Volume Regulator: Minimum and Maximum Lot size

 

Hello friends :)



I need help for my EA Script :) i want to place Volume Regulator in the extern boolean, to be able to regulaate Minimum and Maximum Lot size before starting the trade.



EA to do not trade with smaller or bigger Lot sizes. For example: if there is a signal to trade (for example Martingale strategies) to do not start before size become bigger than 1 lot is on turn to be traded.


extern bool Volume Regulator = TRUE / FALSE;

extern double MinLots = 1.0

extern double MaxLots = 10.0


If there is needed to pay something for the advises, we can negotiate that. I am willing to pay for good programing services.



Waiting for your replies :)

 

i found something near to my need .... and i will work on it :

https://championship.mql5.com/2012/en/2006


if you have any other ideas, please write to me



here is the script from the link:


//--- extern variables
extern double ExtMaximumRisk=0.05;             // 5% by default
 
//--- calculate current volume
double CalculateVolume()
  {
   double lot_min =MarketInfo(Symbol(),MODE_MINLOT);
   double lot_max =MarketInfo(Symbol(),MODE_MAXLOT);
   double lot_step=MarketInfo(Symbol(),MODE_LOTSTEP);
   double contract=MarketInfo(Symbol(),MODE_LOTSIZE);
   double vol;
//--- check data
   if(lot_min<0 || lot_max<=0.0 || lot_step<=0.0) 
     {
      Print("CalculateVolume: invalid MarketInfo() results [",lot_min,",",lot_max,",",lot_step,"]");
      return(0);
     }
   if(AccountLeverage()<=0)
     {
      Print("CalculateVolume: invalid AccountLeverage() [",AccountLeverage(),"]");
      return(0);
     }
//--- basic formula
   vol=NormalizeDouble(AccountFreeMargin()*ExtMaximumRisk*AccountLeverage()/contract,2);
//--- additional calculation
//   ...
//--- check min, max and step
   vol=NormalizeDouble(vol/lot_step,0)*lot_step;
   if(vol<lot_min) vol=lot_min;
   if(vol>lot_max) vol=lot_max;
//---
   return(vol);
  }