How to code such EA - page 2

 
while(....) {
odprt=OrderSend(...);
return(0); 
RefreshRates();
Sleep(1000);
}

 

BTW it's supposed to be:

while(....) {
Sleep(1000);
RefreshRates();
odprt=OrderSend(...);
return(0); 
}
 

No, still same problem. It opens many ordes. How can I find last order open price, any idea?

Is the last open order:

OrderSelect(0,SELECT_BY_POS,MODE_TRADES);

 

no the last order is OrderSelect(OrdersTotal()-1,SELECT_BY_POS,MODE_TRADES);

 
OK, than maybe there is a problem. Thanks I'll try this.
 
01005379:
OK, than maybe there is a problem. Thanks I'll try this.


i don't understand how it's going to help u it's the same as

for(cnt=OrdersTotal()-1;cnt>=0;cnt--){
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);

 
It's not, because in this loop we are going from last order to first, and EA doesn't look last open order but first open order.
 

Lets say I have BUY,1 BUY2, SELL1, SELL2 and SELL3 orders. BUY1 was opened first and SELL3 last. How can I find BUY2 open price. I try like this

for(int i=0;i<OrdersTotal();i++){
   OrderSelect(i,SELECT_BY_POS,MODE_TRADES)  
   if(OrderType()==OP_BUY) double lastbuy=OrderOpenPrice();
   else double lastsell=OrderOpenPrice();
}
 
01005379:

Lets say I have BUY,1 BUY2, SELL1, SELL2 and SELL3 orders. BUY1 was opened first and SELL3 last. How can I find BUY2 open price. I try like this


no,

for(int i=OrdersTotal()-1; i>=0 ;i--){
   OrderSelect(i,SELECT_BY_POS,MODE_TRADES)  
   if(OrderType()==OP_BUY) double lastbuy=OrderOpenPrice();
   else double lastsell=OrderOpenPrice();
}

but this is gonna give u the last order

Print ("the last order is: ", lastbuy)
 
qjol:


no,

but this is gonna give u the last order

I find the way. Thanks anyway!
Reason: