Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

Exp_Iin_MA_Signal_MMRec - MetaTrader 5 Expert - MT4/MT5 Resources

author EAcpu | 2 reads | 0 comments |

Exp_Iin_MA_Signal_MMRec - expert for MetaTrader 5

Exp_Iin_MA_Signal_MMRec - expert for MetaTrader 5

Add input EA variable block for managing the trading volume of the opened position:

 Enter the unit purchase total MMTriger= 5 ; // The quantity of the last buy transaction to calculate the stop loss
Input unit buying loss MMTriger= 3 ; // Reduce the number of loss buying transactions of MM
Input unit Sell total MMTriger= 5 ; // The quantity of the last sell transaction to calculate the stop loss
Input unit Sell loss MMTriger= 3 ; // Number of losing sell transactions to reduce MM
Enter double the small MM_= 0.01 ; // Margin share when a loss occurs in the transaction
Enter double MM= 0.1 ; // Share of margin in a trade during normal trading
Enter the margin mode MMMode=LOT; // Lot size determination method

In the case of such inputs, when choosing from the last 5 trades (3 of which were losses in a single direction), the EA opens the next trade in the same direction with a volume of 0.01 lots. If the last 5 losing trades are less than 3, the position will be 0.1.

This EA is an EA for the Exp_Iin_MA_ signal . The EA input block has been added to the code, and the opening/closing blocks have been changed:

 //---- Transaction execution
//---- Close the position through the magic number BuyPositionClose_M(BUY_Close, symbol (),Deviation_,BuyMagic); //----Close the position through the magic number SellPositionClose_M(SELL_Close, symbol (),Deviation_,SellMagic);

Double millimeters; //---- Open long position via magic number if (Buy_Open)
    {
      mm=BuyTradeMMRecounterS(BuyMagic,BuyTotalMMTriger,BuyLossMMTriger,SmallMM_,MM); //Define the number of long positions based on the results of previous trades BuyPositionOpen_M1(BUY_Open, symbol (),UpSignalTime,mm,MMMode,Deviation_,StopLoss_,TakeProfit_,BuyMagic);
    } //---- Open a long position via magic number if (sell_open)
    {
      mm=SellTradeMMRecounterS(SellMagic,SellTotalMMTriger,SellLossMMTriger,SmallMM_,MM); // Define the number of short positions based on the results of previous trades SellPositionOpen_M1(SELL_Open, symbol (),DnSignalTime,mm,MMMode,Deviation_,StopLoss_,TakeProfit_,SellMagic);
    }

In order for the generated EA to run correctly, the compiled Iin_MA_Signal.ex5 indicator file should be located in the <terminal data directory>\MQL5\indicator folder.

During testing the default Expert Advisor's input parameters without stop loss were used, as shown below.

Exp_Iin_MA_Signal_MMRec - expert for MetaTrader 5

Figure 1. Example of trade on chart

2017 GBP/JPY H1 test results:

Exp_Iin_MA_Signal_MMRec - expert for MetaTrader 5

Figure 2. Test result graph


Attachment download

📎 tradealgorithms.mqh (236.36 KB)

📎 iin_ma_signal.mq5 (16.36 KB)

📎 exp_iin_ma_signal_mmrec.mq5 (17.45 KB)

Source: MQL5 #21969

Verification code Refresh