tradearcher

Trade Archer - Moving Averages - v1.4F

Trade Archer Moving Averages has been updated!

Description:
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.

Features:
- 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.

Notes:
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
tradearcher@gmail.com
www.tradearcher.com
@tradearcher

Script de código aberto

Dentro do verdadeiro espírito TradingView, o autor deste script publicou ele como um script de código aberto, para que os traders possam compreender e checar ele. Um viva ao autor! Você pode usá-lo gratuitamente, mas a reutilização deste código em uma publicação é regida pelas Regras da Casa. Você pode favoritá-lo para usá-lo em um gráfico.

Aviso legal

As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.

Quer usar esse script no gráfico?
//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")

//Functions
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)