[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 212

 
dzhini:

Great, it's all here. Posted last night, but the thread has already gone pretty far with explanations of what a magician is and how it is prepared )))

Please give me an answer to my question.

My EA sets BUYLIMIT and SELLLIMIT at certain times. I would like to make it delete the pending orders (OP_BUY or OP_SELL) in one direction when the order is opened.

This was my variant:


It looks better this way:

void start(){
  .....

  for(int i=OrdersTotal() -1;i>=0;i--) 
    if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) 
     {
      if(CalculateCurrentOrders(Symbol())>0) {Alert(CalculateCurrentOrders(Symbol()));ClosePendingOrder(OP_SELLLIMIT);} // (1) 
      if(CalculateCurrentOrders(Symbol())<0) {Alert(CalculateCurrentOrders(Symbol()));ClosePendingOrder(OP_BUYLIMIT);} //(2) 
      if(TimeCurrent() - OrderOpenTime()>=HowManyHours*60*60) {ClosePendingOrder(OP_BUYLIMIT);ClosePendingOrder(OP_SELLLIMIT);} //(3) 
     } 
   ....

}

Without getting into the logic, the absence of curly brackets and incorrect organization of OrderSelect() are immediately apparent

 
eddy:

why not make these questions thematically grouped and add the possibility to ask questions directly there? that would be a normal questionnaire.

And if you add the possibility to add not only questions but also tasks, with codes/articles as answers, you get what I propose - a different site structure that includes all of its existing content

Roman, the preparatory work has been done for a long time, the FAQ ideology has been previously developed and will be posted in a special branch, the technical basis has been agreed upon with the administration.
Wait for the release of the branch to see how it coincides with your ideas and, if necessary, you can develop and implement your project if it is within your power.
 
Sergey_Rogozin:

It looks better this way:

Without getting into the logic, the lack of curly braces and the incorrect organisation of OrderSelect() are immediately apparent

Can you explain what is wrong with OrderSelect() . Because, as I wrote before, if I make removal of orders in the direction of already open trade, everything goes without problems. Also it goes without problems removing all orders in strictly defined time.
 
dzhini:
Could you please explain what is wrong with OrderSelect() . Because, as I wrote before, if I make removal of orders in the direction of already open trade, everything goes without problems. We also have no problems removing all the orders at a certain time.
Without seeing the code, it's hard to say definitely. Perhaps OrderSelect() will work as it is, if you do not need to select by symbol, magician, type of operation, etc.
 

This is essentially an attempt to make a practice for the future, to work with different sets of orders (not just two).

When the order view cycle is running, the EA runs quite well up to the alert, but it does not want to work correctly with the delete function:

void ClosePendingOrder(int ORDERType)
{
 while(!IsTradeAllowed()) Sleep(100);
 if(OrderType()==ORDERType)
 {
 if(OrderSymbol()==Symbol())
 { 
 if(!OrderDelete(OrderTicket(),CLR_NONE))
   Print("Order close error",GetLastError());
return;
      }
    }
}
 
granit77:
the FAQ's ideology is pre-designed and the technical basis has been agreed with the administration.
see how it matches your ideas and, if necessary, you can develop your own project
Did I get the answer: "everything has already been thought out and agreed with the administration (i.e., there's no way to change it), if something does not match your ideas, you can make your own"?
 
eddy:
I understood the answer correctly: "Everything has already been thought out and agreed with the administration (i.e. there is no way to change it), if something does not match your ideas - you can make your own"?
"Everything has already been stolen before you")))
 
dzhini:

This is essentially an attempt to make a practice for the future, to work with different sets of orders (not just two).

When the order view cycle is running, the EA runs quite well up to the alert, but it does not want to work correctly with the delete function:

It looks like everything is in place. I don't know.
 
Sergey_Rogozin:

How does this work: ClosePendingOrder(OP_SELLLIMIT);} // (1) ?

Its code.

The code of the function to delete an order is given in the very message... Maybe I didn't understand the question, but I'll try to explain it as I understood it:

A for loop sets an enumeration of all available open orders and pending orders. ClosePendingOrder(OP_SELLLIMIT) - selects from this list those that match the currency symbol and parameter OP_SELLLIMIT . As soon as it finds these matches, it deletes this pending order.

 
dzhini:

I gave the code for the delete order function in that very message... Maybe I didn't understand the question, but I'll try to explain it as I understood it:

A for loop sets an enumeration of all available open orders and pending orders. ClosePendingOrder(OP_SELLLIMIT) - selects from this list those that match the currency symbol and parameter OP_SELLLIMIT . As soon as it finds these matches, it removes this pending order.

I've already figured it out. Just looked at it inattentively at first.

I don't see the error.

Reason: