Discussion of article "The Optimal Method for Calculation of Total Position Volume by Specified Magic Number" - page 4

 
jelagins #:

the following warnings and errors were noticed during compilation in mql5: possible loss of data due to type conversion from 'long' to 'int' eposvoltest.mq5 426 20 , possible loss of data due to type conversion from 'long' to 'datetime' eposvoltest.mq5 439 32, possible loss of data due to type conversion from 'long' to 'int' eposvoltest.mq5 456 26, possible loss of data due to type conversion from 'long' to 'int' eposvoltest.mq5 491 23, return value of 'OrderSend' should be checked eposvoltest.mq5 236 4, return value of 'OrderSend' should be checked eposvoltest.mq5 268 4, '-' - expression not boolean eposvoltest.mq5 279 14, 'MQL5_TESTING' is deprecated, use 'MQL_TESTER' instead eposvoltest.mq5 335 23, 'MQL5_TESTING' is deprecated, use 'MQL_TESTER' instead of eposvoltest.mq5 346 23

10.09.2025

It is hardly surprising, considering that the code dates from 2010!

 
There was an error in the code.
bool fOpSell(string aSymbol,double aVolume=0.1,int aSlippage=0,int aMagic=0,string aComment="",string aMessage="",bool aSound=false)
  {
   request.symbol=aSymbol;
   request.action=TRADE_ACTION_DEAL;
   request.type=ORDER_TYPE_SELL;
   request.volume=aVolume;
   request.price=SymbolInfoDouble(aSymbol,SYMBOL_BID);
   request.sl=0;
   request.tp=0;
   request.deviation=aSlippage;
   request.type_filling=ORDER_FILLING_FOK;
   request.comment=aComment;
   request.magic=aMagic;
   if(aMessage!="")Print(aMessage);
   if(aSound)PlaySound("expert");
   OrderSend(request,result);
   if(result.retcode==TRADE_RETCODE_DONE)
     {
      Print("...lucky (#"+IntegerToString(result.order)+")");
      if(aSound)PlaySound("ok");
      return(1);
     }
   else
     {
      Print("...mistake "+IntegerToString(result.retcode)+" - "+fTradeRetCode(result.retcode));
      if(aSound)PlaySound("timeout");
      return(-1);
     }
  }

The corrected version is in the trailer.

Files:
eposvoltest.mq5  19 kb