MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal

Source code library - Expert Advisors, Indicators and Scripts

Copy experienced traders' deals with Trading Signals
To post a new code, please log in or register

Interesting script?
So post a link to it -
let others appraise it

You liked the script? Try it in the MetaTrader 5 terminal

2011.08.03 15:53

EMAplusWPR_V2 - expert for MetaTrader 4

| English Spanish Portuguese

votes: 3

Expert advisor that trade in the trend of EMA and buy/sell signals get from Williams %R

I have tried to create an Expert advisor that could by traded with 1000 EUR starting equity and to minimize the drawdown. Hope you like it. I appreciate every feedback.

Optimized for EURUSD 5 min

I have removed some bugs, removed position sizing, add some inputs.

You use it on your own risk. I am not responsible for your loss, you have to change, test and optimize it for your purpose.

have not optimized it

old versions:


extern string    separator1 = "------trend settings------";
extern bool      useEMAtrend = true;               // trade in EMA trend
extern int       barsInTrend = 1;                  // how many bars should be in trend
extern double    EMAtrend = 144;                   // EMA period for trend

extern string    separator2 = "------WPR settings------";
extern double    iWPRPeriod = 46;                  // WPR period for enter and exit
extern double    iWPRRetracement = 30;             // minimal retracement for WPR to allow another trade
extern bool      useWPRExit = true;                // use exit with WPR indicator

extern string    separator3 = "------position settings------";
extern double    lots = 0.1;                       // fixed lot size
extern int       maxTrades = 2;                    // max trades allowed for pyramiding
extern double    stop_loss = 50;                   // stop loss
extern double    take_profit = 200;                // take profit
extern bool      useTrailingStop = false;          // use trailing stop
extern double    trailing_stop = 10;               // trail stop loss
extern bool      useUnprofitExit = false;          // exit trade when trade was not in profit in defined amount of bars
extern int       maxUnprofitBars = 5;              // amount of bars not in profit

Last comments | Go to discussion (7)
MQL4 Comments
mql4_comments | 22 Oct 2011 at 20:41


SymbolEURUSDFXF (Euro vs US Dollar)
Period5 Minutes (M5) 2007.03.30 17:01 - 2011.09.30 00:59 (2007.01.01 - 2011.06.20)
ModelEvery tick (the most precise method based on all available least timeframes)
Parametersseparator1="------trend settings------"; useEMAtrend=true; barsInTrend=1; EMAtrend=144; separator2="------WPR settings------"; iWPRPeriod=46; iWPRRetracement=30; useWPRExit=true; separator3="------position settings------"; lots=0.1; maxTrades=2; stop_loss=50; take_profit=200; useTrailingStop=false; trailing_stop=10; useUnprofitExit=false; maxUnprofitBars=5; magicNumber=13131;
Bars in test335572Ticks modelled34632921Modelling quality99.00%
Mismatched charts errors0
Initial deposit10000.00
Total net profit3924.40Gross profit32367.40Gross loss-28443.00
Profit factor1.14Expected payoff1.64
Absolute drawdown376.60Maximal drawdown1261.60 (8.53%)Relative drawdown8.53% (1261.60)
Total trades2399Short positions (won %)1100 (65.45%)Long positions (won %)1299 (69.44%)
Profit trades (% of total)1622 (67.61%)Loss trades (% of total)777 (32.39%)
Largestprofit trade136.60loss trade-54.80
Averageprofit trade19.96loss trade-36.61
Maximumconsecutive wins (profit in money)30 (287.20)consecutive losses (loss in money)12 (-599.60)
Maximalconsecutive profit (count of wins)455.80 (18)consecutive loss (count of losses)-599.60 (12)
Averageconsecutive wins4consecutive losses2
MQL4 Comments
mql4_comments | 22 Oct 2011 at 20:45

indeed is profitable but needs optimization

MQL4 Comments
mql4_comments | 16 Feb 2012 at 14:17
Did you write this Code? I am trying to find someone that can write a similar EA for me. I have the concept but do not know how to write the code.
forex22 | 27 Jul 2012 at 19:02

i risultati esposti sono molto buoni.......h o scaricato, ma non riesco a farlo funzinare con i parametri default.......quancuno mi aiuta??'


broketrader | 26 Feb 2014 at 10:20

Not bad, at least it doesn't crash to zero like many others noted 10 on this site !

Congrats !