Madrid

Madrid Trend Spotter

486 1 66
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:
Remove from Favorite Scripts Add to Favorite Scripts
// 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.
//
study("Madrid Trend Spotter", overlay=true, shorttitle="MTrendS")
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)
MakisMooz
a year ago
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!
+1 Reply
Ideas Scripts Chart
United States
United Kingdom
India
España
France
Italia
Brasil
Россия
Türkiye
日本
한국
Home Stock Screener 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
Private Messages Chat Ideas Published Followers Following Priority Support Public Profile Profile Settings Account and Billing Sign Out