Current Version: http://codebase.mql4.com/en/code/10413
Are you a trader looking to enhance your strategy? Let me introduce you to EMAplusWPRv1_1, an Expert Advisor (EA) designed for MetaTrader 4. This EA utilizes the Exponential Moving Average (EMA) trend along with buy/sell signals derived from Williams %R.
I aimed to create an EA that works effectively with a starting equity of €1,000 while minimizing drawdown. Your feedback is always welcome!
Optimized for EURUSD on a 5-minute chart
I've ironed out some bugs and tweaked the position sizing. You can now set how much of your account you wish to risk with each trade. Plus, I've included a simple trailing stop feature that you can disable by setting trailingStop to 0.
Disclaimer: Use this EA at your own risk. I’m not liable for any losses you may incur. Be sure to adjust, test, and optimize it to suit your trading needs.
Inputs:
extern double takeProfit = 200; // Take Profit extern double maxStopLoss = 50; // Stop Loss extern double maxLots = 10; // Max lots per position extern double maxContracts = 2; // Max open positions, 2 is optimal for smoother equity extern double EMA = 144; // EMA to determine trend extern int iWPRPeriod = 46; // Williams' %R for buy/sell signals int iWPRretracement = 30; // Retracement for next trade extern double trailingStop = 50; // Trailing stop, set to 0 to disable extern int risk = 2; // % of account risk per trade extern double magicNumber = 13131;
Strategy Tester Report
| Symbol | EURUSD (Euro vs US Dollar) | ||||
| Period | 5 Minutes (M5) 2010.01.04 00:00 - 2011.02.01 23:55 | ||||
| Model | Every tick (most accurate method) | ||||
| Parameters | takeProfit=200; maxStopLoss=50; maxLots=0.1; maxContracts=2; EMA=144; iWPRPeriod=46; trailingStop=50; risk=6; magicNumber=13131; | ||||
| Bars in test | 59025 | Ticks modelled | 7365767 | Modelling quality | n/a |
| Mismatched charts errors | 8220 | ||||
| Initial deposit | €1,000.00 | ||||
| Total net profit | €1,635.88 | Gross profit | €4,478.56 | Gross loss | -€2,842.67 |
| Profit factor | 1.58 | Expected payoff | €3.92 | ||
| Absolute drawdown | €22.16 | Maximal drawdown | €249.69 (10.77%) | Relative drawdown | 12.99% (188.82) |
| Total trades | 417 | Short positions (won %) | 198 (67.68%) | Long positions (won %) | 219 (73.52%) |
| Profit trades (% of total) | 295 (70.74%) | Loss trades (% of total) | 122 (29.26%) | ||
| Largest | profit trade | €67.23 | loss trade | -€39.62 | |
| Average | profit trade | €15.18 | loss trade | -€23.30 | |
| Maximum | consecutive wins (profit in money) | 20 (€273.93) | consecutive losses (loss in money) | 6 (-€142.17) | |
| Maximal | consecutive profit (count of wins) | €326.42 (15) | consecutive loss (count of losses) | -€142.17 (6) | |
| Average | consecutive wins | 4 | consecutive losses | 2 | |

For optimal position sizing, adjust the maxLots and determine what percentage of your account you'd like to risk on each trade.
Here's the position sizing code I use:
minAllowedLot = MarketInfo(Symbol(), MODE_MINLOT); // IBFX= 0.10 lotStep = MarketInfo(Symbol(), MODE_LOTSTEP); // IBFX= 0.01 maxAllowedLot = MarketInfo(Symbol(), MODE_MAXLOT); // IBFX=50.00 balance = AccountBalance(); ilo = ((balance * risk / 100) / maxStopLoss); lots = NormalizeDouble(ilo, 0) * lotStep; if (lots < minAllowedLot) lots = minAllowedLot; if (lots > maxLots) lots = maxLots; if (lots > maxAllowedLot) lots = maxAllowedLot;
Strategy Tester Report
| Symbol | EURUSD (Euro vs US Dollar) | ||||
| Period | 5 Minutes (M5) 2010.01.04 00:00 - 2011.02.01 23:55 | ||||
| Model | Every tick (the most precise method) | ||||
| Parameters | takeProfit=200; maxStopLoss=50; maxLots=10; maxContracts=2; EMA=144; iWPRPeriod=46; trailingStop=50; risk=6; magicNumber=13131; | ||||
| Bars in test | 59025 | Ticks modelled | 7365767 | Modelling quality | n/a |
| Mismatched charts errors | 8220 | ||||
| Initial deposit | €1,000.00 | ||||
| Total net profit | €4,655.80 | Gross profit | €13,740.16 | Gross loss | -€9,084.36 |
| Profit factor | 1.51 | Expected payoff | €11.16 | ||
| Absolute drawdown | €22.16 | Maximal drawdown | €1,139.43 (28.08%) | Relative drawdown | 28.08% (€1,139.43) |
| Total trades | 417 | Short positions (won %) | 198 (67.68%) | Long positions (won %) | 219 (73.52%) |
| Profit trades (% of total) | 295 (70.74%) | Loss trades (% of total) | 122 (29.26%) | ||
| Largest | profit trade | €268.93 | loss trade | -€256.75 | |
| Average | profit trade | €46.58 | loss trade | -€74.46 | |
| Maximum | consecutive wins (profit in money) | 20 (€353.21) | consecutive losses (loss in money) | 6 (-€354.36) | |
| Maximal | consecutive profit (count of wins) | €1,466.13 (15) | consecutive loss (count of losses) | -€664.91 (4) | |
| Average | consecutive wins | 4 | consecutive losses | 2 | |

Comments 0