Madrid

Madrid Trend Spotter

635 1 92
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
France
España
Italia
Polska
Türkiye
Россия
Brasil
Indonesia
Malaysia
Việt Nam
日本
한국
简体
繁體
Home Stock Screener Forex Signal Finder Cryptocurrency Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators Website & Broker Solutions Widgets Stock Charting Library Feature Request Blog & News FAQ Help & Wiki Twitter
Profile Profile Settings Account and Billing My Support Tickets Priority Support Contact Support Ideas Published Followers Following Private Messages Chat Sign Out