which order's open price is the lowest one

 

which one's price is the lowest one

I have bought 5 times,so I have 5 OP_BUY order, how to find out which order's open price is the lowest one?

 

u should loop all the orders to find it & u can use MathMin()

 
qjol:

u should loop all the orders to find it & u can use MathMin()


thank you,I'm a beginner, will you show me a sample of loop.
 
for (int i = 0; i < OrdersTotal(); i++)
   {
   OrderSelect (i, SELECT_BY_POS, MODE_TRADES);
   
   if (OrderSymbol() == Symbos() && OrderType() == OP_BUY)
      {
      //then do something
      }
   }
 

but BTW if u have only this 5 on this symbol it's supposed to be the first i (the first selecting order) on the sample above (SELECT_BY_POS)

And nothing will happen if you going to read this book

 
qjol:

thank you sir, and how can I find out which one' open price is the lowest one from a loop? MathMin() can find out which is smaller from two, i try to find out which is smaller from five or more, will you show me a sample about it?
 
double a = 1.39355;
double b = 1.37566;
double c = 1.41234;

double smallest = MathMin(MathMin(a,b),c);
 

thank you very much sir, I'll study the code.

 
double lowest=99999;
for(int pos = OrdersTotal()-1; pos >= 0 ; pos--) if (
    OrderSelect(pos, SELECT_BY_POS)             // Only my orders w/
&&  OrderMagicNumber() == magic.number          // my magic number
&&  OrderSymbol()      == Symbol() ){           // and period and symbol
   lowest = MathMin( lowest, OrderOpenPrice() );
}
 

Thank you Sir:

I had 3 buying order, My perpose is to select the lowest one, I used the code above, but it still show me all the 3 OrderOpenPrice,not the only lowest one,will you please help me to solve it?

2010.11.02 04:42:16 MyEa GBPJPY,M5: 129.203
2010.11.02 04:42:16 MyEa GBPJPY,M5: 129.207
2010.11.02 04:42:16 MyEa GBPJPY,M5: 129.236

 

my code didn't help