Show Heikin-Ashi Candles over TTM trend

JL356

New member
Hi everyone this is from a script here. Is there a way to get the candle to show over the TTM trend, its one or the other, thanks in advance.


def HAclose = ohlc4;
rec HAopen = compoundValue( 1, ( HAopen[1] + HAclose[1] ) / 2, HAclose );
def HAhigh = Max( high, Max( HAopen, HAclose ) );
def HAlow = Min( low, Min( HAopen, HAclose ) );
def haBuy = HAopen <= HAlow;
def haSell = HAopen >= HAhigh;
rec count=if haBuy==1 and count[1]==0 then 1 else if haSell==0 and count[1]>=1 then count[1]+1 else 0;
rec count1=if haSell==1 and count1[1]==0 then 1 else if haBuy==0 and count1[1]>=1 then count1[1]+1 else 0;
def PrimaryUP = if HAopen <= HAlow and habuy==1 and count[1]==0 then yes else no;
def PrimaryDOWN = if HAopen >= HAhigh and hasell==1 and count1[1]==0 then yes else no;

assignpricecolor (if PrimaryUP then Color.white else color.current) ;
AssignPriceColor (if PrimaryDOWN then Color.white else color.current) ;
def shavenBottom = HAopen <= HAlow;
def shavenTop = HAopen >= HAhigh;
 
Solution
Hi everyone this is from a script here. Is there a way to get the candle to show over the TTM trend, its one or the other, thanks in advance.


def HAclose = ohlc4;
rec HAopen = compoundValue( 1, ( HAopen[1] + HAclose[1] ) / 2, HAclose );
def HAhigh = Max( high, Max( HAopen, HAclose ) );
def HAlow = Min( low, Min( HAopen, HAclose ) );
def haBuy = HAopen <= HAlow;
def haSell = HAopen >= HAhigh;
rec count=if haBuy==1 and count[1]==0 then 1 else if haSell==0 and count[1]>=1 then count[1]+1 else 0;
rec count1=if haSell==1 and count1[1]==0 then 1 else if haBuy==0 and count1[1]>=1 then count1[1]+1 else 0;
def PrimaryUP = if HAopen <= HAlow and habuy==1 and count[1]==0 then yes else no;
def PrimaryDOWN = if HAopen >= HAhigh and hasell==1...
Hi everyone this is from a script here. Is there a way to get the candle to show over the TTM trend, its one or the other, thanks in advance.


def HAclose = ohlc4;
rec HAopen = compoundValue( 1, ( HAopen[1] + HAclose[1] ) / 2, HAclose );
def HAhigh = Max( high, Max( HAopen, HAclose ) );
def HAlow = Min( low, Min( HAopen, HAclose ) );
def haBuy = HAopen <= HAlow;
def haSell = HAopen >= HAhigh;
rec count=if haBuy==1 and count[1]==0 then 1 else if haSell==0 and count[1]>=1 then count[1]+1 else 0;
rec count1=if haSell==1 and count1[1]==0 then 1 else if haBuy==0 and count1[1]>=1 then count1[1]+1 else 0;
def PrimaryUP = if HAopen <= HAlow and habuy==1 and count[1]==0 then yes else no;
def PrimaryDOWN = if HAopen >= HAhigh and hasell==1 and count1[1]==0 then yes else no;

assignpricecolor (if PrimaryUP then Color.white else color.current) ;
AssignPriceColor (if PrimaryDOWN then Color.white else color.current) ;
def shavenBottom = HAopen <= HAlow;
def shavenTop = HAopen >= HAhigh;

This combines the two scripts with one price bar coloring scheme.

The image shows the standalone TTM_Trend and the lower chart is the two indicators combined.
Screenshot-2023-04-10-113824.png
Code:
#TTM Trend
input length = 6;
def trendup = reference TTM_Trend(length, "paint bars" = no);
def trenddn = reference TTM_Trend(length, "paint bars" = no).TrendDown;
input colorbars = yes;

