Download MetaTrader 5

Lot number for order send and order close

To add comments, please log in or register
wen hao
8
wen hao  

Hi,

Would like to ask, is there anyone encountered invalid lot number for OrderClose function() ?

I'm trying to play around with the EA, a very simple EA.

The lot I had initially is 0.1 when executing order send. Then when I tried to loop through all the order, all order lots is 0.

Here is my code:


   if( testingCount < 10 ){
      ticket = OrderSend(Symbol(),OP_BUY, volumeSize,Ask,slipageSize,0,0,"",0,Black);
      testingCount++;
   }
   
   for( i = 0 ; i < OrdersTotal(); i++){
      if( OrderSelect(i, SELECT_BY_POS) == true ){
         orderTicket = OrderTicket();
         orderPrice = OrderOpenPrice();
         orderSL = OrderStopLoss();
         orderTP = OrderTakeProfit();
         orderLots = OrderLots();

         Alert("Order Lots: " + orderLots);
      }
   }

It keeps on alert me the order lots is 0.

When I changed the lot number from 0.1 to 1, it able to alert me the correct number.

I was wondering what can actually cause this? I was testing on EUR-USD.

Ubzen
5390
Ubzen  
programmerpig:

Hi,

Would like to ask, is there anyone encountered invalid lot number for OrderClose function() ?

I'm trying to play around with the EA, a very simple EA.

The lot I had initially is 0.1 when executing order send. Then when I tried to loop through all the order, all order lots is 0.

Here is my code:


It keeps on alert me the order lots is 0.

When I changed the lot number from 0.1 to 1, it able to alert me the correct number.

I was wondering what can actually cause this? I was testing on EUR-USD.

You probably have orderLots defined as Integer.
Simon Gniadkowski
Moderator
18040
Simon Gniadkowski  
programmerpig:

Hi,

Would like to ask, is there anyone encountered invalid lot number for OrderClose function() ?

I'm trying to play around with the EA, a very simple EA.

The lot I had initially is 0.1 when executing order send. Then when I tried to loop through all the order, all order lots is 0.

Is orderLots a double or an int ?
To add comments, please log in or register