MACD Multi-Timeframe- TraderR0BERT

MACD with ability to show multiple timeframes on the chart. Set the higher-timeframe MACD at a 5-multiple above the current timeframe that you're on.

Remove from Favorite Scripts Add to Favorite Scripts
//Created by @TraderR0BERT, NETWORTHIE.COM, last updated 01/26/2016
//MACD Indicator with Histogram
//Resolution input option for higher/lower time frames

study(title="MACD Timeframe", shorttitle="MACD TF")
source = close

fastLength = input(12, minval=1), slowLength=input(26,minval=1)
Timeframe = input(title="Timeframe", type=resolution, defval="W")

fastMA = ema(source, fastLength)
slowMA = ema(source, slowLength)

//Script for Indicator
macd = fastMA - slowMA
signal = sma(macd, signalLength)
hist = macd - signal
zeroline = 0

//Timeframe Optionality
MacdTF = security(tickerid, Timeframe, macd)
SignalTF = security(tickerid, Timeframe, signal)
HistTF = security(tickerid, Timeframe, hist)

//Histogram Color Definitions Current Timeframe
histA_IsUp = hist > hist[1] and hist > 0
histA_IsDown = hist < hist[1] and hist > 0
histB_IsDown = hist < hist[1] and hist <= 0
histB_IsUp = hist > hist[1] and hist <= 0

//Histogram Color Definitions Timeframe Optionality
histA_TF_IsUp = HistTF > HistTF[1] and HistTF > 0
histA_TF_IsDown = HistTF < HistTF[1] and HistTF > 0
histB_TF_IsDown = HistTF < HistTF[1] and HistTF <= 0
histB_TF_IsUp = HistTF > HistTF[1] and HistTF <= 0

plot_color = histA_IsUp ? lime : histA_IsDown ? green : histB_IsDown ? red : histB_IsUp ? maroon : white
Plot_color2 = histA_TF_IsUp ? lime : histA_TF_IsDown ? green : histB_TF_IsDown ? red : histB_TF_IsUp ? maroon : white

//Plot Current Timeframe
plot(hist, color=plot_color, style=columns, linewidth=3)
plot(macd, title="MACD", color=lime, linewidth=4)
plot(signal, title="Signal Line", color=blue, linewidth=3)
plot(zeroline, title="Zero Line", color=black, linewidth=3)

//Plot Timeframe Optionality
plot(HistTF, color=plot_color, style=columns, linewidth=3)
plot(MacdTF, title="MACD", color=lime, linewidth=4)
plot(SignalTF, title="Signal Line", color=blue, linewidth=3)

//Alert Function for MACD crossing Zero Line
Zero_Cross = cross(macd, zeroline)
Zero_Cross_TF = cross(MacdTF, zeroline)
alertcondition(Zero_Cross, title="Low TF MACD crossing Zero", message="Lower TF MACD crossing Zero")
alertcondition(Zero_Cross_TF, title="High TF MACD crossing Zero", message="Higher TF MACD crossing Zero")

//Alert Function for MACD crossing Signal Line
Signal_Cross = cross(macd, signal)
Signal_Cross_TF = cross(MacdTF, SignalTF)
alertcondition(Signal_Cross, title="Low TF MACD crossing Signal", message="Lower TF MACD crossing Signal")
alertcondition(Signal_Cross_TF, title="High TF MACD crossing Signal", message="Higher TF MACD crossing Signal")

Hi, with which trading platform can I use it? thanks
EN English
EN English (UK)
EN English (IN)
DE Deutsch
FR Français
ES Español
IT Italiano
PL Polski
TR Türkçe
RU Русский
PT Português
ID Bahasa Indonesia
MS Bahasa Melayu
TH ภาษาไทย
VI Tiếng Việt
JA 日本語
KO 한국어
ZH 简体中文
ZH 繁體中文
AR العربية
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 Contact Support Ideas Published Followers Following Private Messages Chat Sign Out