OrderModify() question

 

Hello MQL4 forum,

{OrderModify(ticket,0,Ask-500*Point,0,0,Blue);}}}}

The code above works, but moves the sl up or down as the ask price moves up or down.

I tried this, as a solution...

{OrderModify(ticket,0,OrderOpenPrice()-500*Point,0,0,Blue);}}}}

(the order being selected is a buy order)

I checked the journal for the error being received and it read 4051. There are multiple error 4051. Basically it doesn't work, and I am curious if anyone else has previously solved this problem before and has an explanation.

I don't see why this solution wouldn't work (yes, I believe I am correctly selecting the order because the first incorrect OrderModify solution is working).

Thank you.

 
WhooDoo22:


I checked the journal for the error being received and it read 4051. There are multiple error 4051. Basically it doesn't work, and I am curious if anyone else has previously solved this problem before and has an explanation.

When you have a problem with a function read the documentation on that function . . . .   OrderModify()   <-----  Click ME ! ! ! 

You cannot modify the  Open Price of the Order to 0.0   . . .   assuming yo have correctly performed a OrderSelect(),  use OrderOpenPrice()  for the 2nd parameter you are passing to OrderModify()

 

Simon, I read the documentation for OrderModify() function and noticed the example being used is a trailing stop. I do not wish to use a trailing stop for the EA. This is because if I used a trailing stop, (according to the example) the EA would need the market to travel x points above current sl to modify the sl to specified price. Basically this is too complicated. I just want to add a stop loss to the order AFTER the order has been submitted to the market.

Anyways, I am trying new solutions currently as well.

Thank you.

 
WhooDoo22:

Simon, I read the documentation for OrderModify() function and noticed the example being used is a trailing stop. I do not wish to use a trailing stop for the EA. This is because if I used a trailing stop, (according to the example) the EA would need the market to travel x points above current sl to modify the sl to specified price. Basically this is too complicated. I just want to add a stop loss to the order AFTER the order has been submitted to the market.

Anyways, I am trying new solutions currently as well.

Thank you.

So why are you trying to change the Open Price to 0.0 ?  you need to leave the Open Price unchanged,  i.e. OrderOpenPrice()  try it . . .
 

Simon,

Strategy tester:

1. Visual mode

2. Speed 31

3. 2010.12.29

4. EURUSD

5. M15

run "Open prices only", not every tick.


MetaEditor: Edit -> Find... -> "// choice 1."


choice 1. = no errors, but I obviously don't want this.

choice 2. = Journal tab -> Journal reads: "error 4051".

Thank you.

Files:
test1.mq4  12 kb
 

Evidently, using OrderOpenPrice() function inside OrderModify() parameters is considered an "invalid function parameter" according to error 4051. I am thinking "?". :) I could save the OrderOpenPrice() value and include this in the order modify function parameters to do what I wish to do, but really? Surely there is a simpler way! Its back to the old grindstone for me. ;)

Thank you.

 
WhooDoo22:
Evidently, using OrderOpenPrice() function inside OrderModify() parameters is considered an "invalid function parameter" according to error 4051.
Evidently, your code is wrong. OrderOpenPrice() is fine. Post the code including your orderSelect.
 

William,

Evidently, I posted the EA in a link for you to download and view in MetaEditor if you wish to provide your support. OrderSelect() function is currently not an issue. You know what? I'll post this just for you, William.

//***************************************************
// EMERGENCY BUY ORDER STOP LOSS PROTECTION SECTION ;
//***************************************************

   OrderSelect(0,SELECT_BY_TICKET,MODE_TRADES); // was ticket.
   if(OrdersTotal()>0)                                                                         {
   if(OrderType()==OP_BUY)                                                                     {
   if(OrderSend1==true)                                                                        {
//   if(iMA(NULL,0,1,0,MODE_SMMA,PRICE_CLOSE,1)<=OrderOpenPrice()-500*Point)                     {
     
// choice 1.     
//     {OrderModify(ticket,OrderOpenPrice(),Ask-500*Point,0,0,Blue);}}}}
// choice 2.
     {OrderModify(ticket,OrderOpenPrice(),OrderOpenPrice()-500*Point,0,0,Blue);}}}}

As you requested.

Thank you.

 
WhooDoo22:

William,

Evidently, I posted the EA in a link for you to download and view in MetaEditor if you wish to provide your support. OrderSelect() function is currently not an issue. You know what? I'll post this just for you, William.

As you requested.

Thank you.

0 is NOT a valid ticket number, not even in the Strategy Tester,   test your OrderSelect() and you will see for yourself . . .
 

Simon, I will run tests to find out.

Thank you.

 

Ah-ha! I switched ticket number 0 to 1, then everything worked like clockwork. Yes, I was wrong William... The OrderSelect() function was an issue. Obviously, the OrderSelect() function must select a ticket. If the ticket number is 0, what ticket will the EA select? :O "?". Thank you both for your assistance.

Thank you.