A trading system using the Ang_Zad_C trend-following indicator with the possibility to set a strict trading time interval and change the volume of a forthcoming trade depending on the results of the previous trades.
A trade decision is made when the indicator cloud changes its color.
It is possible to specify trading time in input parameters to trade in the specified time interval:
input bool TimeTrade=true; //Permission to trade by time interval input HOURS StartH=ENUM_HOUR_0; //Trading start (hours) input MINUTS StartM=ENUM_MINUT_0; //Trading start (minutes) input HOURS EndH=ENUM_HOUR_23; //Trading end (hours) input MINUTS EndM=ENUM_MINUT_59; //Trading end (minutes)
Two variables for hours and minutes are provided for each of trading start and trading end times.
Default settings enable the Expert Advisor to trade the whole trading session from 0:00, while all positions are closed at 23:59.
If the start time in the EA’s settings is later than the specified trading end time, the EA will close the opened positions at the specified time next day.
The block of input EA variables is added for managing volumes of opened positions:
input uint    BuyLossMMTriger=2;  //number of loss-making Buy trades to decrease MM input uint    SellLossMMTriger=2; //number of loss-making Sell trades to decrease MM input double  Small_MM=0.01;      //Share of financial resources from the deposit used in a trade in case of losses input double  MM=0.1;            //Share of financial resources from the deposit used in a trade in case of normal trading input MarginMode MMMode=LOT;      //lot size calculation method
In case of such inputs and if the last two trades in one direction were loss-making, the EA opens the next trade in the same direction having the volume of 0.01 lot. If at least one of the two last trades is not loss-making, the position volume is 0.1.
This Expert Advisor requires the compiled indicator file Ang_Zad.ex5 in order to run. Place it in <terminal_data_folder>\MQL5\Indicators.
Default Expert Advisor’s input parameters have been used during tests shown below. Stop Loss and Take Profit have not been used during the tests.
Fig. 1. Examples of deals on the chart. Trading only in the time intervals set in the inputs is disabled
Testing results for 2017 at EURUSD H12:
Fig. 2. Test results chart
Fig. 3. Examples of deals on the chart. Trading only in the time intervals set in the inputs is enabled