Heiken Ashi conditional order at close of bar?

whirl

New member
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
@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
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
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

Top