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

To add comments, please log in or register
Jing Wang
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; 
   int MaxLot=MarketInfo(Symbol(), MODE_MAXLOT);   
 //---lot calculation
 while(lot_counter > l){

                //---Placing the order 
                 while(order_ticket<0 && i<5) {   
                // Sending a trade request  
                if(order_ticket<0) { 
                if(!Errors(GetLastError())) return; }
                 else {
                i++; } // end of while 
        lot_count = lot_counter - l;
        l = lot_counter;

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