Select the low or high of previous pending order's bar!!!!

To add comments, please log in or register
mnatarajan63
215
mnatarajan63  

hi.... i need help in ea......i had an order placed in a bar and it is still pending and many bars have passed without trading, now i want to select the low or high of that pending order's bar....how to do it ??...please some one tell me the code snippet for it???

Simon Gniadkowski
17644
Simon Gniadkowski  

First you need to get the order ticket . . .

Then using the Order Ticket you get the time the order was placed, then find the bar you want for the Timeframe you want

The once you have the BarShift value you can look up the low or high for that BarShift.

For example . . .

I haven't tested this . . . .

for(int OrderPosition = OrdersTotal()-1; OrderPosition >= 0 ; OrderPosition--) 
   if ( OrderSelect(OrderPosition, SELECT_BY_POS, MODE_TRADES) &&  
        OrderMagicNumber() == YourMagicNo && 
        OrderType() >= OP_BUYLIMIT && OrderType() <= OP_SELLSTOP &&
        OrderSymbol() == YourSymbol )
      {
       double BarHigh = iHigh(YourSymbol, YourTimeframe, iBarShift( YourSymbol, YourTimeframe, OrderOpenTime() ) );  
       double BarLow  = iLow(YourSymbol, YourTimeframe, iBarShift( YourSymbol, YourTimeframe, OrderOpenTime() ) ); 
      }
whroeder1
17949
whroeder1  
Or if you're only running on the current chart
for(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 my pair.
&&  OrderType()          > OP_SELL                  // Only pending orders
){
    int    iOOT    = iBarShift(NULL,0, OrderOpenTime());
    double BarHigh = High[iOOT],
           BarLow  =  Low[iOOT];
}
mnatarajan63
215
mnatarajan63  
RaptorUK:

First you need to get the order ticket . . .

Then using the Order Ticket you get the time the order was placed, then find the bar you want for the Timeframe you want

The once you have the BarShift value you can look up the low or high for that BarShift.

For example . . .

I haven't tested this . . . .


thanks mate......i will check it when the market opens.....anyways..thanks for answering quick......
mnatarajan63
215
mnatarajan63  
WHRoeder:
Or if you're only running on the current chart

oh...i get it.....thanks.....i will update u when i try it....thanks again for ur reply....
Simon Gniadkowski
17644
Simon Gniadkowski  
kmnatarajan:

thanks mate......i will check it when the market opens.....anyways..thanks for answering quick......
If you are just using one symbol you don't need to wait . . use the Strategy Tester.
mnatarajan63
215
mnatarajan63  

thanks dude.....i never knew that there was such a thing known as strategy tester,...only after u have said, i did that....and voila!!!.....it is working properly...!!...thanks a lot....

Simon Gniadkowski
17644
Simon Gniadkowski  
Glad to hear you are making progress :-)
To add comments, please log in or register