Order Size to fix

 

Hello,

Below is the money management part of my expert.

The calculation based on the "percent of equity" still returns a volume at 0.01.

Where is the bug ?

Thanking you in davance for your help !


double MoneyManagement()

{

   double lot = 0;  

   double Free =AccountInfoDouble(ACCOUNT_EQUITY);

   double LotVal =SymbolInfoDouble(Symbol(),SYMBOL_TRADE_TICK_VALUE);

   double Min_Lot =SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MIN);

   double Max_Lot =SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MAX);

   double Step =SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_STEP);

   double leverage = (double)AccountInfoInteger(ACCOUNT_LEVERAGE);

   double ticksize = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_SIZE);



   if(MM_type == fixed_lot)lot=FixedLotSize;



   if(MM_type == percent_risk_of_equity)      

   {

      lot =MathFloor((Free*MM_percent/100)/(StopLoss*LotVal)/Step)*Step;

      if(lot<Min_Lot) lot=Min_Lot;

      if(lot>Max_Lot) lot=Max_Lot;

   }  

   

   if(MM_type == percent_of_equity)

   {

      lot = NormalizeDouble(Free * MM_percent * 0.01  / leverage  /  (LotVal  /  ticksize), 2);

      if(lot<Min_Lot) lot=Min_Lot;

      if(lot>Max_Lot) lot=Max_Lot;

   }



   return(lot);

}
Money Management by Vince. Implementation as a module for MQL5 Wizard
Money Management by Vince. Implementation as a module for MQL5 Wizard
  • www.mql5.com
The article is based on 'The Mathematics of Money Management' by Ralph Vince. It provides the description of empirical and parametric methods used for finding the optimal size of a trading lot. Also the article features implementation of trading modules for the MQL5 Wizard based on these methods.
Reason: