How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Feature Request FAQ Help & Wiki Twitter

564 1
This study shows a pair of colored moving averages filled with the color of the direction of the trend.
This study calculates the moving averages with standard or exponential M.A.'s. By default it uses a couple of fast exponential moving average pair (5,13) with the closing price as the source.

Parameters:
• source
• fast MA length
• slow MA Length
• type of moving average
```// Madrid : 16/Jun/2015 12:12 : 2.0 : Trend Spotter
// This study shows a pair of colored moving averages filled with the color of the
// direction of the trend.
// This study calculates the moving averages with standard or exponential M.A.'s
// By default it uses a couple of fast exponential moving average pair (5,13) with
// the closing price as the source.
// Parameters: source, fast MA length, slow MA Length, type of moving average.
//
src = input(close, type="source")
fastLen = input(5, minval=1)
slowLen = input(13, minval=1)
ema = input(true, title="Exponential")

maColor(ma) =>
change(ma,3)>=0?lime:red

fastMA = ema?ema(src, fastLen):sma(src, fastLen)
slowMA = ema?ema(src, slowLen):sma(src, slowLen)

fastUT = plot(fastMA>=slowMA?fastMA:na, color=maColor(fastMA), style=linebr, linewidth=1)
slowUT = plot(fastMA>=slowMA?slowMA:na, color=maColor(slowMA), style=linebr,linewidth=1)
fill(fastUT, slowUT, color=lime, transp=80)

fastDT = plot(fastMA<slowMA?fastMA:na, color=maColor(fastMA), style=linebr,linewidth=1)
slowDT = plot(fastMA<slowMA?slowMA:na, color=maColor(slowMA), style=linebr,linewidth=1)
fill(fastDT, slowDT, color=red, transp=80)

plot(fastMA, color=maColor(fastMA), linewidth=2)
plot(slowMA, color=maColor(slowMA), linewidth=2)
```
What is your idea behind? Why using a pair of moving average, simple or exponential, and not plot 2 moving averages 8 and 55?
Nice coding!
United States
United Kingdom
India
España
France
Italia
Polska
Brasil
Россия
Türkiye
Indonesia

한국
Home Stock Screener Forex Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter