Heikin Ashi "Just Assume Seven" Strategy



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.

#Author @dublin_capital
#Version History 202005301044ds

#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;

plot barsDown = if barNumberShort > 0 then barNumberShort else Double.NaN;

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);


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


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


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.