>>>MT4/MT5 Expert Advisors<<<
Heiken Ashi Naïve
Heiken Ashi Naïve is a MetaTrader expert advisor based on Heiken Ashi charting system through the platform's standard indicator by the same name. The employed trading system is naive in a way that it interprets only two latest Heiken Ashi candles and does not apply any complex pattern analysis. The only trick is that the expert advisor trades against the supposed trend direction, confirmed by current Heiken Ashi setup. Its biggest advantage is that it has no input parameters to optimize and curve-fit to the past data. Optional ATR-based position sizing is available for improved money management. There are two versions of the EA: a plain one and one with Z-Score optimization applied. The expert advisor (with and without Z-Score optimization) is available for both MT4 and MT5 versions of the platform.
Heiken Ashi:
Heiken Ashi (or Heikin Ashi, from Japanese 平均足) is an alternative technique of representing the usual candlestick charts for the purpose of trading. Unlike with traditional Japanese candles, it is impossible to read the actual price levels (Open, High, Low and Close) on Heiken Ashi chart, but it is easier to spot trend developments and reversals. Rising Heiken Ashi candles are usually plotted as white ones, and the falling — as red ones. Similarly to the standard candles, Heiken Ashi show wicks. Neither direction of a candle, nor the length of its wicks point to actual price levels, but rather should be considered in relation to other Heiken Ashi candles in the close proximity.
The switch of colors means a change of trend: red to white — a bearish trend reversal, white to red — a bullish trend reversal. Increasing candle body length signals strengthening of trend. Decreasing — signals weakening. Lower wicks on white candles and upper wicks on red candles signal volatility and trend instability. Lack of such wicks indicates a definite and clear trend.
Introduction:
Heiken Ashi Naïve is a MetaTrader expert advisor based on Heiken Ashi charting system through the platform's standard indicator by the same name. The employed trading system is naive in a way that it interprets only two latest Heiken Ashi candles and does not apply any complex pattern analysis. The only trick is that the expert advisor trades against the supposed trend direction, confirmed by current Heiken Ashi setup. Its biggest advantage is that it has no input parameters to optimize and curve-fit to the past data. Optional ATR-based position sizing is available for improved money management. There are two versions of the EA: a plain one and one with Z-Score optimization applied. The expert advisor (with and without Z-Score optimization) is available for both MT4 and MT5 versions of the platform.
Heiken Ashi:
Heiken Ashi (or Heikin Ashi, from Japanese 平均足) is an alternative technique of representing the usual candlestick charts for the purpose of trading. Unlike with traditional Japanese candles, it is impossible to read the actual price levels (Open, High, Low and Close) on Heiken Ashi chart, but it is easier to spot trend developments and reversals. Rising Heiken Ashi candles are usually plotted as white ones, and the falling — as red ones. Similarly to the standard candles, Heiken Ashi show wicks. Neither direction of a candle, nor the length of its wicks point to actual price levels, but rather should be considered in relation to other Heiken Ashi candles in the close proximity.
The switch of colors means a change of trend: red to white — a bearish trend reversal, white to red — a bullish trend reversal. Increasing candle body length signals strengthening of trend. Decreasing — signals weakening. Lower wicks on white candles and upper wicks on red candles signal volatility and trend instability. Lack of such wicks indicates a definite and clear trend.
Calculation Rules:
The following rules are used to calculate Heiken Ashi candle levels:
The following rules are used to calculate Heiken Ashi candle levels:
- HA_Open = (previous HA_Open + previous HA_Close) / 2
- HA_Low = minimum(Low, HA_Open, HA_Close)
- HA_High = maximum(High, HA_Open, HA_Close)
- HA_Close = (Open + High + Low + Close) / 4
Where:
- HA_Open, HA_High, HA_Low and HA_Close — Heiken Ashi candle levels.
- Open, High, Low and Close — normal candle levels.
- The levels of the initial HA candle are equal to respective levels of the original candle.
Heiken Ashi Chart:
The chart that you see below demonstrates the Heiken Ashi candle technique, showing both trending and ranging periods. The initial uptrend (white) becomes weak with Heiken Ashi doji and turns red for four candles. Only one candle (second) in this downtrend qualifies for a strong bearish trend according to Heiken Ashi rules outlined above. The renewed bullish trend shows a period of weakness (short-bodied candles with downside wicks) but then returns to its strength. A small red correction goes rather deep and is signaled as such by the long-bodied candles without upper wicks. Without a clear reversal signal, a new upward trend ensues. It was followed by a plateau with a chaos of red/white colors, which ended in a long downward trend. A small correction consisting of five white with one red candle in a middle did not stop the whole trend going south till the end of the chart.
The chart that you see below demonstrates the Heiken Ashi candle technique, showing both trending and ranging periods. The initial uptrend (white) becomes weak with Heiken Ashi doji and turns red for four candles. Only one candle (second) in this downtrend qualifies for a strong bearish trend according to Heiken Ashi rules outlined above. The renewed bullish trend shows a period of weakness (short-bodied candles with downside wicks) but then returns to its strength. A small red correction goes rather deep and is signaled as such by the long-bodied candles without upper wicks. Without a clear reversal signal, a new upward trend ensues. It was followed by a plateau with a chaos of red/white colors, which ended in a long downward trend. A small correction consisting of five white with one red candle in a middle did not stop the whole trend going south till the end of the chart.
Naturally, such an indicator looks rather promising to traders who wish to trade on trends and their reversals.
Trading Strategy:
Heiken Ashi Naïve expert advisor uses a rather simple, yet not very obvious method to trade with Heiken Ashi candles.
The following entry signals are used:
If there exists an open position in an opposite direction when a signal arrives, the position is closed. If the existing position is in the same direction as the signal, the latter is ignored.
The following exit signals are used to close trades before a new entry signal arrives:
As you can see, the expert advisor uses the inverted logic in its trading strategy. It goes long when the Heiken Ashi system points at a rather strong bearish trend, and it goes short when it is a bullish rally according to Heiken Ashi. The trick here is that it tries to catch reversals as early as possible.
Heiken Ashi Naïve expert advisor uses a rather simple, yet not very obvious method to trade with Heiken Ashi candles.
The following entry signals are used:
- Sell if the latest completed HA candle is bullish, its body is longer than previous candle's body, previous candle is also bullish, and latest candle has no lower wick.
- Buy if the latest completed HA candle is bearish, its body is longer than previous candle's body, previous candle is also bearish, and latest candle has no upper wick.
If there exists an open position in an opposite direction when a signal arrives, the position is closed. If the existing position is in the same direction as the signal, the latter is ignored.
The following exit signals are used to close trades before a new entry signal arrives:
- Exit short position if the latest completed HA candle is bearish, previous candle is also bearish, and the latest candle has no upper wick.
- Exit long position if the latest completed HA candle is bullish, previous candle is also bullish, and the latest candle has no lower wick.
As you can see, the expert advisor uses the inverted logic in its trading strategy. It goes long when the Heiken Ashi system points at a rather strong bearish trend, and it goes short when it is a bullish rally according to Heiken Ashi. The trick here is that it tries to catch reversals as early as possible.
Trade Examples:
The chart screenshot from the strategy backtest on EUR/JPY is shown below. There are six completed trades:
The chart screenshot from the strategy backtest on EUR/JPY is shown below. There are six completed trades:
- The first position is bearish (shown with a red arrow) and lasts for 8 candles until the new position is entered following bullish entry signal generation.
- The second position is bullish (shown with a blue arrow) and is a big loser. The downtrend signaled by Heiken Ashi turns out to be a lasting one, so the advisor's system fails here.
- The third position is a short-term bearish one (second red arrow). It lasts only 3 days and is quite profitable.
- The fourth position is a short-term bullish one (second blue arrow) and is even more profitable.
- The fifth position is another short-term sell (third red arrow). It is the most profitable trade of the six shown in these examples.
- The sixth position is long (third blue arrow). It is very profitable and last for long enough to live through several white candles, which fail to trigger exit conditions for the bullish trade.
Position Sizing:
Heiken Ashi Naïve expert advisor uses the same advanced position sizing system as the Ichimoku Chinkou Cross expert advisor. It is capable of both fixed position size and ATR-based fixed fractional position size.
Heiken Ashi Naïve expert advisor uses the same advanced position sizing system as the Ichimoku Chinkou Cross expert advisor. It is capable of both fixed position size and ATR-based fixed fractional position size.
Z-Score Optimization:
The second version of this expert advisor has Z-Score optimization implemented in its algorithm. Z-Score optimization is based on the intrinsic parameter of some Forex strategies. Basically, Z-Score value tells us if there is any correlation between the trade outcomes of the given strategy. Large positive Z-score (like the one of Heiken Ashi Naïve on EUR/JPY @ D1) means that the winning trade is likely to be followed by a losing one, and that the losing trade will probably be followed by a winning one. Large negative Z-score would mean that winning trades are often followed by more winning trades, while losing trades frequently follow the same losing trades. Obviously, such metric can be used to optimize a trading strategy or an expert advisor.
Heiken Ashi Naïve with Z-score optimization stops trading following a profitable trade. It then switches to a virtual trading mode, where it calculates the trades, but does not actually send any orders to MetaTrader sever. Once a losing virtual trade is encountered, the EA switches back to real trading mode and continues normal operation. This expert advisor is also capable of saving and loading all the virtual trading data from file, preventing Z-score optimization malfunction due to software or hardware failures.
The second version of this expert advisor has Z-Score optimization implemented in its algorithm. Z-Score optimization is based on the intrinsic parameter of some Forex strategies. Basically, Z-Score value tells us if there is any correlation between the trade outcomes of the given strategy. Large positive Z-score (like the one of Heiken Ashi Naïve on EUR/JPY @ D1) means that the winning trade is likely to be followed by a losing one, and that the losing trade will probably be followed by a winning one. Large negative Z-score would mean that winning trades are often followed by more winning trades, while losing trades frequently follow the same losing trades. Obviously, such metric can be used to optimize a trading strategy or an expert advisor.
Heiken Ashi Naïve with Z-score optimization stops trading following a profitable trade. It then switches to a virtual trading mode, where it calculates the trades, but does not actually send any orders to MetaTrader sever. Once a losing virtual trade is encountered, the EA switches back to real trading mode and continues normal operation. This expert advisor is also capable of saving and loading all the virtual trading data from file, preventing Z-score optimization malfunction due to software or hardware failures.
Backtest Results:
The backtest of the Heiken Ashi Naïve expert advisor was performed on the period from 1 January, 2001 through 6 December, 2013 (almost 13 years) on the EUR/JPY D1 chart.
When fixed position volume of 0.1 standard lot has been used, the resulting net profit was $11,112 on $10,000 starting account balance with the maximum relative drawdown of 15.8%.
With ATR-based position sizing enabled (ATR period = 20; ATR multiplier = 1; 2% risk tolerance), the resulting net profit increased to $29,903 on the same $10,000 starting account balance, while the maximum relative drawdown increased to 39%.
The backtest of the Heiken Ashi Naïve expert advisor was performed on the period from 1 January, 2001 through 6 December, 2013 (almost 13 years) on the EUR/JPY D1 chart.
When fixed position volume of 0.1 standard lot has been used, the resulting net profit was $11,112 on $10,000 starting account balance with the maximum relative drawdown of 15.8%.
With ATR-based position sizing enabled (ATR period = 20; ATR multiplier = 1; 2% risk tolerance), the resulting net profit increased to $29,903 on the same $10,000 starting account balance, while the maximum relative drawdown increased to 39%.
Backtesting Z-Score Optimized EA:
Z-Score optimized version of Heiken Ashi Naïve expert advisor was backtested on the same data as the original version. The performance resulted in $8,119 profit and 9.11% relative drawdown for a fixed position size (0.1 standard lot). When using ATR-based position sizing, the EA has shown $15,002 with 20.9% drawdown.
As you can see, there is little point in using a Z-Score optimized version of this expert advisor unless you really need to obtain a lower drawdown value. Z-Score version makes only 109 trades compared to 349 trades of the original version. Another advantage of Z-Score version is the expected payoff of $74.49 vs. $31.84 per trade and the doubled Sharp ratio (0.31 vs. 0.14).
Z-Score optimized version of Heiken Ashi Naïve expert advisor was backtested on the same data as the original version. The performance resulted in $8,119 profit and 9.11% relative drawdown for a fixed position size (0.1 standard lot). When using ATR-based position sizing, the EA has shown $15,002 with 20.9% drawdown.
As you can see, there is little point in using a Z-Score optimized version of this expert advisor unless you really need to obtain a lower drawdown value. Z-Score version makes only 109 trades compared to 349 trades of the original version. Another advantage of Z-Score version is the expected payoff of $74.49 vs. $31.84 per trade and the doubled Sharp ratio (0.31 vs. 0.14).
Input ParameterS:
Money Management
Money Management
- Lots (default = 0.1) — basic lot size for fixed position sizing. Used when MM = false.
- MM (default = false) — if true, ATR-based position sizing is enabled.
- ATR_Period (default = 20) — the period of the ATR indicator, which is used for position size calculation. Works only if MM = true.
- ATR_Multiplier (default = 1) — a value, by which the ATR indicator value will be multiplied. Works only if MM = true.
- Risk (default = 2) — risk tolerance in percentage of account balance/equity. Works only if MM = true. This input parameter is ignored if UseMoneyInsteadOfPercentage is set to true.
- FixedBalance (default = 0) — if set to non-zero value, it is used instead of account balance/equity for position size calculation. Works only if MM = true.
- MoneyRisk (default = 0) — risk tolerance in account currency. Works only if MM = true. Requires UseMoneyInsteadOfPercentage to be set to true.
- UseMoneyInsteadOfPercentage (default = false) — if true, position size is calculated based on risk amount given in account currency (MoneyRisk) instead of balance/equity percentage risk (Risk). Works only if MM = true.
- UseEquityInsteadOfBalance (default = false) — if true, position size is calculated based on account equity instead of balance. Works only if MM = true. Ignored if UseMoneyInsteadOfPercentage = true.
- LotDigits (default = 2) — number of decimal places allowed by your broker in order volume. For example, if your broker allows micro lots (0.01), then this parameter should be set to 2. If your broker allows only mini lots (0.1) this parameter should be set to 1. Required only if MM = true.
MiscellaneouS:
- OrderComment (default = "HAN") — the commentary for positions opened by this EA.
- Slippage (default = 100) — the acceptable price slippage in pips.
- Magic (default = 152207122013) — the order magic number to filter positions opened by this EA. Used only in MT4.
- Mute (default = false) — if true, EA will produce no output regarding virtual trading events. This input parameter is present only in Z-Score optimized version.
- FileName (default = "HAN_vt.dat") — the name of the file used by the EA to store virtual trading data. This input parameter is present only in Z-Score optimized version.
Discussion:
Warning! Before you ask basic questions regarding installation of the expert advisors, please, read this MT4 Expert Advisors Tutorial to get the elementary knowledge on handling them.
Use this "EA" at your own risk. SONY Net Business can't be responsible for any losses associated with using any "EA" presented on the site. It's not recommended to use this "EA" on the real account without testing it on demo first.
Warning! Before you ask basic questions regarding installation of the expert advisors, please, read this MT4 Expert Advisors Tutorial to get the elementary knowledge on handling them.
Use this "EA" at your own risk. SONY Net Business can't be responsible for any losses associated with using any "EA" presented on the site. It's not recommended to use this "EA" on the real account without testing it on demo first.
---------------------------------------------------------
Metatrader Expert Advisors — User’s Tutorial
Using Metatrader expert advisors
is simple, but sometimes people get confused with it and after
downloading a file with the expert advisor a user might get stuck with
it without knowing what to do next. This a simple tutorial on how
to attach an expert advisor to Metatrader 4 char and activate it.
1. Download your MT4 expert advisor or copy it and save it to your MetaTrader’s ‘experts’ folder:
2. Double click it with your mouse and it will be opened in MQL
editor (this editor comes with MT4). There will be a button ‘Compile’
at the center top of the window. Click it and your expert advisor will
be compiled and ready to use. There might be some errors or warnings
during the compilation, but in most cases there shouldn’t be any. You
can try and fix those errors, but it takes time and some programming
skills, usually.
3. Now, all you need to do is add your expert advisor
to the preferred chart and activate it. You can also change some input
parameters for the advisor in the Inputs tab:
That’s it! Now you can enjoy your expert advisor — its signals or its
trading (if it is designed to perform trading). Good luck with them!
1. Download your MT4 expert advisor or copy it and save it to your MetaTrader’s ‘experts’ folder:
-----------------------------------------------------------------------
Risk Warning:
Forex and CFD trading carry a high degree of risk. As such they may not be suitable for all investors. Investors should ensure they fully understand the risks associated with CFD trading before deciding to trade. Investors may choose to seek independent advice and should not risk more than they are prepared to lose.
Forex and CFD trading carry a high degree of risk. As such they may not be suitable for all investors. Investors should ensure they fully understand the risks associated with CFD trading before deciding to trade. Investors may choose to seek independent advice and should not risk more than they are prepared to lose.