Two independent trading systems using Skyscraper_Fix and ColorAML indicators within a single EA with an ability to change the volume of a forthcoming trade depending on the results of the previous trades for this trading system. Trading signals are formed when a bar closes if a trend has changed (which is displayed by any of the two indicators changing its color).
The blocks of input EA variables are added for managing volumes of opened positions. For example, for a system applying the Skyscraper_Fix indicator:
input uint A_BuyLossMMTriger=2; //A number of losing Buy deals to reduce MM input uint A_SellLossMMTriger=2; //A number of losing Sell deals to reduce MM input double A_SmallMM=0.01; //A share of a deposit in a deal in case of loss input double A_MM=0.1; //A share of a deposit in a deal during normal trading
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.
The similar inputs are also available for the trading system using ColorAML:
input uint B_BuyLossMMTriger=2; //B number of losing Buy deals to reduce MM input uint B_SellLossMMTriger=2; //B number of losing Sell deals to reduce MM input double B_SmallMM=0.01; //B share of a deposit in a deal in case of loss input double B_MM=0.1; //B share of a deposit in a deal
For the generated EA to operate correctly, the compiled files of the Skyscraper_Fix.ex5 and ColorAML.ex5 indicators should be present in the <terminal_data_directory>\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 trades on the chart
Test results for GBPJPY H4 over the year 2016:
Fig. 2. Test results chart
Translated from Russian by MetaQuotes Software Corp.
Original code: https://www.mql5.com/ru/code/22372