Hello dear readers, Besso again here and today I have a big gift for you!
It's a complete working divergence trader, I'm including the full source code but even if you aren't into coding, EA has most of the inputs you'll need in order to optimize and set it the way you want.
There's another file (wte.mqh) which you should put in Experts\Classes folder, there is no Classes folder inside Experts folder, you'll need to create it first.
Here's the description of input parameters:
T I M I N G
monthsToTrade="1,2,3,4,5,6,7,8,9,10,11,12"; //Months To Trade ( 1 - 12 = January - February )
daysToTrade="1,2,3,4,5"; //Days To Trade ( 1 - 5 = Monday - Friday )
tradingHours="0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23"; //hours to trade
S T O P L O S S
stopLossMethod=sl_biggest; //it can be set to use fixed value below, can be set to employ signal candle's high/low price and can also be biggest or smallest among the first two, additionally you can further adjust it by adjustSL input
fixedStopLoss=200.0; //fixedStopLoss ( used only if selected as SL method )
adjustSL=80.0; //adjustSL ( increase (>0) or decrease (<0) SL by X points )
T A K E P R O F I T
takeProfitMethod=tp_multiple; //can be set to fixed value or to be X times the SL as well as biggest or smallest among the first two, can be further adjusted by adjustTP input
fixedTakeProfit=1000.0; //fixedTakeProfit ( used only if selected as TP method )
tpToSlRatio=10.0; //tpToSlRatio ( used only if takeProfitMethod = SL Multiple )
adjustTP=0.0; //adjustTP ( increase (>0) or decrease (<0) TP by X points )
R I S K M A N A G E M E N T
tradeRiskPercent=1.0; //tradeRiskPercent ( used if fixedLotSize = 0 )
fixedLotSize=0.01;
breakEven=0; //breakEven ( used if > 0 AND if > breakEvenLock )
breakEvenLock=20.0; //breakEvenLock ( points to secure after breakEven activation )
trailingStop= 300.0;//trailingStop ( used if > 0 )
trailWait=10.0; //trailWait ( defer TS trigger by X points )
O R D E R S
comment="de.comm";
magic=888100;
E N T R Y
entryType=entry_market; //Market Entry Type (via market orders, stop orders or limit orders). Stop and limit orders can be fine-tuned with inputs below.
pendingOrderDistance=100.0; //pendingOrderDistance ( used in Limit and Stop orders )
pendingOrderExprCandles=6; //pendingOrderExprCandles ( used in Limit and Stop orders ). This is basically for how much candles (after sending) pending orders should stay active.
signalCandleLevel=0.3; //this one is interesting and involves one or two last candles, takes full candle size (from high to low) and then checks what part of this size is "traced back" by candle's close price (own or the candle after it) for signal to be considered valid.
maxPositionsPerSide=3; //maxPositionsPerSide ( long or short )
minPattSize=3; //minimum candles in a pattern
maxPattSize=7; //maximum candles in a pattern
minPriceStrength=0.0; //minPriceStrength ( minimum: difference in points between two price levels divided by candle quantity ). Basically calculates an angle between the two price levels, never really used it.
minSignalStrength=8.0; //minSignalStrength ( min: raw difference between indicator values )
minPattDepth=5; //minimum pattern depth in points
tradeFullDivergence=true; //by full divergence I mean when price goes up and indicator goes down or vice versa. Inputs below cover cases where one of the two is flat / horizontal.
tradeEqualPriceDivergence = false; //tradeEqualPriceDivergence ( W or M chart pattern )
tradeEqualIndicDivergence = false; //tradeEqualIndicDivergence ( W or M indicator pattern )
indicatorName=Stochastic; //Indicator to use: you can choose between Stochastic, MACD, RSI and Momentum.
stochKPeriod = 9; //Stochastic K Period
stochDPeriod = 6; //Stochastic D Period
stochSlowing = 5; //Stochastic Slowing
stochPriceField=0; //Stochastic Price Field
stochMAMethod=MODE_SMA; //Stochastic MA Method
macdFastEMAPeriod = 12; //MACD Fast EMA Period
macdSlowEMAPeriod = 26; //MACD Slow EMA Period
macdSignalPeriod=9; //MACD Signal Period
rsiPeriod=14; //RSI Period
momentumPeriod=20; //Momentum Period
indicatorAppliedPrice=PRICE_CLOSE; //indicatorAppliedPrice ( for MACD, RSI and Momentum )
indicatorMode=index_main; //indicator mode, MODE_MAIN or MODE_SIGNAL ( for MACD and Stochastic )
overPricedArea=20.0; //indicator overpriced area ( for Stochastic and RSI ). For example if value is 20, oversold will be below 20 and overbought will be above 80 in Stochastic and RSI.
signalLocation=location_all; //signal location filter ( for Stochastic and RSI ). You can choose between any location, only overbought/oversold or only neutral.
I finished setting it up on EURUSD and started optimisations on USDJPY and GBPUSD but as I'm doing these testing with TDS software (real variable spreads + commissions and ticks) it will probably take a lot of time
to add all (at least major) pairs and timeframes. In case you have the software and are going to do your own tests, it will be amazing if you share your results and set files with us.
I believe this way we can all save time and energy and get better results faster.
EURUSD H1 FIXED 0.01 LOTSIZE (REAL SPREADS) 2010-2017
EURUSD H1 1% RISK PER TRADE (REAL SPREADS) 2010-2017
EURUSD M15 FIXED 0.01 LOTSIZE (REAL SPREADS) 2010-2017
EURUSD M15 1% RISK PER TRADE (REAL SPREADS) 2010-2017
I'm including the SET files which you can use, but please keep in mind that what you see underwent a lot of work and optimization,
as well as timing filters, while trading results do not deteriorate right away outside the optimization period (2010-2017) it's still not clear
yet how stable these settings are and on which pairs it works best.
SET files have timing filters which are created for GMT +2 brokers. Easy way to adjust it is to disable timing filters (set them to trade all months, days and hours) and to load backtests in Quant Analyzer software.
You'll see directly which part of the day is more profitable and which part is noisier. Then you can simply set trading hours and days on your own based on acquired info.
I personally wouldn't put it on a live account without having enough data. Probably we have somewhere like 10% of it (enough data) right now.
The software is distributed "as is" without any promises.
Thanks for reading!
Besso
Other Posts For Further Reading:
Evaluating Urban Towers Strategy (Source Code): https://www.mql5.com/en/blogs/post/687314
Metaeditor Dark Theme: https://www.mql5.com/en/blogs/post/687043
Traders' Dynamic Index EA (Source Code): https://www.mql5.com/en/blogs/post/686791