Basic Trailing Stop 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:
- Basic Trailing Stop Expert Advisor For MT4
- The Basic Trailing Stop Expert Advisor for MT4 – Entry Criteria
- The Basic Trailing Stop Expert Advisor for MT4 – Exit Criteria
- The Basic Trailing Stop Expert Advisor for MT4 – Room for Improvement
The Basic Trailing Stop Expert Advisor For MT4 adjusts the stop loss of winning trades in the current symbol in a slightly different way. While other expert advisors activate this function to secure and maximize the profit of a trade entry, this robot takes action immediately the moment a trade has gained as little as one point.
When this happens, the robot moves the stop loss at the same distance as the price is away from the entry price. The downside to this strategy is that stop trailing is performed prematurely, and the scheme could work against the trader in terms of profitability.
The Basic Trailing Stop Expert Advisor for MT4 – Entry Criteria
The Basic Trailing Stop Expert Advisor is a basic trading system for the MetaTrader4 platform. The first time it is applied on a chart, the program makes some computations to convert the variables in Inputs from points to pips based on the price quotes received from the broker’s server. The robot also checks the number of bars if it is greater than 30 as well as the take profit target if it is greater than 10 points.
If any of the two checks above is negative, the robot will print an error in the terminal window. However, such action is not helpful because the user cannot see the notes without going to the Experts tab of the client terminal, and the errors are printed only once during initialization. The better way is to use alerts for this purpose. Alternatively, the robot can be removed from the chart immediately.
There are very few variables that the user can adjust in the expert settings, and they are self-explanatory. The user is free to make changes to the default settings to optimize the performance of the trading system according to his preference. The available parameters in Inputs are the following:
- stopLossPips = 20 – Every trade taken by this robot has a stop loss of 20 pips. This variable is not only used for setting the initial stop loss. It is also used in trailing the stop loss of a winning trade.
- lots = 0.1 – All trades executed by this robot have a lot size of 0.1.
- slippage = 5 – This is the maximum deviation in pips between requested price by the robot and fill price returned by the server.
- magicNumber = 1443192709 – The robot assigns this unique number to each trade to make way for trade management.
Two technical indicators define the entry rules for this trading system. To arrive at a valid signal, the set of indicators must give either a buy or sell signal, but not both buy and sell signals. If the indicators do not give any signal at all, no trade will be taken. How the indicators are used to provide a signal is explained below:
- Commodity channel index (period 14, close price) – The CCI is applied on the previous candle of the current timeframe and symbol. A sell signal will be generated if the CCI is greater than 100 and less than 250. A buy signal will be obtained if the CCI is greater than -100 and less than or equal to -150, which cannot be true.
- Relative strength index (period 14, close price) – The value of the RSI indicator is computed from the previous candle of the current timeframe and symbol. A buy signal will be generated if the RSI is below or equal to 30 (meaning oversold), and a sell signal will be obtained if the RSI is above 70 (meaning overbought).
While it is not specified in Inputs that the robot can only take a specific number of trades, the expert advisor only checks if there is an open trade on the current symbol or none. If there is none, the robot will look for a trade entry. If there is an open trade, the robot will check if it can adjust the stop loss. These conditions indirectly instruct the expert advisor to open one trade at a time on the current symbol.
The Basic Trailing Stop Expert Advisor for MT4 – Exit Criteria
On every tick, the Basic Trailing Stop Expert Advisor checks if there is a trade on the active chart. If this is the case, the robot will look further to determine the location of the stop loss relative to the market price. Unlike most other trading systems that require price to move a certain number of pips beyond the entry price before triggering the trail stop function, this trading system immediately starts trailing the stop loss of a selected order the moment the trade gains a point or more.
Stop trailing is performed in this manner. For a buy trade, if the bid price moves above the entry price for at least one point, the stop loss is moved by the same amount. The robot maintains a distance of 20 pips between the stop loss of the trade and the bid price. The same logic follows for a sell trade. With this style of trade management, it is possible to see trades closed in loss even if trailing stop has been activated.
The Basic Trailing Stop Expert Advisor for MT4 – Room for Improvement
The Basic Trailing Stop Expert Advisor for MT4 is a very simple expert advisor, judging by the amount of coding involved in the program. The robot failed to generate returns in testing. This is partly due to the low win rate and partly due to a code error resulting in execution of sell trades only. This is apparent in the Report tab in the strategy tester.
In the back testing, the expert advisor is run using five months of test data in one currency pair and one timeframe. A total of 145 trades was taken during back test, all of which were sell trades. Looking at the code, one can see that the error came from a statement that defines when the CCI indicator would give a bullish signal. A buy signal would never be generated due to this minor oversight. If this error is corrected, the expert advisor might give a different result for better or for worse. This task is left for the interested user to work on.
Putting the code error aside, the current win rate of the expert advisor is not favorable. Based on the back test result, the robot achieved a win rate of 33 percent. Had the risk-reward ratio been set in favor of reward, the trade result could have been breakeven or profitable. This is possible when the reward-risk ratio is at least 2. When the ratio is 2, a breakeven result is possible, and anything higher could mean a positive return.
Because of the trail stop function, the win rate so achieved does not hold much value. This is true even if the win rate happened to be higher than 50 percent. This is because the money gained when a trade is profitable could be relatively small compared to the money lost when a trade is a loser. That is why the reward-risk ratio should be given enough thought. A simple trading strategy based on sound trading principles is still capable of making money if the reward-risk ratio is favorable.
To turn the trading performance of this expert advisor around, shifting from trailing stop to static take profit is an area that can be explored. Setting a reward-risk ratio of at least 2 is recommended. This is the standard ratio mostly suggested by many traders. Higher ratios can be investigated in testing. This change involves code review though.