Heikin-Ashi is a trend visualization technique based on Japanese candlestick charting. In-fact, Heikin-Ashi is also a type of candlestick, whose OHLC value differs from the traditional candlesticks. In Japanese, Heikin means “average” and “ashi” means “pace” . Taken together, Heikin-Ashi represents the average-pace of prices. Heikin-Ashi Candlesticks use the open-close data from the prior period and the open-high-low-close data from the current period to create a combo candlestick. In this post we would reveal a Heikin Ashi Trading System coded in Amibroker AFL. This system is optimized for NSE:Banknifty but should work well for other instruments too.
Analyzing price patterns in Heikin-Ashi charts is far more simpler and visually appealing as compared to traditional candlestick charts. See the below image:
Calculating Heikin-Ashi prices
As discussed above, OHLC value for Heikin-Ashi charts differs from the traditional candlestick charts. It is calculated using the below formula:
- HAClose = (Open+High+Low+Close)/4
o Average price of the current bar
- HAOpen = [HAOpen(Previous Bar) + HAClose(Previous Bar)]/2
o Midpoint of the previous bar
- HAHigh = Max(High, HAOpen, HAClose)
o Highest value in the set
- HALow = Min(Low, HAOpen, HAClose)
o Lowest value in the set
Heikin-Ashi Trading rules
Below are the 5 important rules (from Investopedia) which should be followed while trading with Heikin-Ashi technique:
- Green candles with no lower “shadows” indicate a strong uptrend: let your profits ride
- Green candles signify an uptrend: you might want to add to your long position, and exit short positions.
- One candle with a small body surrounded by upper and lower shadows indicates a trend change: risk-loving traders might buy or sell here, while others will wait for confirmation before going short or long.
- Red candles indicate a downtrend: you might want to add to your short position, and exit long positions.
- Red candles with no higher shadows identify a strong downtrend: stay short until there’s a change in trend.
In the next section, we’ll go through an AFL and backtest report for this Heikin Ashi Trading System. Please visit Trading Tuitions Academy to learn AFL coding and create your own Trading systems.
Heikin Ashi Trading System – AFL Overview
|Buy Condition||Formation of Heikin-Ashi green candle with Open=Low, and Close>40 period EMA of Close|
|Short Condition||Formation of Heikin-Ashi red candle with Open=High, and Close<40 period EMA of Close|
|Targets||No fixed target|
|Position Size||120 Quantities|
|Brokerage||50 per order|
Heikin Ashi Trading System – AFL Code
Click here to download the AFL code for this system.
Heikin Ashi Trading System – Backtest Report
|Fixed Position Size|
|Scrip Name||NSE Banknifty|
|Backtest Period||01-Mar-2000 to 09-Mar-2016|
|Net Profit %||763.25%|
|Annual Return %||13.94%|
|Number of Trades||276|
|Winning Trade %||25.36%|
|Average holding Period||11.88 periods|
|Max consecutive losses||18|
|Max system % drawdown||-75.62%|
|Max Trade % drawdown||-32.42%|
Additional Amibroker settings for backtesting
Goto Symbol–>Information, and specify the lot size and margin requirement. The below screenshot shows lot size of 40 and margin requirement of 10% for NSE Banknifty:
All the AFL’s posted in this section are for learning purpose. Trading Tuitions does not necessarily own these AFL’s and we don’t have any intellectual property rights on them. We might copy useful AFL’s from public forums and post it in this section in a presentable format. The intent is not to copy anybody’s work but to share knowledge. If you find any misleading or non-reproducible content then please inform us at email@example.com