Help with study to show HH HL LL LH on the chart with Heiken Aishi candles

bmn

Member
Using Heiken Aishi candles on the chart, I'm trying to just draw a small line at the highs and lows, with a chart bubble showing what it is. something like this image that I've manually the lines and written the HH or LH or LL or HL labels. The level will have to wait until the next HA candle is a different level than prior, and then the line and text will appear after the candle is closed. If this is a bit complicated, please let me know and we can ignore this.

chart preview:

Thanks.
 
Last edited:
Solution
Using Heiken Aishi candles on the chart, I'm trying to just draw a small line at the highs and lows, with a chart bubble showing what it is. something like this image that I've manually the lines and written the HH or LH or LL or HL labels. The level will have to wait until the next HA candle is a different level than prior, and then the line and text will appear after the candle is closed. If this is a bit complicated, please let me know and we can ignore this.

chart preview:

Thanks.

Here is one way you could do this:

Screenshot-2022-12-15-144623.png
Ruby:
def HAclose  = ohlc4;
def HAopen   = CompoundValue( 1, ( HAopen[1] + HAclose[1] ) / 2, HAclose );
def HAhigh   = Max( high, Max( HAopen, HAclose ) );
def HAlow    = Min( low...
Using Heiken Aishi candles on the chart, I'm trying to just draw a small line at the highs and lows, with a chart bubble showing what it is. something like this image that I've manually the lines and written the HH or LH or LL or HL labels. The level will have to wait until the next HA candle is a different level than prior, and then the line and text will appear after the candle is closed. If this is a bit complicated, please let me know and we can ignore this.

chart preview:

Thanks.

Here is one way you could do this:

Screenshot-2022-12-15-144623.png
Ruby:
def HAclose  = ohlc4;
def HAopen   = CompoundValue( 1, ( HAopen[1] + HAclose[1] ) / 2, HAclose );
def HAhigh   = Max( high, Max( HAopen, HAclose ) );
def HAlow    = Min( low, Min( HAopen, HAclose ) );

def H   = if Barnumber() == 1
          then HAhigh
          else if HAhigh > H[1]
          then HAhigh
          else if HAhigh < H[1]
          then HAhigh
          else H[1];
plot HH = if H[1] < H and H > H[-1]
          then H
          else Double.NaN;
HH.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
def H0   = if !IsNaN(HH) != !IsNaN(HH[1])
           then HAhigh
           else h0[1];
def H1   = if h0[1] != h0
           then h0[1]
           else h1[1];
AddChartBubble(
isnan(HH[1]) and HH,
HAhigh,
if HH > h1[1] then "HH" else "LH",
if HH > h1[1] then Color.LIGHT_GREEN else Color.LIGHT_RED);

def L   = if Barnumber() == 1
          then HAlow
          else if HAlow < L[1]
          then HAlow
          else if HAlow > L[1]
          then HAlow
          else L[1];
plot LL = if L[1] > L and L < L[-1]
          then L
          else Double.NaN;
LL.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
def L0  = if !IsNaN(LL) != !IsNaN(LL[1])
          then HAlow
          else L0[1];
def L1  = if L0[1] != L0
          then L0[1]
          else L1[1];
AddChartBubble(
isnan(LL[1]) and LL,
HAlow,
if LL > L1[1] then "HL" else "LL",
if LL > L1[1] then Color.LIGHT_GREEN else Color.LIGHT_RED, no);
 
Solution

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

Hi @SleepyZ , thanks again, it looks great. After adding it, few things I realize I missed thinking it out. What I find is it creates a lot of noise with the small peaks and lows within the same trend - please see image attached, with some comments. The main issues are in the 2 white boxes, I've added notes. Would there be a way to say use highs and lows of the last 5 or 7 candles, that way we eliminate noise when the candles are still the same color in Heiken Ashi, this is from the /ES chart M1 timeframe in this evening

 
Last edited:
Hi @SleepyZ , thanks again, it looks great. After adding it, few things I realize I missed thinking it out. What I find is it creates a lot of noise with the small peaks and lows within the same trend - please see image attached, with some comments. The main issues are in the 2 white boxes, I've added notes. Would there be a way to say use highs and lows of the last 5 or 7 candles, that way we eliminate noise when the candles are still the same color in Heiken Ashi, this is from the /ES chart M1 timeframe in this evening

I only did this to show you an example of one way of how it is done, especially the bubble code. There are various swing and zigzag studies that identify highs/lows (peaks/valleys) that just need the bubbles included in the code that you showed you wanted.

As you did not indicate any rules, I just chose to use the normal pivot definition (ex: high> high[1] and high < high[-1], which does not use equal values you indicated that were missed.

I suggest you find some code on the site that identifies highs/lows in a way that you like with minimal noise and ask someone to modify it if needed and add bubbles similar to what I made for you.
 
I only did this to show you an example of one way of how it is done, especially the bubble code. There are various swing and zigzag studies that identify highs/lows (peaks/valleys) that just need the bubbles included in the code that you showed you wanted.

As you did not indicate any rules, I just chose to use the normal pivot definition (ex: high> high[1] and high < high[-1], which does not use equal values you indicated that were missed.

I suggest you find some code on the site that identifies highs/lows in a way that you like with minimal noise and ask someone to modify it if needed and add bubbles similar to what I made for you.
Will do, I will try to do it per your guidelines. thank you
 
Using Heiken Aishi candles on the chart, I'm trying to just draw a small line at the highs and lows, with a chart bubble showing what it is. something like this image that I've manually the lines and written the HH or LH or LL or HL labels. The level will have to wait until the next HA candle is a different level than prior, and then the line and text will appear after the candle is closed. If this is a bit complicated, please let me know and we can ignore this.

chart preview:

Thanks.
Can you help me understand the defintion of HH, HL , LL and LH used here
BTW - Thanks in advance
 
Last edited by a moderator:
Can you help me understand the defintion of HH, HL , LL and LH used here
BTW - Thanks in advance

These are comparisons of the current high/low to the previous high/low shown att the pivots used in the code.

HH = current High is Higher than the previous High
LH = current High is Lower than the previous High

HL = current Low is Higher than the previous Low
LL = current Low is Lower than the previous Low

These can be indicative of the trend direction.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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