OPEN-SOURCE SCRIPT
MTF MACD – 1m / 15m / 1D / 1W

//version=6
indicator("MTF MACD – 1m / 15m / 1D / 1W", overlay=false)
// MACD inputs
fastLen = input.int(12, "Fast length")
slowLen = input.int(26, "Slow length")
signalLen = input.int(9, "Signal length")
// Multi-timeframe MACD using built-in ta.macd()
[macd_1m, signal_1m, hist_1m] = request.security(syminfo.tickerid, "1", ta.macd(close, fastLen, slowLen, signalLen))
[macd_15m, signal_15m, hist_15m] = request.security(syminfo.tickerid, "15", ta.macd(close, fastLen, slowLen, signalLen))
[macd_1d, signal_1d, hist_1d] = request.security(syminfo.tickerid, "D", ta.macd(close, fastLen, slowLen, signalLen))
[macd_1w, signal_1w, hist_1w] = request.security(syminfo.tickerid, "W", ta.macd(close, fastLen, slowLen, signalLen))
// Plot MACD lines for each timeframe
plot(macd_1m, title="MACD 1m", color=color.red, linewidth=2)
plot(macd_15m, title="MACD 15m", color=color.blue, linewidth=2)
plot(macd_1d, title="MACD 1D", color=color.green, linewidth=2)
plot(macd_1w, title="MACD 1W", color=color.orange, linewidth=2)
// (Optional) you can uncomment these if you also want signals/histograms:
// plot(signal_1m, title="Signal 1m", color=color.new(color.red, 50), style=plot.style_dotted)
// plot(signal_15m, title="Signal 15m", color=color.new(color.blue, 50), style=plot.style_dotted)
// plot(signal_1d, title="Signal 1D", color=color.new(color.green, 50), style=plot.style_dotted)
// plot(signal_1w, title="Signal 1W", color=color.new(color.orange, 50), style=plot.style_dotted)
// plot(hist_1m, title="Hist 1m", color=color.red, style=plot.style_histogram)
// plot(hist_15m, title="Hist 15m", color=color.blue, style=plot.style_histogram)
// plot(hist_1d, title="Hist 1D", color=color.green, style=plot.style_histogram)
// plot(hist_1w, title="Hist 1W", color=color.orange, style=plot.style_histogram)
indicator("MTF MACD – 1m / 15m / 1D / 1W", overlay=false)
// MACD inputs
fastLen = input.int(12, "Fast length")
slowLen = input.int(26, "Slow length")
signalLen = input.int(9, "Signal length")
// Multi-timeframe MACD using built-in ta.macd()
[macd_1m, signal_1m, hist_1m] = request.security(syminfo.tickerid, "1", ta.macd(close, fastLen, slowLen, signalLen))
[macd_15m, signal_15m, hist_15m] = request.security(syminfo.tickerid, "15", ta.macd(close, fastLen, slowLen, signalLen))
[macd_1d, signal_1d, hist_1d] = request.security(syminfo.tickerid, "D", ta.macd(close, fastLen, slowLen, signalLen))
[macd_1w, signal_1w, hist_1w] = request.security(syminfo.tickerid, "W", ta.macd(close, fastLen, slowLen, signalLen))
// Plot MACD lines for each timeframe
plot(macd_1m, title="MACD 1m", color=color.red, linewidth=2)
plot(macd_15m, title="MACD 15m", color=color.blue, linewidth=2)
plot(macd_1d, title="MACD 1D", color=color.green, linewidth=2)
plot(macd_1w, title="MACD 1W", color=color.orange, linewidth=2)
// (Optional) you can uncomment these if you also want signals/histograms:
// plot(signal_1m, title="Signal 1m", color=color.new(color.red, 50), style=plot.style_dotted)
// plot(signal_15m, title="Signal 15m", color=color.new(color.blue, 50), style=plot.style_dotted)
// plot(signal_1d, title="Signal 1D", color=color.new(color.green, 50), style=plot.style_dotted)
// plot(signal_1w, title="Signal 1W", color=color.new(color.orange, 50), style=plot.style_dotted)
// plot(hist_1m, title="Hist 1m", color=color.red, style=plot.style_histogram)
// plot(hist_15m, title="Hist 15m", color=color.blue, style=plot.style_histogram)
// plot(hist_1d, title="Hist 1D", color=color.green, style=plot.style_histogram)
// plot(hist_1w, title="Hist 1W", color=color.orange, style=plot.style_histogram)
Script de código abierto
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Exención de responsabilidad
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Script de código abierto
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Exención de responsabilidad
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.