English

## OrderLots() error

 22 meroo_basha 2014.04.06 19:30   Hello, I am Trying to calculate my prievious trades losses using a function of the open lots. But it seems there is something wrong because every time I try to read Print ( OrderLots()); I got the initial lot which is 0.01. ``` void lossCalculation() {    int total=OrdersTotal();    for (int cnt=total;cnt>=0;cnt--)     OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES); double Loss1=Step*OrderLots(); double Loss2=Step*OrderLots()+Loss1; double Loss3=Step*OrderLots()+Loss2; double Loss4=Step*OrderLots()+Loss3; double Loss5=Step*OrderLots()+Loss4; double Loss6=Step*OrderLots()+Loss5; double Loss7=Step*OrderLots()+Loss6; double Loss8=Step*OrderLots()+Loss7; double Loss9=Step*OrderLots()+Loss8; double Loss10=Step*OrderLots()+Loss9; if (OrderLots()==0.01) {Loss=Loss1;}   if (OrderLots()==0.02) {Loss=Loss2;}    if (OrderLots()==0.04) {Loss=Loss3;}     if (OrderLots()==0.08) {Loss=Loss4;}      if (OrderLots()==0.16) {Loss=Loss5;}       if (OrderLots()==0.32) {Loss=Loss6;}        if (OrderLots()==0.64) {Loss=Loss7;}         if (OrderLots()==1.28) {Loss=Loss8;}          if (OrderLots()==2.56) {Loss=Loss9;}           if (OrderLots()==5.12) {Loss=Loss10;}              Print ( OrderLots());     }```
 2408 deVries 2014.04.06 20:05 #   This is what happens ```void lossCalculation()   {    int total=OrdersTotal();  // Example OrdersTotal == 5    OrderSelect(5,SELECT_BY_POS,MODE_TRADES);      //there is no number 5    OrderSelect(4,SELECT_BY_POS,MODE_TRADES);      //OrderLots()==0.16    OrderSelect(3,SELECT_BY_POS,MODE_TRADES);      //OrderLots()==0.08    OrderSelect(2,SELECT_BY_POS,MODE_TRADES);      //OrderLots()==0.04    OrderSelect(1,SELECT_BY_POS,MODE_TRADES);      //OrderLots()==0.02    OrderSelect(0,SELECT_BY_POS,MODE_TRADES);      //OrderLots()==0.01    This trade is now selected double Loss1=Step*OrderLots(); double Loss2=Step*OrderLots()+Loss1; double Loss3=Step*OrderLots()+Loss2; double Loss4=Step*OrderLots()+Loss3; double Loss5=Step*OrderLots()+Loss4; double Loss6=Step*OrderLots()+Loss5; double Loss7=Step*OrderLots()+Loss6; double Loss8=Step*OrderLots()+Loss7; double Loss9=Step*OrderLots()+Loss8; double Loss10=Step*OrderLots()+Loss9; if (OrderLots()==0.01) {Loss=Loss1;}                   //true   if (OrderLots()==0.02) {Loss=Loss2;}    if (OrderLots()==0.04) {Loss=Loss3;}     if (OrderLots()==0.08) {Loss=Loss4;}      if (OrderLots()==0.16) {Loss=Loss5;}       if (OrderLots()==0.32) {Loss=Loss6;}        if (OrderLots()==0.64) {Loss=Loss7;}         if (OrderLots()==1.28) {Loss=Loss8;}          if (OrderLots()==2.56) {Loss=Loss9;}           if (OrderLots()==5.12) {Loss=Loss10;}              Print ( 0.01);                                        //Print ( OrderLots());     }``` look to what you coded