#Primary Up/Down
def HAclose = ohlc4;
rec HAopen = compoundValue( 1, ( HAopen[1] + HAclose[1] ) / 2, HAclose );
def HAhigh = Max( high, Max( HAopen, HAclose ) );
def HAlow = Min( low, Min( HAopen, HAclose ) );
def haBuy = HAopen <= HAlow;
def haSell = HAopen >= HAhigh;
rec count=if haBuy==1 and count[1]==0 then 1 else if haSell==0 and count[1]>=1 then count[1]+1 else 0;
rec count1=if haSell==1 and count1[1]==0 then 1 else if haBuy==0 and count1[1]>=1 then count1[1]+1 else 0;
def PrimaryUP = if HAopen <= HAlow and habuy==1 and count[1]==0 then yes else no;
def PrimaryDOWN = if HAopen >= HAhigh and hasell==1 and count1[1]==0 then yes else no;

#assignpricecolor (if PrimaryUP then Color.white else color.current) ;
#AssignPriceColor (if PrimaryDOWN then Color.white else color.current) ;
def shavenBottom = HAopen <= HAlow;
def shavenTop = HAopen >= HAhigh;

#Price Color Combined with both TTM_Trend and PrimaryDOWN Up/Down

AssignPriceColor(if colorbars then if primaryup or primaryDOWN then color.white else if trendup then color.blue else color.red else Color.CURRENT);
 
Solution

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

This combines the two scripts with one price bar coloring scheme.

The image shows the standalone TTM_Trend and the lower chart is the two indicators combined.

Hi @SleepyZ

Thank you for sharing this awesome work, do you have mobile version, like i am looking
when you have color bar on top chart like paint it could be used Boolean dots in settings can be selected for coloring with trend change, i saw this kind of work very long back, but now i really forgot that which indicator or code i have saved, please if you have an idea to add Boolean lines it would definitely helpful for mobile users.

Thank you in advance.
 
Hi @SleepyZ

Thank you for sharing this awesome work, do you have mobile version, like i am looking
when you have color bar on top chart like paint it could be used Boolean dots in settings can be selected for coloring with trend change, i saw this kind of work very long back, but now i really forgot that which indicator or code i have saved, please if you have an idea to add Boolean lines it would definitely helpful for mobile users.

Thank you in advance.

You're welcome!

Sorry, but I have not used the mobile version.
 
Thanks again SleepyZ, is there a way to plot a line under the flat top or flat bottom. I have this but not plotting anything.


#TTM Trend
input length = 6;
def trendup = reference TTM_Trend(length, "paint bars" = no);
def trenddn = reference TTM_Trend(length, "paint bars" = no).TrendDown;
input colorbars = yes;

#Primary Up/Down
def HAclose = ohlc4;
rec HAopen = CompoundValue( 1, ( HAopen[1] + HAclose[1] ) / 2, HAclose );
def HAhigh = Max( high, Max( HAopen, HAclose ) );
def HAlow = Min( low, Min( HAopen, HAclose ) );
def haBuy = HAopen <= HAlow;
def haSell = HAopen >= HAhigh;
rec count = if haBuy == 1 and count[1] == 0 then 1 else if haSell == 0 and count[1] >= 1 then count[1] + 1 else 0;
rec count1 = if haSell == 1 and count1[1] == 0 then 1 else if haBuy == 0 and count1[1] >= 1 then count1[1] + 1 else 0;
def PrimaryUP = if HAopen <= HAlow and haBuy == 1 and count[1] == 0 then yes else no;
def PrimaryDOWN = if HAopen >= HAhigh and haSell == 1 and count1[1] == 0 then yes else no;

#assignpricecolor (if PrimaryUP then Color.white else color.current) ;
#AssignPriceColor (if PrimaryDOWN then Color.white else color.current) ;
def shavenBottom = HAopen <= HAlow;
def shavenTop = HAopen >= HAhigh;

#Price Color Combined with both TTM_Trend and PrimaryDOWN Up/Down

AssignPriceColor(if colorbars then if PrimaryUP or PrimaryDOWN then Color.CYAN else if trendup then Color.WHITE else Color.RED else Color.CURRENT);

#Add horizontal line at top and bottom of PrimaryUp or PrimaryDown candles
if colorbars and (PrimaryUP or PrimaryDOWN) then
plot hline(HAhigh, color = Color.cyan, style = STYLE_SOLID);
plot hline(HAlow, color = Color.cyan, style = STYLE_SOLID);
 
Thanks again SleepyZ, is there a way to plot a line under the flat top or flat bottom. I have this but not plotting anything.


