Heikin Ashi

NateB9916

New member
Is there any way to make heikin ashi charts consider after hours data without it being displayed? I hate that there are a string of long candles when there is a large gap overnight.
 
Solution
To consider the after hour data, it must be on the chart. However, there is a workaround to hide the after hours bars by using the addchart function. Add the code below to hide the price plot and substitute the addchart workaround.

The image shows the workaround in the upper chart without after hours data and the lower chart with the workaround, which shows after hours.

Sorry, the above solution did not work as it made the after hours data unusable by hiding the price plot.

So you can try this instead. First go to chart settings and Uncheck Highlight Extended-Hours
Capture.jpg


Then add the following code which will hide the after hours bars
Ruby:
def rth = between(gettime(), regularTradingStart(getyyyYMMDD())...
To consider the after hour data, it must be on the chart. However, there is a workaround to hide the after hours bars by using the addchart function. Add the code below to hide the price plot and substitute the addchart workaround.

The image shows the workaround in the upper chart without after hours data and the lower chart with the workaround, which shows after hours.

Sorry, the above solution did not work as it made the after hours data unusable by hiding the price plot.

So you can try this instead. First go to chart settings and Uncheck Highlight Extended-Hours
Capture.jpg


Then add the following code which will hide the after hours bars
Ruby:
def rth = between(gettime(), regularTradingStart(getyyyYMMDD()),
                             regularTradingEnd(getyyyYMMDD()));
AssignPriceColor(if !rth then Color.BLACK else Color.CURRENT);

Capture.jpg
 
Solution
Sorry, the above solution did not work as it made the after hours data unusable by hiding the price plot.

So you can try this instead. First go to chart settings and Uncheck Highlight Extended-Hours
Do you know of anyway to cutout the void that leaves behind? I feel like it will mess up my keltner bands that don't need the after-hours data. Thanks for all your help!
 
No, but if you use the solution in post #3, then it should not affect your indicators. See images without and with bars showing in after hours.
That looks like the indicator is using the afterhours data though, I need mine not to use it. It seems the easiest solution would be to somehow change the heikin ashi to where it uses the first normal candle of the day to initialize the trend, avoiding a large gap. Just don't know if that's possible.
 
That looks like the indicator is using the afterhours data though, I need mine not to use it. It seems the easiest solution would be to somehow change the heikin ashi to where it uses the first normal candle of the day to initialize the trend, avoiding a large gap. Just don't know if that's possible.

Your first post indicated that you "to consider after hours data" and your subsequent post indicated that you "don't need after hours data." Please explain what you need the after hours data to do and how you currently are able to have after hours data, but not for the Keltner Channel indicator, all on one chart with after hours data.

If you do not need after hours data at all, then just refer to post #3 above and uncheck "Show Extended-hours" above the cyan colored circled check box.
 
Sorry, I should have put photo's in my original post to help explain what I meant. All I'm trying to do is get rid of the long candles on heikin-ashi when a stock gaps up or down.

cn5e8i3.png


BqxUCSw.png
 
Sorry, I should have put photo's in my original post to help explain what I meant. All I'm trying to do is get rid of the long candles on heikin-ashi when a stock gaps up or down.

cn5e8i3.png


BqxUCSw.png

Thank you, now I see what you wanted. The following seems to work. It assigns a black price color to the heiken ashi 0930 bar and replaces it with a hybred heiken ashi bar, which appears to expose the gaps in my testing. It does not appear to affect the Keltner Channel as seen in the image below.

Capture.jpg
Ruby:
input charttype=chartType.CANDLE;
def o = open;
def h = high;
def l = low;
def c = close;
def HAclose = (o+h+l+c)/4;
def HAopen  = CompoundValue(1, (HAopen[1] + HAclose[1]) / 2, (o[1] + c[1]) / 2);
def haopen_ = if haopen>haclose
              then HAopen + 0
              else double.nan;
def HAhigh  = if haopen_>=haclose
              then Max(Max(h, HAopen_), HAclose)
              else double.nan;
def HAlow   = if haopen>=haclose
              then Min(Min(l, HAopen_), HAclose)
              else double.nan;
def bar = secondsfromTime(0930) == 0;

def o1 = if bar and haopen<haclose then l else double.nan;
def c1 = if bar and haopen<haclose then o else double.nan;
def h1 = if bar and haopen<haclose then h else double.nan;
def l1 = if bar and haopen<haclose then l else double.nan;

AddChart(growColor = color.green, fallColor = color.red, neutralColor = color.gray, high = h1, low = l1, open = c1, close = o1, type = chartType);

def o2 = if bar and haopen >=haclose then h else double.nan;
def h2 = if bar and haopen >=haclose then h else double.nan;
def l2 = if bar and haopen >=haclose then halow else double.nan;
def c2 = if bar and haopen >=haclose then haclose else double.nan;
AddChart(growColor = color.red, fallColor = color.green, neutralColor = color.gray, high = h2, low = l2, open = o2, close = c2, type = chartType);


assignpriceColor(if bar then color.black else color.current);
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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