Well. I finished coding.
It is my version attached.
I checked everything in visual mode of Metatrader during the backtesting attaching indicators and compare the trading with indicators crossing with different settings.
It works well.
Explanation of the settings:
Code:
MagicNumber = 112340;
It is magic number. It should be different for different pairs
(each pair should have its own magic number (anyone but not the same with others)
If we want to trade fixed lot size (always by o.1 lot or always by 1 lot size without MM) so change MaximumRisk to zero (0).
Slippage.
Code:
StopLossMode = False;
StopLoss = 100;
if StopLossMode = False so EA will close the order on the 8 EMA/21 EMA crossing (by default setting). If StopLossMode = True so EA will close the orders according to stop loss
AND 8 EMA/21 EMA crossing.
Code:
TakeProfitMode = False;
TakeProfit = 100;
if TakeProfitMode = False so EA will close the order on the 8 EMA/21 EMA crossing (by default setting). If TakeProfitMode = True so EA will close the orders according to take profit value
AND 8 EMA/21 EMA crossing.
Code:
TrailingStopMode = False;
TrailingStop = 30;
if TrailingStopMode = False so EA will close the order on the 8 EMA/21 EMA crossing (by default setting). If TrailingStopMode = True so EA will close the orders according to trailing stop value
AND 8 EMA/21 EMA crossing.
Please note that trailing stop is working even if stop loss/take profit options are "false". It means: if TrailingStopMode = True but TakeProfitMode = False and StopLossMode = False so EA will use trailing stop even in this case.
All those functions are working separatedly from each other (TrailingStopMode, TakeProfitMode, StopLossMode).
Code:
PARAMETERS_MM = "MONEY MANAGEMENT";
MaximumRisk =0.15;
DecreaseFactor =3;
if MaximumRisk=0 so EA will use fixed lot size (lot size will always be exact equal "Lots"). If you are using MM function so it is necessary to set MaximumRisk value according to your deposit size (for EA to start open the order in "right" lot size). Try to backtest with different MaximumRisk value just for 5 minutes and you will understand what i mean. It is MM which Igorad is using in his EAs (i just took this code from him).
Code:
PARAMETERS_INDICATOR_ONE = "Moving Average signal";
SignalEMA_Period = 8;
Usually we ae looking for this EMA with this period for crossing with main EMA for buy or sell.
Code:
PARAMETERS_INDICATOR_TWO = "Moving Average main";
MainEMA_Period = 55;
Delta=0;
And it is main EMA.
If Delta is above zero so it means that 8 EMA should cross (55 EMA + Delta) for buy. and 8 EMA is crossing (55 EMA minus Delta for sell). Delta is acting as a filter. I still don't not whether we need it or not. It is very easy to understand when we attach indicators to the chart:
8 EMA closed price, 55 EMA closed price and with "Levels" = Delta and minus Delta (see my image from previous posts).
Code:
PARAMETERS_INDICATOR_THREE = "Moving Average for close";
CloseEMA_Period = 21;
It is EMA to close all the orders. When signal EMA is crossing this close EMA so the order will be closed.
If somebody finds some bug so don't ask. Just please fix it and post improved versions.
Tomorrow I will try to backtest this EA and EA by anazri.