Optimize Your Trading with EMAplusWPRv1_1 for MetaTrader 4

Mike 2011.03.30 16:24 23 0 0
Attachments

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

EMAplusWPRv1_1
XTrade-MT4 Demo (Build 229)

SymbolEURUSD (Euro vs US Dollar)
Period5 Minutes (M5) 2010.01.04 00:00 - 2011.02.01 23:55
ModelEvery tick (most accurate method)
ParameterstakeProfit=200; maxStopLoss=50; maxLots=0.1; maxContracts=2; EMA=144; iWPRPeriod=46; trailingStop=50; risk=6; magicNumber=13131;
Bars in test59025Ticks modelled7365767Modelling qualityn/a
Mismatched charts errors8220
Initial deposit€1,000.00
Total net profit€1,635.88Gross profit€4,478.56Gross loss-€2,842.67
Profit factor1.58Expected payoff€3.92
Absolute drawdown€22.16Maximal drawdown€249.69 (10.77%)Relative drawdown12.99% (188.82)
Total trades417Short 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%)
Largestprofit trade€67.23loss trade-€39.62
Averageprofit trade€15.18loss trade-€23.30
Maximumconsecutive wins (profit in money)20 (€273.93)consecutive losses (loss in money)6 (-€142.17)
Maximalconsecutive profit (count of wins)€326.42 (15)consecutive loss (count of losses)-€142.17 (6)
Averageconsecutive wins4consecutive losses2

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

EMAplusWPRv1_1 with Position Sizing
XTrade-MT4 Demo (Build 229)

SymbolEURUSD (Euro vs US Dollar)
Period5 Minutes (M5) 2010.01.04 00:00 - 2011.02.01 23:55
ModelEvery tick (the most precise method)
ParameterstakeProfit=200; maxStopLoss=50; maxLots=10; maxContracts=2; EMA=144; iWPRPeriod=46; trailingStop=50; risk=6; magicNumber=13131;
Bars in test59025Ticks modelled7365767Modelling qualityn/a
Mismatched charts errors8220
Initial deposit€1,000.00
Total net profit€4,655.80Gross profit€13,740.16Gross loss-€9,084.36
Profit factor1.51Expected payoff€11.16
Absolute drawdown€22.16Maximal drawdown€1,139.43 (28.08%)Relative drawdown28.08% (€1,139.43)
Total trades417Short 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%)
Largestprofit trade€268.93loss trade-€256.75
Averageprofit trade€46.58loss trade-€74.46
Maximumconsecutive wins (profit in money)20 (€353.21)consecutive losses (loss in money)6 (-€354.36)
Maximalconsecutive profit (count of wins)€1,466.13 (15)consecutive loss (count of losses)-€664.91 (4)
Averageconsecutive wins4consecutive losses2

 

List
Comments 0