Looking for help in configuring the MTF MACD label. 1D, 4H, 1H, 15M, 5M label for MACD. If macd line crosses above signal line within these time frames the label will be green otherwise, the label will be red. This will help to understand overall trend in MTF. TIA.
# macd_mtf_labels
#https://usethinkscript.com/threads/mtf-trend-label.15204/
#MTF trend label
script macd1 {
input price = close;
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;
plot Value = MovingAverage(averageType, price, fastLength) - MovingAverage(averageType, price, slowLength);
plot avg = MovingAverage(averageType, Value...
Looking for help in configuring the MTF MACD label. 1D, 4H, 1H, 15M, 5M label for MACD. If macd line crosses above signal line within these time frames the label will be green otherwise, the label will be red. This will help to understand overall trend in MTF. TIA.
Looking for help in configuring the MTF MACD label. 1D, 4H, 1H, 15M, 5M label for MACD. If macd line crosses above signal line within these time frames the label will be green otherwise, the label will be red. This will help to understand overall trend in MTF. TIA.
# macd_mtf_labels
#https://usethinkscript.com/threads/mtf-trend-label.15204/
#MTF trend label
script macd1 {
input price = close;
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;
plot Value = MovingAverage(averageType, price, fastLength) - MovingAverage(averageType, price, slowLength);
plot avg = MovingAverage(averageType, Value, MACDLength);
plot Diff = Value - Avg;
};
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;
#input showBreakoutSignals = no;
# 1D, 4H, 1H, 15M, 5M
#---------------------------------
# get chart agg time
def chartagg = getaggregationperiod();
def chartmin = chartagg/(1000*60);
#---------------------------------
input agg1 = AggregationPeriod.day;
input agg2 = AggregationPeriod.four_HOURs;
input agg3 = AggregationPeriod.HOUR;
input agg4 = AggregationPeriod.fifteen_min;
input agg5 = AggregationPeriod.five_min;
def agg1min = agg1/60000;
def agg2min = agg2/60000;
def agg3min = agg3/60000;
def agg4min = agg4/60000;
def agg5min = agg5/60000;
def price1 = close(period = agg1);
def price2 = close(period = agg2);
def price3 = close(period = agg3);
def price4 = close(period = agg4);
def price5 = close(period = agg5);
def m1v = macd1(price1, fastLength, slowLength, MACDLength, averageType).value;
def m2v = macd1(price2, fastLength, slowLength, MACDLength, averageType).value;
def m3v = macd1(price3, fastLength, slowLength, MACDLength, averageType).value;
def m4v = macd1(price4, fastLength, slowLength, MACDLength, averageType).value;
def m5v = macd1(price5, fastLength, slowLength, MACDLength, averageType).value;
def m1a = macd1(price1, fastLength, slowLength, MACDLength, averageType).avg;
def m2a = macd1(price2, fastLength, slowLength, MACDLength, averageType).avg;
def m3a = macd1(price3, fastLength, slowLength, MACDLength, averageType).avg;
def m4a = macd1(price4, fastLength, slowLength, MACDLength, averageType).avg;
def m5a = macd1(price5, fastLength, slowLength, MACDLength, averageType).avg;
def up1 = (m1v > m1a);
def up2 = (m2v > m2a);
def up3 = (m3v > m3a);
def up4 = (m4v > m4a);
def up5 = (m5v > m5a);
addlabel(1, " ", color.black);
addlabel(1, agg1min + " min MACD " + round(m1a,2) , (if up1 then color.green else color.red));
addlabel(1, agg2min + " min MACD " + round(m2a,2) , (if up2 then color.green else color.red));
addlabel(1, agg3min + " min MACD " + round(m3a,2) , (if up3 then color.green else color.red));
addlabel(1, agg4min + " min MACD " + round(m4a,2) , (if up4 then color.green else color.red));
addlabel(1, agg5min + " min MACD " + round(m5a,2) , (if up5 then color.green else color.red));
#
Thank you. I will try tomorrow.calc 5 MTF MACD values
when value > avg then green , else red
Code:# macd_mtf_labels #https://usethinkscript.com/threads/mtf-trend-label.15204/ #MTF trend label script macd1 { input price = close; input fastLength = 12; input slowLength = 26; input MACDLength = 9; input averageType = AverageType.EXPONENTIAL; plot Value = MovingAverage(averageType, price, fastLength) - MovingAverage(averageType, price, slowLength); plot avg = MovingAverage(averageType, Value, MACDLength); plot Diff = Value - Avg; }; input fastLength = 12; input slowLength = 26; input MACDLength = 9; input averageType = AverageType.EXPONENTIAL; #input showBreakoutSignals = no; # 1D, 4H, 1H, 15M, 5M #--------------------------------- # get chart agg time def chartagg = getaggregationperiod(); def chartmin = chartagg/(1000*60); #--------------------------------- input agg1 = AggregationPeriod.day; input agg2 = AggregationPeriod.four_HOURs; input agg3 = AggregationPeriod.HOUR; input agg4 = AggregationPeriod.fifteen_min; input agg5 = AggregationPeriod.five_min; def agg1min = agg1/60000; def agg2min = agg2/60000; def agg3min = agg3/60000; def agg4min = agg4/60000; def agg5min = agg5/60000; def price1 = close(period = agg1); def price2 = close(period = agg2); def price3 = close(period = agg3); def price4 = close(period = agg4); def price5 = close(period = agg5); def m1v = macd1(price1, fastLength, slowLength, MACDLength, averageType).value; def m2v = macd1(price2, fastLength, slowLength, MACDLength, averageType).value; def m3v = macd1(price3, fastLength, slowLength, MACDLength, averageType).value; def m4v = macd1(price4, fastLength, slowLength, MACDLength, averageType).value; def m5v = macd1(price5, fastLength, slowLength, MACDLength, averageType).value; def m1a = macd1(price1, fastLength, slowLength, MACDLength, averageType).avg; def m2a = macd1(price2, fastLength, slowLength, MACDLength, averageType).avg; def m3a = macd1(price3, fastLength, slowLength, MACDLength, averageType).avg; def m4a = macd1(price4, fastLength, slowLength, MACDLength, averageType).avg; def m5a = macd1(price5, fastLength, slowLength, MACDLength, averageType).avg; def up1 = (m1v > m1a); def up2 = (m2v > m2a); def up3 = (m3v > m3a); def up4 = (m4v > m4a); def up5 = (m5v > m5a); addlabel(1, " ", color.black); addlabel(1, agg1min + " min MACD " + round(m1a,2) , (if up1 then color.green else color.red)); addlabel(1, agg2min + " min MACD " + round(m2a,2) , (if up2 then color.green else color.red)); addlabel(1, agg3min + " min MACD " + round(m3a,2) , (if up3 then color.green else color.red)); addlabel(1, agg4min + " min MACD " + round(m4a,2) , (if up4 then color.green else color.red)); addlabel(1, agg5min + " min MACD " + round(m5a,2) , (if up5 then color.green else color.red)); #
![]()
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
L | Create Multi-TimeFrame (MTF) MACD Labels | Questions | 2 | |
S | Weighted MTF MACD | Questions | 3 | |
E | MTF Bar Counting | Questions | 1 | |
S | MTF EMA Trend | Questions | 0 | |
Z | MTF Heiken-Ashi Trend Line | Questions | 1 |
Start a new thread and receive assistance from our community.
useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.
We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.
If you are new, or just looking for guidance, here are some helpful links to get you started.