MTF Moving average cross candle color

Cmeeker778

New member
I am in need of help with finishing this code.

I'm trying to color lower timeframe candles, with a shift in moving average cross on a higher timeframe.

So if the 10 min 3 and 10 ema hasn't crossed, then the colors will not shift until that occurs.

I have line drawn in where the 10 min has shifted, but as you can see the candle colors are not steady or consistent on the up move (the colors change too much, should be steady change)
Any help would be appreciated!

FYI:
The SuperMomentum indicator is a proprietary indicator, cannot be shared. I did not create. Sorry


declare lower;

input Fast = 3;
input Slow = 10;
input displace = 0;
input priceclose = close;
input averageType = AverageType.EXPONENTIAL;
input period = AggregationPeriod.TEN_MIN;


plot AVG = MovingAverage(averageType, close(period = aggregationperiod.ten_min), FASt) - MovingAverage(averageType, close(period = aggregationPeriod.TEN_MIN), SLOW);
plot ZeroLine = 0;
AVG.DefineColor("Up", GetColor(1));
AVG.DefineColor("Down", GetColor(0));
AVG.AssignValueColor(if AVG > AVG[1] then AVG.Color("Up") else AVG.Color("Down"));
AssignPriceColor(if AVG > AVG[1] then AVG.Color("Up") else AVG.Color("Down"));
 

Attachments

  • example code and screenshot.png
    example code and screenshot.png
    188.7 KB · Views: 214
Last edited by a moderator:
Solution
The issue you have is in this piece of code:
Code:
AVG > AVG[1]
which only returns TRUE on the single bar where the AVG has increased. You can change it to
Code:
AVG >= AVG[1]
which will return TRUE for any bar where it has not decreased. Your 10 minute line does not change gradually between values -- it is perfectly flat for the 10 minutes it covers. Since it only shifts between 10 minute increments, it only triggers on the 1m chart when the 10m plot has changed values.

Hope that helps. I haven't had any coffee yet today and I'm not sure I'm very clear.

-mashume
The issue you have is in this piece of code:
Code:
AVG > AVG[1]
which only returns TRUE on the single bar where the AVG has increased. You can change it to
Code:
AVG >= AVG[1]
which will return TRUE for any bar where it has not decreased. Your 10 minute line does not change gradually between values -- it is perfectly flat for the 10 minutes it covers. Since it only shifts between 10 minute increments, it only triggers on the 1m chart when the 10m plot has changed values.

Hope that helps. I haven't had any coffee yet today and I'm not sure I'm very clear.

-mashume
 
Solution

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

I am in need of help with finishing this code.

I'm trying to color lower timeframe candles, with a shift in moving average cross on a higher timeframe.

So if the 10 min 3 and 10 ema hasn't crossed, then the colors will not shift until that occurs.

I have line drawn in where the 10 min has shifted, but as you can see the candle colors are not steady or consistent on the up move (the colors change too much, should be steady change)
Any help would be appreciated!

declare lower;

input Fast = 3;
input Slow = 10;
input displace = 0;
input priceclose = close;
input averageType = AverageType.EXPONENTIAL;
input period = AggregationPeriod.TEN_MIN;


plot AVG = MovingAverage(averageType, close(period = aggregationperiod.ten_min), FASt) - MovingAverage(averageType, close(period = aggregationPeriod.TEN_MIN), SLOW);
plot ZeroLine = 0;
AVG.DefineColor("Up", GetColor(1));
AVG.DefineColor("Down", GetColor(0));
AVG.AssignValueColor(if AVG > AVG[1] then AVG.Color("Up") else AVG.Color("Down"));
AssignPriceColor(if AVG > AVG[1] then AVG.Color("Up") else AVG.Color("Down"));
Is it possible to share the SuperMomentum indicator?
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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