Trade Archer - Moving Averages - v1

A group of four moving averages used for price smoothing. It also creates a cloud between Fast Ma and Medfast MA, Medfast MA and Medslow MA, and Medslow MA and Slow MA. Originally only Exponential Moving Averages were available, however the option to choose SMA , EMA (default), RMA, WMA , and VWMA were added. Also added was the option to choose the source of input. If any interesting additions are added, please let me know so I can update the script.

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.


The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?
//Created By User Trade Archer (Kevin Johnson)
//Last Update 1/31/2015
//Added support for SMA, WMA, RMA, and VWMA.  Defaults to EMA
//Note: If you make some neat additions, let me know via PM.  Thanks & Enjoy

study(title="TA-MAs-v1", shorttitle="TA-MAs-v1", overlay=true, precision=2)

//Collect input
source = input(3, type=integer, minval=0, maxval=6, defval=3, title="Source: open=0 high=1 low=2 close=3 hl2=4 hlc3=5 ohlc4=6")
fast = input(9, minval=1, title="Fast MA")
medfast = input(19, minval=1, title="Medfast MA")
medslow = input(50, minval=1, title="Medslow MA")
slow = input(200, minval=1, title="Slow MA")

usesma = input(false, title="SMA", defval=false, type=bool, defval=false)
useema = input(true, title="EMA (default)", defval=true, type=bool, defval=true)
usewma = input(false, title="WMA", defval=false, type=bool, defval=false)
userma = input(false, title="RMA", defval=false, type=bool, defval=false)
usevwma = input(false, title="VWMA", defval=false, type=bool, defval=false)

//Translate source
src = source == 0 ? open :
      source == 1 ? high :
      source == 2 ? low :
      source == 3 ? close :
      source == 4 ? hl2 :
      source == 5 ? hlc3 :
      source == 6 ? ohlc4 :

//Selects check MA type.  Defaults to EMA
ma1 = usesma ? sma( src, fast) : useema ? ema( src, fast) : usewma ? wma( src, fast) : userma ? rma( src, fast) :
      usevwma ? vwma( src, fast) : ema( src, fast)
ma2 = usesma ? sma( src, medfast) : useema ? ema( src, medfast) : usewma ? wma( src, medfast) : userma ? rma( src, medfast) :
      usevwma ? vwma( src, medfast) : ema( src, medfast)
ma3 = usesma ? sma( src, medslow) : useema ? ema( src, medslow) : usewma ? wma( src, medslow) : userma ? rma( src, medslow) :
      usevwma ? vwma( src, medslow) : ema( src, medslow)
ma4 = usesma ? sma( src, slow) : useema ? ema( src, slow) : usewma ? wma( src, slow) : userma ? rma( src, slow) :
      usevwma ? vwma( src, slow) : ema( src, slow)

//plot MAs& save as variable
pfast = plot( ma1, linewidth=1, color=lime, title="Fast MA" )
pmedfast = plot( ma2, linewidth=1, color=orange, title="Medfast MA" )
pmedslow = plot( ma3, linewidth=2, color=red, title="Medslow MA" )
pslow = plot( ma4, linewidth=3, color=maroon, title="Slow MA" )

//fill between two emas
fquickcloud = fill(pfast, pmedfast, color=green, transp=65, title="Quick Cloud")
fnormalcloud = fill(pmedfast, pmedslow, color=yellow, transp=75, title="Normal Cloud")
fslowcloud = fill(pmedslow, pslow, color=red, transp=85, title="Slow Cloud")