Maximum Lot Size EA - Help!

Back to topics list To post a new topic, please log in or register
avatar
2
tylevay 2014.01.20 03:30
 

Hi guys!

I'm having a hard time with MAXLOTSIZE..

My broker does not allow Lots greater than 50.00. So, when my MM calculates a greater lot than 50 would give me error 131. I could "cheat it " assuming that if the lot is greater than 50 assume 50 as default as shown bellow.

What i Really would appreciate a help is to split the order about to be sent in as many as my margin and risk factor allows. Ex. 7 orders of 50 and 1 of 48 with a total of 8 orders.. instead of the static orders bellow..


Thanks a lot to you guys and may the pips be with you!


<CODE REMOVED>

avatar
14167
RaptorUK 2014.01.20 10:44 #
 
tylevay:

Hi guys!

I'm having a hard time with MAXLOTSIZE..

My broker does not allow Lots greater than 50.00. So, when my MM calculates a greater lot than 50 would give me error 131. I could "cheat it " assuming that if the lot is greater than 50 assume 50 as default as shown bellow.

What i Really would appreciate a help is to split the order about to be sent in as many as my margin and risk factor allows. Ex. 7 orders of 50 and 1 of 48 with a total of 8 orders.. instead of the static orders bellow..


Thanks a lot to you guys and may the pips be with you!


<CODE REMOVED>


I removed your code . . . .


Please edit your post above and re-insert your code using the SRC button . . . please use the SRC button to post code: How to use the SRC button.

To edit your post . . .

avatar
12983
WHRoeder 2014.01.20 19:24 #
 
tylevay: What i Really would appreciate a help is to split the order about to be sent
From my code
   //{https://forum.mql4.com/59709/page3#883534 Please be hereby advised that
   // your trade has been opened partially (2.32 lots out of 15.84) at the price
   // 587.318. Support: Please be advised, during periods of high volatility or
   //}low liquidity, Limit Orders may be partially executed.
   while(lotsNew >= market_minLot){                                             
      // maxlot, it must be split.                     99.99=50.0+49.99         
      // If a trade size is bigger than               100.10=33.34+33.34+33.33  
      int      nSplit   = MathCeil(lotsNew / market_maxLot);                    
      double   size     = NormalizeLots(lotsNew / nSplit);                      
      if(GetTradeContext() < TC_LOCKED)   return(false); // Refreshes Rates
      double   oop = BidToOpen();               // Update for each openSend.    
      int ticket = OrderSend( market_pair,   op_code,          size,
                              oop,           Slippage_Pips*pips2points,
                              SL,            TP,               orderComment,
                              MN,            NO_EXPIRATION,    orderColor );
      if(ticket < 0){                                                           
         int gle = GetLastError();                                              
         if(!IsTradeAllowed()){                                                 
                           AlertMe("Trading NOT allowed!");    return(false); } 
         RefreshRates();   // Update Bid                                        
         AlertMe( "OrderSend(type=" + op_code + " (" + op_text                  
                  + "), lots=" + DoubleToString(size)                           
                  + ", price=", PriceToStr(oop) + " (" + DeltaToPips(oop-Bid)   
                  + "), SL=" +PriceToStr(SL) +", TP=" +PriceToStr(TP) +", '"    
                  + orderComment+ "', ...) failed: ", gle                       
                  + IfS(" Will retry without stops","", retryOnce) );           
         ea_status   = "OrderSend Failed "+gle;                return(false); } 
      if( !OrderSelect(ticket,SELECT_BY_TICKET) ){ gle = GetLastError();        
         LogMe( "OrderSelect(Ticket=", ticket, ") failed: ", gle );             
                                                               return(false); } 
      lotsNew -= OrderLots();                                                   
   } // true                                                                    

avatar
2
tylevay 2015.01.28 03:13 #
 
WHRoeder:
From my code

Thanks a lot! I couldn´t make it on my code.. here it goes.. thanks for the help..



double LotSize() {
   double Lot;
   double LotOptimized;
   double lotstep;
   double marginrequired;
  
   if (RiskPercent > 0 && UseMM) {
   
      lotstep = MarketInfo(Symbol(), MODE_LOTSTEP);
      marginrequired = MarketInfo(Symbol(), MODE_MARGINREQUIRED);
      Lot = AccountBalance() * RiskPercent / 100.0 / marginrequired;
      
      LotOptimized = MathMod(Lot, lotstep);
      if (LotOptimized != 0.0) Lot -= LotOptimized;
   } else Lot = Lots;
   double minlot = MarketInfo(Symbol(), MODE_MINLOT);
   double maxlot = MarketInfo(Symbol(), MODE_MAXLOT);
   if (Lot < minlot) Lot = minlot;
   if (Lot > maxlot) Lot = maxlot;
   return (Lot);

         
   
}


Back to topics list  

To add comments, please log in or register