Heiken Ashi conditional order at close of bar?

whirl

New member
VIP
Hey guys. Just seeing if this is possible. Is there a way to exit a position when the close of Heiken Ashi candle changes color on a 5 minute bar?
Ideally I'd like to close a position at the end of the trend when the candle closes red after a series of green bars for example. Is something like that possible? I have no real scripting skills. Thank you
 

whirl

New member
VIP
@RickAns Thank you for that, nice interesting read. Yes, some additional rules would be needed but interesting to base on, always nice to hear near ideas.

Right now, I have a scan for when Heiken-Ashi candles change color in a TOS watchlist. But when trying to create a conditional order, I don't know how to create a script to exit a position when the color changes at the end of the bar.
 

whirl

New member
VIP
If nobody here knows how to code this exit, would anyone by chance point me in the right direction of someplace that could do it for me? Thanks in advance.
 

whirl

New member
VIP
Is there a website that has programmers for hire? I'm guessing this should be a quick fix. I know TOS has some of the studies built in, but not sure how to tell it to exit when the colors change. Thank you
 

dvorakm

New member
2019 Donor
VIP
If nobody here knows how to code this exit, would anyone by chance point me in the right direction of someplace that could do it for me? Thanks in advance.
Did you ever figure this out? I am also trying to create a conditional order based on Heiken but it fails. You can create a chart study and it alerts (works), but fails when trying to add to conditional order.
 

rad14733

Well-known member
VIP
@dvorakm In order to exit a trade based on Heikin Ashi you need to define the Heikin Ashi prices within the Conditional Order script... That is the only way the code knows the Heikin Ashi values... Close in Heikin Ashi is actually (Open + High + Low + Close) / 4, or ohlc4... And close is the same as last until the candle closes... The following code is what I use in all of my Heikin Ashi scripts for...

Ruby:
def haClose = ohlc4;
def haOpen = (haOpen[1] + haClose[1]) / 2;
def haHigh = max(high, max(ha_close, ha_high));
def haLow = min(low, min(ha_open, ha_close));
 

dvorakm

New member
2019 Donor
VIP
@dvorakm In order to exit a trade based on Heikin Ashi you need to define the Heikin Ashi prices within the Conditional Order script... That is the only way the code knows the Heikin Ashi values... Close in Heikin Ashi is actually (Open + High + Low + Close) / 4, or ohlc4... And close is the same as last until the candle closes... The following code is what I use in all of my Heikin Ashi scripts for...

Ruby:
def haClose = ohlc4;
def haOpen = (haOpen[1] + haClose[1]) / 2;
def haHigh = max(high, max(ha_close, ha_high));
def haLow = min(low, min(ha_open, ha_close));
thank you very much!

def haClose = ohlc4;
def haOpen = (haOpen[1] + haClose[1]) / 2;
def ha_high = max(high, max(haclose, ha_high));
def ha_low = min(low, min(haopen, haclose));
def haColor = haClose > haOpen;
def trendUp = haColor and haColor[1] and !haColor[2];
def trendDown = !haColor and !haColor[1] and haColor[2];
plot signal = trendDown;

I believe this would be correct to trigger a conditional order if there is currently a red Heikin Ashi, a red Heikin Ashi before that with a green Heikin Ashi before that. However, I can not get it to take in the conditional order config. It throws a invalid statement: def at 6:1, where it shows the code was deprecated. No matter how many times I paste it in there, it deprecates.
 

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.
Top