JayRogers

High-Low MA Difference Channels [Final]

Ok final revision. Won't be doing any more to this unless absolutely necessary. Really need to make sure I'm done tweaking things before I publish in future..

Description:
  • High and Low sourced MA channels extending out from a median ( hl2 sourced) MA.
  • Large array of MA variants to choose from.
  • Fixed resolutions available - can be disabled if desired.

Usage:
Intended help find support and resistance levels within the flow of the market. It can be used similarly to Bollinger Bands , with length/period and multiplier performing much the same way in setup, and the extremes often marking good points for a turn - but the added bonus of helping mark other potential turns and breaks when set up appropriately.

I've included the following MA variants for a wide array of different basis to help fit different needs and situations.
  • SMA
  • EMA
  • WMA
  • VWMA
  • SMMA
  • DEMA
  • HullMA
  • LSMA

May the pips be with you.
Remove from Favorite Scripts Add to Favorite Scripts
//@version=2

study(title="High-Low MA Difference Channels [Final]", shorttitle="HLMADC", overlay=true)

// Revision:    3
// Author:      JayRogers
//
// r2 Changes:
//  - Increased amount of up/down channels to 5, and lowered multiplier default to 1 (previously 1.5)
//  - Tweaked default colour scheme.
//  - Pick your MA poison of choice! Added choices for all your common MA variants.
// r3 Changes:
//  - added fixed resolution selection
//  - added input toggle to enable / disable fixed resolution

hlc_typeString  = input(defval="VWMA", title="Pick your Poison: SMA, EMA, WMA, VWMA, SMMA, DEMA, HullMA, LSMA ( case sensitive )", type=string)
hlc_useFixedRes = input(defval=true, title="Use Fixed Resolution? ( otherwise will use current chart resolution )")
hlc_resolution  = input(defval="120", title="Channel Resolution", type=resolution)
hlc_length      = input(defval=50, title="Channel Length", minval=1)
hlc_diffMult    = input(defval=1.0, title="Channel Width Multiplier", minval=0.1, maxval=50)
lsma_offset     = input(defval=0, title="LSMA Offset ( only affects LSMA )")

// Returns MA input selection variant, default to SMA if blank or typo.
maVariant(maT, maS, maL) =>
    v1 = sma(maS, maL)                                                  // Simple
    v2 = ema(maS, maL)                                                  // Exponential
    v3 = wma(maS, maL)                                                  // Weighted
    v4 = vwma(maS, maL)                                                 // Volume Weighted *
    v5 = na(v5[1]) ? sma(maS, maL) : (v5[1] * (maL - 1) + maS) / maL    // Smoothed
    v6 = 2 * ema(maS, maL) - ema(ema(maS, maL), maL)                    // Double Exponential
    v7 = wma(2 * wma(maS, maL / 2) - wma(maS, maL), round(sqrt(maL)))   // Hull
    v8 = linreg(maS, maL, lsma_offset)                                  // Least Squares
    maT=="SMA"?v1 : maT=="EMA"?v2 : maT=="WMA"?v3 : maT=="VWMA"?v4 : maT=="SMMA"?v5 : maT=="DEMA"?v6 : maT=="HullMA"?v7 : maT=="LSMA"?v8 : v1

// Setup hl2, high, and low MA series variables
hl2_line    = maVariant(hlc_typeString, hl2, hlc_length)
high_line   = maVariant(hlc_typeString, high, hlc_length)
low_line    = maVariant(hlc_typeString, low, hlc_length)

// High-Low difference multiplier.
diffMult(num) =>
    hldm = (high_line - low_line) * hlc_diffMult
    hldm * num

// Return fixed resolution series expression, or just series expression for current resolution
timeReso(exp) =>
    hlc_useFixedRes ? security(tickerid, hlc_resolution, exp) : exp 

// Plot base, high, and low MA's
midline     = plot(timeReso(hl2_line), title="Basis MA", color=#0066AA, linewidth=2, transp=50)
highLine    = plot(timeReso(hl2_line + (diffMult(1) / 2)), title="Center Channel Upper", color=silver, transp=100)
lowLine     = plot(timeReso(hl2_line - (diffMult(1) / 2)), title="Center Channel Lower", color=silver, transp=100)
// Fill median high-low channel
fill(highLine, lowLine, title="Center High-Low Fill", color=silver, transp=70)

// ..colour and transparency variables for quicker 'style' edits..
_dc = #0099FF, _dt = 70
// Plot upper difference channels
diffUp1     = plot(timeReso(hl2_line + diffMult(1)), title="High Diff 1", color=_dc, transp=_dt)
diffUp2     = plot(timeReso(hl2_line + diffMult(2)), title="High Diff 2", color=_dc, transp=_dt)
diffUp3     = plot(timeReso(hl2_line + diffMult(3)), title="High Diff 3", color=_dc, transp=_dt)
diffUp4     = plot(timeReso(hl2_line + diffMult(4)), title="High Diff 4", color=_dc, transp=_dt)
diffUp5     = plot(timeReso(hl2_line + diffMult(5)), title="High Diff 5", color=_dc, transp=_dt)
// Plot lower difference channels
diffDown1   = plot(timeReso(hl2_line - diffMult(1)), title="Low Diff 1", color=_dc, transp=_dt)
diffDown2   = plot(timeReso(hl2_line - diffMult(2)), title="Low Diff 2", color=_dc, transp=_dt)
diffDown3   = plot(timeReso(hl2_line - diffMult(3)), title="Low Diff 3", color=_dc, transp=_dt)
diffDown4   = plot(timeReso(hl2_line - diffMult(4)), title="Low Diff 4", color=_dc, transp=_dt)
diffDown5   = plot(timeReso(hl2_line - diffMult(5)), title="Low Diff 5", color=_dc, transp=_dt)
Home Stock Screener Forex Screener Crypto Screener Economic Calendar How It Works Chart Features Pricing House Rules Moderators Website & Broker Solutions Widgets Charting Solutions Help Center Feature Request Blog & News FAQ Wiki Twitter
Profile Profile Settings Account and Billing TradingView Coins My Support Tickets Help Center Ideas Published Followers Following Private Messages Chat Sign Out