possible use of uninitialized variable 'oldorderopenprice'

To add comments, please log in or register
Endru Sitompul
55
Endru Sitompul  

maybe any coder can fix this?

this code give warning

possible use of uninitialized variable 'oldorderopenprice'


double FindLastBuyPrice() {

   double oldorderopenprice;
   int oldticketnumber;
   double unused = 0;
   int ticketnumber = 0;
   for (cnt = OrdersTotal() - 1; cnt >= 0; cnt--) {
      ticket = OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber && OrderType() == OP_BUY) {
         oldticketnumber = OrderTicket();
         if (oldticketnumber > ticketnumber) {
            oldorderopenprice = OrderOpenPrice();
            unused = oldorderopenprice;
            ticketnumber = oldticketnumber;
         }
      }
   }
   return (oldorderopenprice);
}
double FindLastSellPrice() {
   double oldorderopenprice;
   int oldticketnumber;
   double unused = 0;
   int ticketnumber = 0;
   for (cnt = OrdersTotal() - 1; cnt >= 0; cnt--) {
      ticket = OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber && OrderType() == OP_SELL) {
         oldticketnumber = OrderTicket();
         if (oldticketnumber > ticketnumber) {
            oldorderopenprice = OrderOpenPrice();
            unused = oldorderopenprice;
            ticketnumber = oldticketnumber;
         }
      }
   }
   return (oldorderopenprice);
}
Juvenille Emperor Limited
Moderator
10285
Eleni Anna Branou  

Please use the </> button to insert your code.


Endru Sitompul
55
Endru Sitompul  
Eleni Anna Branou:

Please use the </> button to insert your code.


ok

Marco vd Heijden
Moderator
12714
Marco vd Heijden  
double oldorderopenprice=0;
Endru Sitompul
55
Endru Sitompul  
Marco vd Heijden:

WOW, amazing!!

thanks Macro, im very happy!

Mehmet Bastem
1672
Mehmet Bastem  
Endru Sitompul:

maybe any coder can fix this?

this code give warning

possible use of uninitialized variable 'oldorderopenprice'


https://www.mql5.com/en/forum/242963
To add comments, please log in or register