Trade Archer - Moving Averages - v1.4F

Trade Archer Moving Averages has been updated!

Moving averages are one of the cornerstones to technical analysts tool box. There are several different kinds of moving averages of which the most common can be selected. Up to four moving averages may be configured and displayed with the option to show clouds between them. Additionally I have added a trend identification system that analyzes the slopes of the moving averages instead of relying on moving average cross overs for long/short signals.

- Multiple Moving Average Choices including: SMA , EMA , DEMA , TEMA , RMA, HMA , WMA , and VWMA .
- Four fully customizable MAs including length, color, and/or optional clouds between the MAs.
- Three ways to display MA trends: bar color, background and/or colored shapes.

The default settings for the MA lengths are: 9, 19, 50, 200. MAs default to EMAs if none are selected.
If you use a blend of MAs, like SMA and EMA , you can apply the indicator again to the same chart and enable/disable the ones you want visible, their type, and trend display.

If you have any questions or need help configuring, feel free to contact me.

Good luck
Trade Archer

오픈 소스 스크립트

이 스크립트의 오써는 참된 트레이딩뷰의 스피릿으로 이 스크립트를 오픈소스로 퍼블리쉬하여 트레이더들로 하여금 이해 및 검증할 수 있도록 하였습니다. 오써를 응원합니다! 스크립트를 무료로 쓸 수 있지만, 다른 퍼블리케이션에서 이 코드를 재사용하는 것은 하우스룰을 따릅니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.


이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.

차트에 이 스크립트를 사용하시겠습니까?
//Created By User Trade Archer (Kevin Johnson)
//Last Update 8/4/2015
//Added support for SMA, EMA, DEMA, TEMA, WMA, HMA, RMA, and VWMA.  Defaults to EMA
//Note: If you make some neat additions, let me know.  Thanks & Enjoy

study(title="Trade Archer - Moving Averages - v1.4F", shorttitle="TA-MAs-v1.4F", overlay=true, precision=2)
//Collect source input and Moving Average Lengths
src = input(close, defval=close, type=source, title="Source:")
fast = input(9, minval=2, step=1, defval=9, type=integer, title="Fast MA Length")
medfast = input(19, minval=2, step=1, defval=19, type=integer, title="Medfast MA Length")
medslow = input(50, minval=2, step=1, defval=50, type=integer, title="Medslow MA Length")
slow = input(200, minval=2, step=1, defval=200, type=integer, title="Slow MA Length")

//Trend is based of combination of two MAs. Preferably MA1 length is shorter than MA2
ma1src = input(1, minval=1, defval=1, maxval=3, type=integer, step=1, title="MA1: (1) *Fast, (2)  MedFast, (3)  MedSlow")
ma2src = input(3, minval=2, defval=3, maxval=4, type=integer, step=1, title="MA2: (2)  MedFast, (3) *MedSlow, (4)  Slow")

//Coloring Options
usebg = input(true, defval=true, type=bool, title="Color Background of Trend")
usedots = input(true, defval=true, type=bool, title="Color Shape of Trend")
usebar = input(true, defval=true, type=bool, title="Color Bars of Trend")

//Set all MAs to a certain type
usesma = input(false, defval=false, type=bool, title="SMA")
useema = input(true, defval=true, type=bool, title="EMA (default)")
usedema = input(false, defval=false, type=bool, title="DEMA")
usetema = input(false, defval=false, type=bool, title="TEMA")
usewma = input(false, defval=false, type=bool, title="WMA")
usehma = input(false, defval=false, type=bool, title="HMA")
userma = input(false, defval=false, type=bool, title="RMA")
usevwma = input(false, defval=false, type=bool, title="VWMA")

dema(s,l) => e1 = ema(s, l), e2 = ema(e1, l), out = 2 * e1 - e2
tema(s,l) => e1 = ema(s, l), e2 = ema(e1, l), e3 = ema(e2, l), out = 3 * (e1 - e2) + e3
hma(s,l) => out = wma( 2*wma(s, l/2)-wma(s, l), round(sqrt(l)) )
ma(s,l) => out = usesma ? sma(s,l) : useema ? ema(s,l) : usewma ? wma(s,l) : usehma ? hma(s,l) : userma ? rma(s,l) :
      usevwma ? vwma(s,l) : usedema ? dema(s,l) : usetema ? tema(s,l) : ema(s,l)
maSelect(c) => out = ma1src == 1 ? ma(src,fast) : ma1src == 2 ? ma(src,medfast) : ma1src == 3 ? ma(src,medslow) : ma1src == 4 ? ma(src,slow) : ema(src,50)
isLong = close > ma(src,50)
isShort = close <= ma(src,50)

//One time calculations
mafast = ma(src,fast)
mamedfast = ma(src,medfast)
mamedslow = ma(src,medslow)
maslow = ma(src,slow)

ma1check = maSelect(ma1src)
ma2check = maSelect(ma2src)

//plot MAs & save as variable
pfast = plot( mafast, linewidth=1, color=green, title="Fast MA" )
pmedfast = plot( mamedfast, linewidth=1, color=green, title="Medfast MA" )
pmedslow = plot( mamedslow, linewidth=2, color=red, title="Medslow MA" )
pslow = plot( maslow, linewidth=1, color=maroon, title="Slow MA" )

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

//Converging and Diverging Conditionals
rfLength = 2
condcr1f2 = rising(ma1check,rfLength) and falling(ma2check,rfLength)  //condc1
condcf1r2 = falling(ma1check,rfLength) and rising(ma2check,rfLength)  //condc2

conddr1r2 = rising(ma1check,rfLength) and rising(ma2check,rfLength)   //condd1
conddf1f2 = falling(ma1check,rfLength) and falling(ma2check,rfLength) //condd2

upColor = lime
neColor = yellow
dnColor = red
//Color Trend of background, bar, or shapes
bgcolor(usebg and condcr1f2 or usebg and conddr1r2 ? upColor : usebg and condcf1r2 or usebg and conddf1f2 ? dnColor : usebg ? neColor : na, transp=90)
plotshape(usedots, style=shape.square, location=location.bottom, color=condcr1f2 or conddr1r2 ? upColor : condcf1r2 or conddf1f2 ? dnColor : neColor, title="Dots", transp=0)
barcolor(usebar and condcr1f2 or usebar and conddr1r2 ? upColor : usebar and condcf1r2 or usebar and conddf1f2 ? dnColor : usebar ? neColor : na)