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:
Heikin-Ashi Chart |
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.
Heikin Ashi Trading System – AFL Overview
Parameter | Value |
Preferred Time-frame | Daily |
Indicators Used | EMA |
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 |
Sell Condition |
|
Cover Condition |
|
Stop Loss | 1% |
Targets | No fixed target |
Position Size | 120 Quantities |
Initial Equity | 200000 |
Brokerage | 50 per order |
Margin | 10% |
Heikin Ashi Trading System – AFL Code
//------------------------------------------------------ // // Formula Name: Heikin Ashi Trading System // Author/Uploader: BrokeyForAmiBroker // E-mail: brokeyforamibroker@gmail.com // Website: brokeyforamibroker.blogspot.in //------------------------------------------------------ _SECTION_BEGIN("Heikin Ashi Trading System"); SetOption( "InitialEquity", 200000); SetTradeDelays( 1, 1, 1, 1 ); SetOption("FuturesMode" ,True); SetOption("MinShares",1); SetOption("CommissionMode",2); SetOption("CommissionAmount",50); SetOption("AccountMargin",10); SetOption("RefreshWhenCompleted",True); SetPositionSize(120,spsShares); SetOption( "AllowPositionShrinking", True ); BuyPrice=Open; SellPrice=Open; ShortPrice=Open; CoverPrice=Open; SetChartOptions(0,chartShowArrows|chartShowDates); _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C )); HaClose = (O + H + L + C)/4; HaOpen = AMA( Ref( HaClose, -1 ), 0.5 ); HaHigh = Max( H, Max( HaClose, HaOpen ) ); HaLow = Min( L, Min( HaClose, HaOpen ) ); barcolor = IIf(HaClose >= HaOpen,colorGreen,colorRed); PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "", barcolor, styleCandle ); printf("\nHaOpen : " + HaOpen ); printf("\nHaHigh : " + HaHigh ); printf("\nHaLow : " + HaLow ); printf("\nHaClose : " + HaClose ); Candles=param("Candles",1,1,5,1); periods=param("periods",40,10,200,10); Buy = Sum(HaClose >= HaOpen,Candles)==Candles AND HaOpen==HaLow AND C>EMA(C,periods); Short= Sum(HaClose <= HaOpen,Candles)==Candles AND HaOpen=HaHigh AND C<EMA(C,periods); Sell=Short OR C<EMA(C,periods); Cover=Buy OR C>EMA(C,periods); Buy = ExRem(Buy,Sell); Sell = ExRem(Sell,Buy); Short=ExRem(Short,Cover); Cover=ExRem(Cover,Short); printf("\nBuy : " + Buy ); printf("\nSell : " + Sell ); printf("\nShort : " + Short ); printf("\nCover : " + Cover ); Stoploss=param("SL",1,1,5,1); ApplyStop(Type=0,Mode=1,Amount=StopLoss); /* Plot Buy and Sell Signal Arrows */ PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40); PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50); PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45); PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40); PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50); PlotShapes(IIf(Cover, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45); PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40); PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50); PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45); PlotShapes(IIf(Short, shapeSquare, shapeNone),colorRed, 0, H, Offset=40); PlotShapes(IIf(Short, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50); PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45); _SECTION_END();
AFL Screenshot
Heikin Ashi Trading System – Backtest Report
Paramter | Value |
Fixed Position Size | |
Initial Capital | 200000 |
Final Capital | 1726506.44 |
Scrip Name | NSE Banknifty |
Backtest Period | 01-Mar-2000 to 09-Mar-2016 |
Timeframe | Daily |
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% |
Clearly, drawdown is on a higher side. It could be overcome with proper Risk Management strategies.
Equity Curve
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:
Disclaimer:
All the AFL’s posted in this section are for learning purpose. BrokeyForAmiBroker 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 brokeyforamibroker@gmail.com
heiken ashi trading system for amibroker (afl)
heiken ashi trading system pdf
heiken ashi trading system for amibroker
heikin ashi trading system amibroker
heikin ashi fibonacci trading system
heiken ashi smoothed trading system
heiken ashi forex trading system
heiken ashi stock trading system
modified heikin ashi fibonacci trading system
heiken ashi trading system afl
trading system con heikin ashi
the modified heikin ashi fibonacci trading system download
the modified heikin ashi fibonacci trading system ebook
the modified heikin ashi fibonacci trading system pdf
the modified heikin ashi fibonacci trading system
No comments:
Post a Comment