#TTM Trend
input length = 6;
def trendup = reference TTM_Trend(length, "paint bars" = no);
def trenddn = reference TTM_Trend(length, "paint bars" = no).TrendDown;
input colorbars = yes;

#Primary Up/Down
def HAclose = ohlc4;
rec HAopen = CompoundValue( 1, ( HAopen[1] + HAclose[1] ) / 2, HAclose );
def HAhigh = Max( high, Max( HAopen, HAclose ) );
def HAlow = Min( low, Min( HAopen, HAclose ) );
def haBuy = HAopen <= HAlow;
def haSell = HAopen >= HAhigh;
rec count = if haBuy == 1 and count[1] == 0 then 1 else if haSell == 0 and count[1] >= 1 then count[1] + 1 else 0;
rec count1 = if haSell == 1 and count1[1] == 0 then 1 else if haBuy == 0 and count1[1] >= 1 then count1[1] + 1 else 0;
def PrimaryUP = if HAopen <= HAlow and haBuy == 1 and count[1] == 0 then yes else no;
def PrimaryDOWN = if HAopen >= HAhigh and haSell == 1 and count1[1] == 0 then yes else no;

#assignpricecolor (if PrimaryUP then Color.white else color.current) ;
#AssignPriceColor (if PrimaryDOWN then Color.white else color.current) ;
def shavenBottom = HAopen <= HAlow;
def shavenTop = HAopen >= HAhigh;

#Price Color Combined with both TTM_Trend and PrimaryDOWN Up/Down

AssignPriceColor(if colorbars then if PrimaryUP or PrimaryDOWN then Color.CYAN else if trendup then Color.WHITE else Color.RED else Color.CURRENT);

#Add horizontal line at top and bottom of PrimaryUp or PrimaryDown candles
if colorbars and (PrimaryUP or PrimaryDOWN) then
plot hline(HAhigh, color = Color.cyan, style = STYLE_SOLID);
plot hline(HAlow, color = Color.cyan, style = STYLE_SOLID);

Sure

Screenshot 2023-06-18 150912.png
Code:
#TTM Trend
input length = 6;
def trendup = reference TTM_Trend(length, "paint bars" = no);
def trenddn = reference TTM_Trend(length, "paint bars" = no).TrendDown;
input colorbars = yes;

#Primary Up/Down
def HAclose = ohlc4;
rec HAopen = CompoundValue( 1, ( HAopen[1] + HAclose[1] ) / 2, HAclose );
def HAhigh = Max( high, Max( HAopen, HAclose ) );
def HAlow = Min( low, Min( HAopen, HAclose ) );
def haBuy = HAopen <= HAlow;
def haSell = HAopen >= HAhigh;
rec count = if haBuy == 1 and count[1] == 0 then 1 else if haSell == 0 and count[1] >= 1 then count[1] + 1 else 0;
rec count1 = if haSell == 1 and count1[1] == 0 then 1 else if haBuy == 0 and count1[1] >= 1 then count1[1] + 1 else 0;
def PrimaryUP = if HAopen <= HAlow and haBuy == 1 and count[1] == 0 then yes else no;
def PrimaryDOWN = if HAopen >= HAhigh and haSell == 1 and count1[1] == 0 then yes else no;

#assignpricecolor (if PrimaryUP then Color.white else color.current) ;
#AssignPriceColor (if PrimaryDOWN then Color.white else color.current) ;
def shavenBottom = HAopen <= HAlow;
def shavenTop = HAopen >= HAhigh;

#Price Color Combined with both TTM_Trend and PrimaryDOWN Up/Down

AssignPriceColor(if colorbars then if PrimaryUP or PrimaryDOWN then Color.CYAN else if trendup then Color.WHITE else Color.RED else Color.CURRENT);

#Add horizontal line at top and bottom of PrimaryUp or PrimaryDown candles

plot hline = if colorbars and shaventop then HAhigh else double.nan;
hline.setdefaultColor( Color.cyan);
hline.setpaintingStrategy(paintingStrategy.HORIZONTAL);
hline.setlineWeight(3);
plot lline = if colorbars and shavenbottom then HAlow else double.nan;
lline.setdefaultColor( Color.cyan);
lline.setpaintingStrategy(paintingStrategy.HORIZONTAL);
lline.setlineWeight(3);
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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