Heikin Ashi script

Hi Optuma, I’m currently investigating heikin ashi candles but can’t find any forum scripting comments incorporating these candles. I’m specifically looking at trialing the Optuma backtesting tool and would like a script which, among other criteria, will allow me to enter a trade when the first green(bullish) heikin ashi bar appears after at least three consecutive red(bearish) bars have occurred. Can anyone help please.


With it being based on Heikin-Ashi candles, it’s a bit tricky, but it can be done.

We have a Heikin-Ashi script function, so you need to be sure the other scripts are being wrapped around that. Here is an example using the bullish candle after 3 bearish candles in a row:

//Set Heikin-Ashi Candles
C1 = HAC() ;
//Find Open and Close values using HA Candles
V1 = MA(C1, CALC=Open, BARS=1);
V2 = MA(C1, CALC=Close, BARS=1);
//Find Bearish Candles
RES1 = V1 > V2;
//Find where 3 or more Bearish candles happen in a row
V3 = RES1 and RES2;
//Find Bullish Candle
V4 = V1 < V2;
//Find where 3 Bearish Candles are followed by a Bullish Candle

Here are the candles that match the criteria (grey shaded zone):


Keep in mind, you can’t apply this script to a Candlestick chart with Heikin Ashi candles already enabled, it would become a Heikin Ashi of a Heikin Ashi and the results wouldn’t match. This script has been written to work with the Back Tester.