MTF MACD Labels For ThinkOrSwim

CodeBee

New member
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.
 
Solution
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.

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...
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.

when asking for a mod to a study, look it up so you know the correct names.
MACD doesn't have a macd line or a signal line.
it has outputs of - Value and Avg.

are you looking for when a value 'crosses above' another value? (just the first bar)
or when one value is greater than the other? (a group of bars) ( guessing this one)

https://tlc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/M-N/MACD
 
Last edited:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

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.

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));
#

2X4GUh9.jpg
 
Solution
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));
#

2X4GUh9.jpg
Thank you. I will try tomorrow.
 
Thread starter Similar threads Forum Replies Date
E MTF Stacked Moving Averages Questions 1
M MTF AMA Questions 2
C MTF EMA cloud Questions 1
V MTF Marubozu signals Questions 0
N Wanting MTF Stochastic Momentum Index Labels Questions 1

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
531 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

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.

How do I get started?

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.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top