Watch how to download trading robots for free

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

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

Experts

EMAplusWPRv1_1 - expert for MetaTrader 4

Matus German | English Español Português 日本語 Deutsch

Views:
10385
Rating:
votes: 3
Published:
2011.03.30 07:24
Updated:
2014.07.01 13:56

ACTUAL VERSION : http://codebase.mql4.com/en/code/10413

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, changed position sizing, you define the % of your account you want to risk on a single trade. I added simple trailing stop, if trailingStop = 0, then it is disabled.

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.

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 identify trend
extern int    iWPRPeriod      = 46;       // Williams' Percentage Range to determine buy/sell signals
       int    iWPRretracement = 30;       // retracement of Williams' Percentage to allow next trade
extern double trailingStop    = 50;       // trailing stop, use 0 to disable trailing stop
extern int    risk            = 2;        // % of account you want to risk on a 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 (2010.01.04 - 2011.02.02)
ModelEvery tick (the most precise method based on all available least timeframes)
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 deposit1000.00
Total net profit1635.88Gross profit4478.56Gross loss-2842.67
Profit factor1.58Expected payoff3.92
Absolute drawdown22.16Maximal drawdown249.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 trade67.23loss trade-39.62
Averageprofit trade15.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

To use my position sizing increase the maxLots size and define the risk - how many % of your account you want to risk on a single trade.

For position sizing I use the following code:

   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 + 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 (2010.01.04 - 2011.02.02)
ModelEvery tick (the most precise method based on all available least timeframes)
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 deposit1000.00
Total net profit4655.80Gross profit13740.16Gross loss-9084.36
Profit factor1.51Expected payoff11.16
Absolute drawdown22.16Maximal drawdown1139.43 (28.08%)Relative drawdown28.08% (1139.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 trade268.93loss trade-256.75
Averageprofit trade46.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)1466.13 (15)consecutive loss (count of losses)-664.91 (4)
Averageconsecutive wins4consecutive losses2

ZMFX Forex Trend v3 ZMFX Forex Trend v3

Trend of 8 pairs on one chart

Regression Analysis Regression Analysis

This indicator compares four types of regression (linear, quadratic, logarithmic and exponential) and chooses the one that best fits the data analyzed.

MTrainer Strategy Tester MTrainer Strategy Tester

Backtest your ideas in ST with simple order initiation. 100% visual, no typing, just drop a horizontal line on the chart to order! Focus on your indicators and trade with ease. Has SL and TP lines as well as PC line for partial close. Externals: BSRa

Place OCO Order, One pip Limit Order and One Pip Stop Order Place OCO Order, One pip Limit Order and One Pip Stop Order

Places OCO Order, One pip Limit Order and One Pip Stop Order on Metatrader 4 platform.