I need to open a position that is larger than the broker's limit

To add comments, please log in or register
Jing Wang
295
Jing Wang  

Hi, everyone. I'm wondering if someone can help me on this.

Suppose I need to open a 112 lot buy trade while the broker only allows max 50 lots in a single trade. So I need to break up into 3 trades 50 lot, 50 lot and 12 lots.


the following code does not work and I don't know why. In back test it just keep opening multiple trades even if the total lots exceeds 112 lots.



///////////////////////////////////////////////////////////
void TradeBuy(void) {
 double l=0; double lot_counter=0;
 int i=0;
 order_ticket=-1; order_ticket1=-1; 
   RefreshRates();
   GetMarketInfo();
   int MaxLot=MarketInfo(Symbol(), MODE_MAXLOT);   
   
 
 //---lot calculation
 
 if(condition==True){
   l=112;
   lot_counter=l;
        }
 if(l>MaxLot)l=MaxLot;
 while(lot_counter > l){

                //---Placing the order 
                 while(order_ticket<0 && i<5) {   
                // Sending a trade request  
                order_ticket=OrderSend(Symbol(),OP_BUY,l,Ask,Slip,0,0,orderComment,Magic1,NULL,clrBlue);
                if(order_ticket<0) { 
                if(!Errors(GetLastError())) return; }
                 else {
                OrderPrint();
                }
                i++; } // end of while 
        lot_count = lot_counter - l;
        l = lot_counter;
        if(l>MaxLot)l=MaxLot;

        }// end of while
}
To add comments, please log in or register