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