EA Template with Trailing Stop v2 Expert Advisor For MT4
WE IMPROVED THIS EXPERT ADVISOR FOR YOU!!!
PLEASE NOTE: This expert advisor was publicly available for free usage on other websites and is not programmed by us. We explain the functionality and possible improvements of the EA. Furthermore, we are convinced that fully automatic Expert Advisors will fail in the long run. On the other hand, our semi-automatic approach with detecting the best setups and then activating our Expert Advisors (e.g. V-Power EA, EdgeZone EA) produced many successful traders and some of them even got prop traders at prop trading firms. Therefore, we added a similar semi-automatic trading feature (to allow only buy or only sell trades) to the free Expert Advisors. You can download the modified version here and enjoy!
Table Of Contents:
- EA Template with Trailing Stop v2 Expert Advisor For MT4
- The EA Template with Trailing Stop v2 Expert Advisor For MT4 – Entry Criteria
- The EA Template with Trailing Stop v2 Expert Advisor For MT4 – Exit Criteria
- The EA Template with Trailing Stop v2 Expert Advisor For MT4 – Room for Improvement
The EA Template with Trailing Stop v2 Expert Advisor For MT4 uses the average directional movement index (ADX) as trigger for trade entry and exit. As such, this trading system can be considered a trend-following strategy since the ADX is widely known as an indicator of trend strength. To trade with the trend, the expert advisor utilizes buy stop and sell stop orders. By default, it opens one trade at a time. When a stop order has been converted into a market order and starts gaining pips, trailing stop comes into play whenever a threshold set in Inputs is achieved.
Unfortunately, the trading system failed to make money in testing when applied to one symbol and 15-minute chart and using five months of historical data. While the winning percentage was high (around 42 percent), the robot lost money anyway. This is possibly due to the use of trailing stop that disrupts the balance between risk and reward, rendering the high win rate inadequate.
The EA Template with Trailing Stop v2 Expert Advisor For MT4 – Entry Criteria
The EA Template with Trailing Stop v2 Expert Advisor performs only two functions on every tick, that is, trade entry and trade management. If there is no open order yet of any type in the current symbol, the robot attempts to find a signal and execute the trade. If there is already an order, the robot will either modify the stop loss or close the trade.
There are some parameters that the user can adjust in Inputs. With these parameters, the user can control some aspects of trading this expert advisor. While some variables are self-explanatory, other variables must be explained to avoid misconception. These variables are outlined below:
- Lot = 0.1 – All trades will have the same lot size of 0.1 because automatic lot sizing is disabled by default.
- AutoLots = False – This parameter means that automatic lot sizing will not be used and static lot sizing will be used instead.
- TakeProfit = 1000 – The take profit of trades is 1,000 points (or 100 pips).
- StopLoss = 500 – The stop loss of trades is 500 points (or 50 pips).
- TrailingStart = 200 – Stop trailing will begin if a trade has gained 200 points (or 20 pips).
- TrailingStop = 150 – When trailing begins, the stop loss is placed 150 points (or 15 pips) beyond the entry price, securing 15 pips of profit in the process.
- Slippage = 3 – This is the maximum amount of price movement from request to execution that the robot allows for each trade in case a trade request experiences latency in response.
- MaxOrders = 1 – This parameter instructs the expert advisor to open only one trade at a time, be it a pending or market order.
- Magic = 777 – Each trade initiated by this trading system is given this magic number for use in trade management.
- Pips = 100 – This variable refers to the distance of the pending order from the market price in points.
- Mins = 30 – The pending order placed by the robot will expire in 30 minutes if not converted into a market order.
- PERIOD = 15 – This is the timeframe of the current symbol where the ADX is applied. The value means 15 minutes.
- adxint = 14 – This is the period of the ADX indicator used in this trading system.
- adxsignal = 20 – A signal from the ADX will be used as filter if the ADX value is greater than 5.
- MaxSpread = 20 – This is the maximum spread in points in the current symbol that is allowed for trade entry. If the spread is greater than this value, a trade signal will be passed over.
The trading system uses one technical indicator to find a trade opportunity and define its direction. How this indicator is used to generate the trade entry is explained below:
- Average directional movement index (period 14, price close) – The ADX values needed for calculation are derived from the candle zero and candle two of the 15-minute period of the current symbol. A buy signal will be generated if the ADX value of candle zero is greater than 20, +DI is above -DI for candle zero, and +DI is below -DI for candle two. On the other hand, a sell signal is obtained if the ADX of candle zero is greater than 20, +DI is below -DI for candle zero, and +DI is above -DI for candle two.
The expert advisor considers a trade entry if the number of open orders is less than maximum. Since the MaxOrders variable is set to 1 by default, the robot will execute one order at a time. Moreover, the current spread in the active symbol should be less than maximum (i.e., 20 points). If these two conditions exist, the robot will place an order based on the signal provided by the ADX.
The trading system puts either a buy stop or sell stop order, but not both. The distance of the stop order is 100 points from the market price. If the pending order is not triggered after 30 minutes, the terminal will delete the order. After this point, the robot can find another signal and place another stop order. If the stop order is triggered in time, the stop order will become a market order. No stop order can be placed while the trade is open.
All orders placed by the robot have a stop loss and take profit. The stop loss is set at 50 pips from the entry price, while the take profit is set at 100 pips from the open price, putting the risk-reward ratio to two in the beginning. This balance between risk and reward is disturbed, though, due to the use of stop trailing.
The EA Template with Trailing Stop v2 Expert Advisor For MT4 – Exit Criteria
As observed in testing, most trades opened by the EA Template with Trailing Stop v2 Expert Advisor are closed by the initial stop loss or directly by the robot. The expert advisor checks on every tick if an open trade can be closed or not. The trigger for trade closure comes from the ADX as discussed below:
- Average directional movement index (period 14, price close) – The expert advisor determines the +DI and -DI values of the current candle for the 15-minute chart of the current symbol. If the current order is long and +DI is below -DI, the buy trade will be closed. If the current order is short and +DI is above -DI, the sell trade will be closed.
This means that the current market order will be closed by an opposite signal from the ADX. Trade closure will be done immediately if triggered, and the robot does not wait for a trade to turn green or profitable. Trades are forcibly closed this way by the robot in loss or in profit.
The EA Template with Trailing Stop v2 Expert Advisor For MT4 – Room for Improvement
The EA Template with Trailing Stop v2 Expert Advisor failed to generate profits when tested over five months of historical price data. As already mentioned, the possible reason for this could be the balance between risk-reward ratio and win rate. While the win rate was high, it was possible that the account lost more money in losing trades than it gained money in winning trades. However, there is no specific variable in Inputs that the user can toggle on and off if he wants to use trailing stop or not. If possible, this option should be given to the trader.