lot increase - page 2

 
RaptorUK:
Did you look at the code I posted and did you understand it ?  if you haven't seen it do a search . . .


Hi RaptorUk,

To be honest I didn't see any code (need to wash my eyes....), but I go again to the topic.

 

Update - Ok. I have not  see the code ( need to look for a compass...). 

Thank you

Luis 

 
luisneves:


Hi RaptorUk,

To be honest I didn't see any code (need to wash my eyes....), but I go again to the topic.

 

Update - Ok. I have not  see the code ( need to look for a compass...). 

Thank you

Luis 


Hi RaptorUK,

My apologies to take your time, but I can't identify where your code is. Is that possible get from you the right place ?

Thank you in advance.

Luis 

 
luisneves:


Hi RaptorUK,

My apologies to take your time, but I can't identify where your code is. Is that possible get from you the right place ?

Thank you in advance.

Luis 

Try here:  https://www.mql5.com/en/forum/140534
 

Good morning RaptorUk;

Thank you for the link provided (definitely am in need for glasses...)

Ok, not a good start taking in consideration my ignorance on these matters, anyway I will do my up most to include this in code to get an opening at precise distance from the later.

Other question (if you still in the mood to keep help me), an op_buy  or op_sell need to include slippage and is that the same for pending orders ?. What I mean is; When  send the pending to the broker do I need to include slippage and if not, when that pending is triggered is the slippage taking in consideration to get that order open ?

Thank you for any clarification regarding the above issue an for time spent.

Luis 

 

Hi RaptorUK,

My apologies to get back to this issue. 

With the code below I can't open orders and receive error order send 4051 from the tester tab.

 

 {
       lotmin = MarketInfo(Symbol(),MODE_MINLOT);
       lotmax = MarketInfo(Symbol(),MODE_MAXLOT);
       lotstep = MarketInfo(Symbol(),MODE_LOTSTEP);
       margin = MarketInfo(Symbol(),MODE_MARGINREQUIRED);
       
       if(LotSize * margin > AccountFreeMargin())
          LotSize = AccountFreeMargin()/margin;
          
      InitialLot = MathFloor(LotSize/lotstep) * lotstep;
      
       mlots = 0;                                 
       for(Orders = OrdersTotal()-1; Orders >= 0 ; Orders--)                      
        {
         if(!OrderSelect(Orders,SELECT_BY_POS,MODE_TRADES))continue;
          if(OrderSymbol() == Symbol() 
             && OrderMagicNumber()== MagicNumber)
           { 
            lastlot = OrderLots();
         if(mlots <= lastlot)mlots = MathFloor((lastlot*Multiplier)/lotstep)* lotstep;  
           }
        } 
      if(InitialLot < lotmin)
          InitialLot = lotmin;
       if(InitialLot > lotmax)
          InitialLot = lotmax;                                           
     }          

 

but using the code below the orders are opening,

 

 MLots = 0;
   
   for(int cnt = 0; cnt < OrdersTotal(); cnt++)
      {//11
      if(!OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES))continue;
         {//12
         if(OrderSymbol() == Symbol()&& OrderMagicNumber() == MagicNumber)
            {//13
            LastLot = OrderLots();
            }//13                                         
         MLots = NormalizeDouble( LastLot * Multiplier,2);        
         }//12      
      }//11 

 

Could you tell me what I'm doing wrong?

 Best regards

Luis 

 Update,

 seems that the code do not work if in a different part of the whole code. Once I put it in a different part starts to work (do not understand....). 

 
luisneves: when that pending is triggered is the slippage taking in consideration to get that order open ?

Terminal's price +/- slippage must be within brokers price to open a market order. Terminal's price may be a minute old by the time it gets to the server, goes through the queue and the server goes to fill.

With a pend order there is only the brokers price. No slippage.

 
WHRoeder:

Terminal's price +/- slippage must be within brokers price to open a market order. Terminal's price may be a minute old by the time it gets to the server, goes through the queue and the server goes to fill.

With a pend order there is only the brokers price. No slippage.




Hi WHRoeder,

Thank you for clarification, seems that I go for pendings, instead. 

Two questions;

 Is there a need to normalize Bid and Ask with pendings ?

Makes any sense use MathRound to get a comparison between two doubles and after that compare the result against  an int distance as shown below ? 

double xpoint = 0.00001; 
if(Op == OP_BUY && MathRound((OrderOpenPrice() - Bid)/xpoint) >= (OppositeDistance*pips2dbl) && SellAllowed)

Thank you in advance.

Best Regards

Luis 

Reason: