Changing open price of pending orders problem

 

Hello everyone.


In MQL4,

when an EA opens a pending order , if it checks OrderOpenPrice(), it will receive the opening price set in the OrderSend, say PRICE1.

If at some point someone decides to go to the trading platform and change the opening price of the pending order to something else, say PRICE2, I will have a problem with my EA.


If it checks the OrderOpenPrice, it will receive PRICE1.

Is there any way to get PRICE2?


I searched the documentation, but found no useful information.

Is there an OrderGetTriggerPrice or something like that?


thanks in advance

 
In english please.
 
Eleni Anna Branou:
In english please.

Sorry, it is the first time I post something here and I was impressed with the translation tool. Then I edited my post and changed the language just to test the translation and I ended up with the post on wrong language.

 
Andre Simoes:

when an EA opens a pending order , if it checks OrderOpenPrice(), it will receive the opening price set in the OrderSend, say PRICE1.

If at some point someone decides to go to the trading platform and change the opening price of the pending order to something else, say PRICE2,

I will have a problem with my EA.

If it checks the OrderOpenPrice, it will receive PRICE1.

Is there any way to get PRICE2?

  1. OK, OrderOpenPrice is PRICE1.
  2. OK, OrderOpenPrice is PRICE2.
  3. Why? EAs must be coded to recover.
  4. Wrong. #2
  5. #2
 
whroeder1:
  1. OK, OrderOpenPrice is PRICE1.
  2. OK, OrderOpenPrice is PRICE2.
  3. Why? EAs must be coded to recover.
  4. Wrong. #2
  5. #2

Did not get point 3.


On point 4, 5, that is exactly what the EA is expecting, but I am sure that it received PRICE1.


I am using XM UK MT4.

Version 4.00 Build 1090 (19 May 2017)

 
Andre Simoes:

Did not get point 3.

On point 4, 5, that is exactly what the EA is expecting, but I am sure that it received PRICE1.

  1. You're the one that said "I will have a problem with my EA."
  2. I am sure you are wrong. Use the debugger or print out your variables, and find out why.
 
Andre Simoes:

Did not get point 3.


On point 4, 5, that is exactly what the EA is expecting, but I am sure that it received PRICE1.

I agree with @whroeder1. I am sure you are wrong, OrderOpenPrice() returns PRICE2.

 
Andre Simoes:

Hello everyone.


In MQL4,

when an EA opens a pending order , if it checks OrderOpenPrice(), it will receive the opening price set in the OrderSend, say PRICE1.

If at some point someone decides to go to the trading platform and change the opening price of the pending order to something else, say PRICE2, I will have a problem with my EA.


If it checks the OrderOpenPrice, it will receive PRICE1.

Is there any way to get PRICE2?


I searched the documentation, but found no useful information.

Is there an OrderGetTriggerPrice or something like that?


thanks in advance

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Pending_Order_Management()
  {
/*-----------------------------------------------------------------------------------------------*/
   double Price1=0;//OrderOpenPrice of the Pending Order
   double Price2=0;//What you wish the Open Price to be changed too.
/*-----------------------------------------------------------------------------------------------*/
   double Delete_PendingOrder=0;
   double Open_New_PendingOrder=0;
/*-----------------------------------------------------------------------------------------------*/
   if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES))
      if(OrderSymbol()==Symbol())
        {
/*-----------------------------------------------------------------------------------------------*/
         if(OrderType()==OP_BUYLIMIT)
           {
/*-----------------------------------------------------------------------------------------------*/
            Price1=OrderOpenPrice();
            if(Price1!=Price2)
              {
               Delete_PendingOrder=OrderDelete(OrderTicket(),clrNONE);
               Open_New_PendingOrder=OrderSend(Symbol(),OP_BUYLIMIT,0.01,Price2,0,0,0,Symbol(),0,0,clrNONE);
              }
/*-----------------------------------------------------------------------------------------------*/
           }
         if(OrderType()==OP_BUYSTOP)
           {
/*-----------------------------------------------------------------------------------------------*/
            Price1=OrderOpenPrice();
            if(Price1!=Price2)
              {
               Delete_PendingOrder=OrderDelete(OrderTicket(),clrNONE);
               Open_New_PendingOrder=OrderSend(Symbol(),OP_BUYSTOP,0.01,Price2,0,0,0,Symbol(),0,0,clrNONE);
              }
/*-----------------------------------------------------------------------------------------------*/
           }
         if(OrderType()==OP_SELLLIMIT)
           {
/*-----------------------------------------------------------------------------------------------*/
            Price1=OrderOpenPrice();
            if(Price1!=Price2)
              {
               Delete_PendingOrder=OrderDelete(OrderTicket(),clrNONE);
               Open_New_PendingOrder=OrderSend(Symbol(),OP_SELLLIMIT,0.01,Price2,0,0,0,Symbol(),0,0,clrNONE);
              }
/*-----------------------------------------------------------------------------------------------*/
           }
         if(OrderType()==OP_SELLSTOP)
           {
/*-----------------------------------------------------------------------------------------------*/
            Price1=OrderOpenPrice();
            if(Price1!=Price2)
              {
               Delete_PendingOrder=OrderDelete(OrderTicket(),clrNONE);
               Open_New_PendingOrder=OrderSend(Symbol(),OP_SELLSTOP,0.01,Price2,0,0,0,Symbol(),0,0,clrNONE);
              }
/*-----------------------------------------------------------------------------------------------*/
           }
        }
  }

Is this what you are looking for?

 

I agree with all of you.

Something must be wrong on my code.


I will make a simple test case to see if I can reproduce the problem.

If I have any new, I will update this thread.

Reason: