Create Multi-TimeFrame (MTF) MACD Labels

Hi @SleepyZ, @tomsk, @BenTen ,

Can you please tell me what I’m doing wrong here?

I have this code painting my candles based on the MACD being above/below zero and also if the Value is above/below Avg (NOT JUST HIGHER/LOWER from the previous bar, but in relation to the Avg line), as you can see from the pic.

But when I try to use it, to create labels which will allow me to see what colors the candles are on higher timeframes (so when I’m on the 5min chart, I’d like to be able to see what colors are the bars on the 15min, 1H, 4H, 1D, 1W etc via colored labels on the top left) it doesn’t pain the correct labels. Can you please help me? Spent countless hours on this and cannot seem to know what’s wrong.

Thank you in advance for your help and have a great New Year.
 

Attachments

  • IMG_6790.jpeg
    IMG_6790.jpeg
    532.4 KB · Views: 107
  • IMG_6791.jpeg
    IMG_6791.jpeg
    337.1 KB · Views: 99
Last edited by a moderator:

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

Here you go and thank you:


input period = AggregationPeriod.HOUR;

input fastLength = 5;
input slowLength = 32;
input MACDLength = 5;
input averageType = AverageType.EXPONENTIAL;

def Value = MovingAverage(averageType, close, fastLength) -
MovingAverage(averageType, close, slowLength);
def Avg = MovingAverage(averageType, Value, MACDLength);

def Diff = Value - Avg;
plot ZeroLine = 0;
addlabel (yes, "H", if Diff >= 0 and Value > Avg then Color.Green else if Diff >= 0
and Value < Avg then Color.Cyan
else if Diff < 0 and Value < Avg then Color.Red else if Diff < 0 and Value > Avg
then Color.Orange else color.white);
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
630 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