searching for orders

 

Could someone please help with this need?

I want my expert to look for any open orders (either a buy or sell that has been filled). If the expert finds a buy or sell order that is filled, I want it to place another order. This seems very trivial and simple to me, yet I cannot get my expert modified to accomplish this. Any help is GREATLY appreciated! Thank you in advance. ....

Forexman

 

for(i = OrdersTotal()-1; i >= 0; i--){

OrderSelect(i, SELECT_BY_POS, MODE_TRADES){

if(OrderType() == OP_BUY){

... you have found an open buy

}

if(OrderType() == OP_SELL){

... you have found an open sell

}

}

 
phy:

for(i = OrdersTotal()-1; i >= 0; i--){

OrderSelect(i, SELECT_BY_POS, MODE_TRADES){

if(OrderType() == OP_BUY){

... you have found an open buy

}

if(OrderType() == OP_SELL){

... you have found an open buy

}

}

 

?

 

Are you willing to Yahoo IM or email to help me on this Phy?

 
...still getting compile errors.....
 
Post your code
 
//+------------------------------------------------------------------+ //| Stoch.mq4 | //| Copyright © 2005, MetaQuotes Software Corp. | //| https://www.metaquotes.net/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2005, MetaQuotes Software Corp." #property link "https://www.metaquotes.net/" //---- extern double TakeProfit = 13; extern double Lots = 1; extern double TrailingStop = 30; extern double StopLoss = 65; extern double MM = 0; extern double Risk = 30; extern double LotLimit = 50; extern double Per = 3; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int start() { double s = GlobalVariableGet("SELLSTOP"); double b = GlobalVariableGet("BUYSTOP"); double ds = GlobalVariableGet("DateS"); double db = GlobalVariableGet("DateB"); //---- if(ds != DayOfWeek() && Hour() == 12) { GlobalVariableDel("SELLSTOP"); GlobalVariableDel("BUYSTOP"); GlobalVariableDel("DatesS"); GlobalVariableDel("DatesB"); } double SL3,BH3; //---- if(OrdersTotal() < 1 && Hour() == 11 && Minute() == 59) return(0); //---- if(OrdersTotal() > 0 && Hour() == 11 && Minute() == 59) { int total = OrdersTotal(); //---- for(int i = total - 1; i >= 0; i--) { OrderSelect(i, SELECT_BY_POS); int type = OrderType(); bool result = false; //---- switch(type) { //Close pending orders case OP_BUYLIMIT : case OP_BUYSTOP : result = OrderDelete(OrderTicket()); case OP_SELLLIMIT : case OP_SELLSTOP : result = OrderDelete(OrderTicket()); } //---- if(result == false) { Alert("Order " , OrderTicket() , " failed to close. Error:" , GetLastError()); Sleep(3000); } } } double H4 = (High[1] + 13*Point); double L4 = (Low[1] - 13*Point); //---- if(db != DayOfWeek() && s == 0) { SL3 = OrderSend(Symbol(), OP_SELLSTOP, Lots, L4, 0, L4 + StopLoss*Point, L4 - TakeProfit*Point, NULL , 0, 0, Red); //---- if(SL3 < 0) { GlobalVariableSet("SELLSTOP", 0); } else { GlobalVariableSet("SELLSTOP", 1); GlobalVariableSet("DateS", DayOfWeek()); } } //---- if(db != DayOfWeek() && b == 0) { BH3 = OrderSend(Symbol(), OP_BUYSTOP, Lots, H4, 3, H4 - StopLoss*Point, H4 + TakeProfit*Point, NULL , 0, 0, Green); //---- if(BH3 < 0) { GlobalVariableSet("BUYSTOP", 0); } else { GlobalVariableSet("BUYSTOP", 1); GlobalVariableSet("DateB", DayOfWeek()); } } } //+------------------------------------------------------------------+ BASICALLY, I NEED TO GET THIS TO LOOK FOR OPEN ORDERS AND THEN PLACE ONLY ONE CORRESPONDING ORDER. I.E. IF THERE IS A BUY POSITION OPENED, I WANT TO PLACE ONE SELL ORDER.. ....
 
i GOT IT LICKED....THANKS A TON PHY!!!
 

good

Reason: