Madrid

Madrid Trend Spotter

595 1 85
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
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)
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
United States
United Kingdom
India
Deutschland
España
France
Italia
Polska
Brasil
Россия
Türkiye
Indonesia
Malaysia
日本
한국
中国
Home Stock Screener Forex Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators Website & Broker Solutions Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter
Profile Profile Settings Account and Billing Priority Support Ideas Published Followers Following Private Messages Chat Sign Out