Heikin Ashi "Just Assume Seven" Strategy

Dublin_Capital

Dublin_Capital

Member
Inspired by this post on twitter, here is the "Just Assume Seven" strategy.

The author assumes that when the color changes on a Heikin Ashi 30 minute chart, you can assume that there will be at least seven bars in that direction. He is obviously not claiming that this is any kind of guarantee, but feel that it is common enough to base a strategy on. I am not familiar with his exit or trade management strategies, so I coded up something simple, using these rules:

1. Enter a Long position when the heikin ashi chart changes to green
2. Hold the long position until either:
a) the heikin ashi turns red, or
b) the current bar closes lower than the previous bar, and there have been at least seven bars in the same direction.

The rules are reversed for short entries. The user can vary the number of bars to hold the trade and watch for a lower close.



Here are the results of a 180 day backtest of the strategy. Obviously the strategy isn't tradeable as it is currently written, but I thought it might provide a framework that could be the basis of something more profitable.








Code:
#HeikinAshi_Assume_Seven
#Author @dublin_capital
#Version History 202005301044ds
#2020-05-30

#based on a 2020-05-30 tweet from @RealBrianWatt, suggesting that you can assume 7 candles on a 30 minute Heikin Ashi chart

input barStop = 7;

def heikinAshiClose = (open + high + low + close) / 4;

rec heikinAshiOpen = CompoundValue(1, (heikinAshiOpen[1] + heikinAshiClose[1]) / 2, (open[1] + close[1]) / 2);

def difference = heikinAshiClose - heikinAshiOpen;

def longSignal = difference > 0 and difference[1] <= 0;
def shortSignal = difference < 0 and difference[1] >= 0;


def barNumberLong = CompoundValue(1, if difference > 0 then barNumberLong[1] + 1 else 0, 0);
def barNumberShort = CompoundValue(1, if difference < 0 then barNumberShort[1] + 1 else 0, 0);

plot barsUp = if barNumberLong > 0 then barNumberLong else Double.NaN;
barsUp.SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
barsUp.SetDefaultColor(Color.DARK_GREEN);

plot barsDown = if barNumberShort > 0 then barNumberShort else Double.NaN;
barsDown.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
barsDown.SetDefaultColor(Color.DARK_RED);

AddOrder(OrderType.BUY_AUTO, longSignal, tickcolor = Color.DARK_GREEN, arrowcolor = Color.DARK_GREEN, name = "LONG");
AddOrder(OrderType.SELL_TO_CLOSE, barNumberLong > barStop - 1 and close < close[1], tickcolor = Color.DARK_GREEN, arrowcolor = Color.DARK_GREEN, name = "CLOSE");

AddOrder(OrderType.SELL_AUTO, shortSignal, tickcolor = Color.DARK_RED, arrowcolor = Color.DARK_RED, name = "SHORT");
AddOrder(OrderType.BUY_TO_CLOSE, barNumberShort > barStop - 1 and close > close[1], tickcolor = Color.DARK_RED, arrowcolor = Color.DARK_RED, name = "CLOSE");


AddLabel(yes, if difference > 0 then "Consecutive Bars Up: " + barsUp else if difference < 0 then "Consecutive Bars Down: " + barsDown else "0", if difference > 0 then color.DARK_GREEN else if difference < 0 then color.DARK_RED else color.GRAY);
 
D

diazlaz

Well-known member
2019 Donor
VIP
@Dublin_Capital nice spreadsheet - would love to collab with you to work on it/enhance it. if you're interested pls let me know.
 
T

tradebyday

Active member
What the data shows is that this works on the S&P,NASDAQ (probably Russell and Dow as well), and of course VIX since it works as an inverse to the previous mentions in a way.But of course nothing else, which would be for many reasons, mainly is that the other assets are too volatile and oscillate in value greatly throughout the day, especially oil, currencies and bonds. The second step to this analysis is to take the net positives and expand their analysis back several years to test viability for them alone. Probably test in 3-5 year groupings as the market conditions vary greatly over x years depending on when you backtest, and odds are conditions will change again in the next couple years. So testing many years back in small groupings could show you what conditions lead to this strategies viability
 
Dublin_Capital

Dublin_Capital

Member
I originally posted this strategy as a response to a tweet that suggested that this was a viable strategy (since deleted). I had hoped to prove them correct and automate things for them, but it just isn't tradeable based on the rules that they shared. Even if profitable, I don't trade any strategies that have a commission % "in the red". Too fragile, and will eventually break down.

I still thought I would share the code - maybe it will help someone solve a different problem or provide something to build on.

@tradebyday did a great job explaining an approach that might help someone turn a bad strategy into something worthwhile. Great advice.
 
C

C4men

Member
I originally posted this strategy as a response to a tweet that suggested that this was a viable strategy (since deleted). I had hoped to prove them correct and automate things for them, but it just isn't tradeable based on the rules that they shared. Even if profitable, I don't trade any strategies that have a commission % "in the red". Too fragile, and will eventually break down.

I still thought I would share the code - maybe it will help someone solve a different problem or provide something to build on.

@tradebyday did a great job explaining an approach that might help someone turn a bad strategy into something worthwhile. Great advice.

Just a quick question for something related I am working on.

In your code above, which parts define the following?
  • Heiken Ashi OPEN
  • Heiken Ashi CLOSE
I like to look at regular candles during the day, but would like to have a label on my Intraday chart that tells me what is happening on a Heiken Ashi without having to switchover and look at it.

Any help greatly appreciated.
 
B

Bald Slacker

New member
VIP
so... on the P/L spread sheet, it shows a loss of $200,000. And this is a good strategy how?
 
surferdude

surferdude

New member
VIP
This is just one of many pattern trading strategies. I haven't done much research, let alone any backtesting, on any of these, but identifying patterns that could work (or has worked) for certain securities may be totally flawed for others. Just like we wouldn't use seasonal strategies for wheat/corn/ags with gold and forex. If the ES shows consistent profitability with this as opposed to the metals/currencies/energy then maybe someone might want to do additional research on this strategy exclusively for the indexes. Maybe they'll also find that it works great on the SPY in addition to the ES...or maybe not so great. But I will say that I can't see this working with the smaller time frames.
 

Similar threads

Top