Evenescent question about function MathFloor()

 

I have slight problems with digesting piece of code posted in Mql Book.:

int start()                                     // Special function start
  {
   int Dist_SL =10;                             // Preset SL (pt)
   int Dist_TP =3;                              // Preset TP (pt)
   double Prots=0.35;                           // Percentage of free margin
   string Symb=Symbol();                        // Symbol
//-------------------------------------------------------------------------- 2 --
   while(true)                                  // Cycle that opens an order
     {
      int Min_Dist=MarketInfo(Symb,MODE_STOPLEVEL);// Min. distance
      double Min_Lot=MarketInfo(Symb,MODE_MINLOT);// Min. volume
      double Step   =MarketInfo(Symb,MODE_LOTSTEP);//Step to change lots
      double Free   =AccountFreeMargin();       // Free Margin
      double One_Lot=MarketInfo(Symb,MODE_MARGINREQUIRED);//Cost per 1 lot
      //-------------------------------------------------------------------- 3 --
      double Lot=MathFloor(Free*ProtsOne_LotStep)*Step;// Lots
What exactly did happen in function MathFloor (apart from finding the nearest integer number lower than value placed between brackets)? Are the multipliy'ing signs omited or it's totally different operation?
I've got another, quite ridiculous and shameful question. I don't know what is this step to change lots variable for. Is that mean, for instance, that with minimum lot=0.1, and step =0.02 i can open orders for 1.2;1.4;...;1+n*.02 lots? How does it work?
Sorry for that newbie topic. I would be utterly grateful, if you could answer me (with possibly low level of hatred), before wiping it out from this forum ;)
 
shirava2k12:

I have slight problems with digesting piece of code posted in Mql Book.:

1. What exactly did happen in function MathFloor (apart from finding the nearest integer number lower than value placed between brackets)? Are the multipliy'ing signs omited or it's totally different operation?

2. I've got another, quite ridiculous and shameful question. I don't know what is this step to change lots variable for. Is that mean, for instance, that with minimum lot=0.1, and step =0.02 i can open orders for 1.2;1.4;...;1+n*.02 lots? How does it work?

Sorry for that newbie topic. I would be utterly grateful, if you could answer me (with possibly low level of hatred), before wiping it out from this forum ;)

1. the contents of the brackets is evaluated and MathFloor is performed on the result.

2. You Broker only allows Lot sizes in multiples of LotStep. If LotStep is 0.02 then you can have lots of 1.02, 1.20, 1.22 but not 1.23, in other words, your lot sizes can be MODE_MINLOT + n*MODE_LOTSTEP

 
  1. your lot sizes can be MODE_MINLOT + n*MODE_LOTSTEP
    Correct.
  2. You posted
     double Lot=MathFloor(Free*ProtsOne_LotStep)*Step;// Lots
    Likely you meant
     double Lot=MathFloor(Free*Prots*One_Lot/Step)*Step;// Lots

  3. However, what you probably want is Contract Size - MQL4 forum



 
Apparently a small mistake has crept into the mql book, since " double Lot=MathFloor(Free*ProtsOne_LotStep)*Step " was quoted from it ( https://book.mql4.com/trading/ordersend). Your answers have made things clear. Thanks a lot.
Reason: