|
|||||||
| Register in Forex TSD! | |
|
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time). Click here to register and get more information |
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
OrderSend error with OP_SELLSTOP and OP_BUYSTOP
Hi there,
I have a problem with issuing OP_SELLSTOP/OP_BUYSTOP. For example, I ran a script on EURUSD 1 Hourly: MyPrice = High[1] + (iATR(Symbol(),0,6,1)*1.5); Ticket=OrderSend(Symbol(), OP_BUYSTOP, Lots, MyPrice,3, Low[1], 0,"BUYSTOP",0,0,Green); MyPrice returns 1.16925750. It gives me an error "2005.11.28 22:00:06 EURUSD,H1: invalid price 1.16925750 for OrderSend function". It is associated with error code: 4107. So, I thought it was because of the rounding off issue. Hence, I replaced MyPrice with: MyPrice = High[1] + NormalizeDouble(((iATR(Symbol(),0,6,1)*1.5),4); Ticket=OrderSend(Symbol(), OP_BUYSTOP, Lots, MyPrice,3, Low[1], 0,"BUYSTOP",0,0,Green); Now, I get "OrderSend BUYSTOP failed with error #4109" (ERR_TRADE_NOT_ALLOWED). Even if I hardcoded the price like so, it still returns me #4109 error. Can anyone do me a favour and execute this, and tell me if it works?: OrderSend("EURUSD", OP_BUYSTOP, 1, 1.1900, 3, Low[1], 0,"BUYSTOP",0,0,Green); Has anyone got a successful OP_BUYSTOP/SELLSTOP sample? What does the above error really mean 4107 and 4109? Thanks! |
|
|||
|
Thanks CodesGuru. That actually works as an EA on the same MT4 build as yours.
But I want to challenge you more, because the following does not work for me as a script (instead of EA). I think we have a bug!. Would you mind testing it for me. Code:
int Ticket=OrderSend(Symbol(), OP_BUYSTOP, 1, (High[1]+0.0020), 3, (Low[1]-0.0020), 0,"BuyStop",0,0,Green); if(Ticket<0) string MsgText = "OrderSend BUYSTOP failed with error #" + GetLastError(); Print(Symbol()+", "+(High[1]+0.0020) + ", " + (Low[1]-0.0020) + ", " +MsgText); If you do get 4107 error (Invalid Price), do you think it's because the MyPrice results in more than FOUR decimal places? Thanks once again. |
|
|||
|
TheExponential,
Did you ever get this resolved. I'm having the same problem when building a "script" to close/open positions on a "single click". If I run it as an expert, it runs fine and will close all open positions. If I run it as a script, it fails with your error. I do know that it's tied to not being allowed to run live trades from a script, but wondered if you found a way to force an allow of live trades. (the Trader script that comes with MT4 won't even work due to the same error. Bear |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| OrderSend problem | Hartadi | Expert Advisors - Metatrader 4 | 10 | 04-11-2007 01:12 PM |
| OrderSend and stops | Pertti | Questions | 2 | 03-12-2007 04:47 AM |
| EA -- OrderSend issue | SaxMan | Metatrader 4 | 2 | 02-23-2007 03:00 AM |
| OrderSend question | knili | Metatrader 4 | 5 | 10-03-2006 12:16 AM |
| OrderSend at a certain time | martin80 | Metatrader 4 | 4 | 09-18-2006 12:47 PM |