try putting the NormalizeDouble on the outside, like this...
MyPrice = NormalizeDouble(High[1]+(iATR(NULL,0,6,1)*1.5),Digits);
and allow a point or 2 or 3 slippage in the ordersend function.
Error 4109 is ERR_TRADE_NOT_ALLOWED.
Use something like this,
Use something like this,
if(IsTradeAllowed()){ double MyPrice = NormalizeDouble(High[1]+(iATR(NULL,0,6,1)*1.5),Digits); int Ticket=OrderSend(Symbol(), OP_BUYSTOP, Lots, MyPrice, 3, Low[1], 0,"BUYSTOP",0,0,Green); }
Thanks GT,
Actually the NormalizeDouble was already on the outside, just like how you described it. I made a mistake in pasting it in. Otherwise, I would have gotten a syntax error anyway during compilation.
Why did I get a 4109 (Trade not allowed) error? I did this during an open market session. I did try it on the weekend when the market was closed, and I did get different error from the server. 4109 is a MQL4 run time error, and not a server error. I get the same error when I hard code everything:
OrderSend(Symbol(), OP_BUYSTOP, 1, 1.1900, 3, Low[1], 0,"BUYSTOP",0,0,Green);
Does anyone know how we are meant to use OP_BUYSTOP/OP_SELLSTOP in an OrderSend properly? Can someone give me a working sample code? I'd like to see the parameters. and what is the real meaning of 4109?
By the way, I set the slippage = 3, and there is enough gap for the StopLoss.
Thanks in advance.
Actually the NormalizeDouble was already on the outside, just like how you described it. I made a mistake in pasting it in. Otherwise, I would have gotten a syntax error anyway during compilation.
Why did I get a 4109 (Trade not allowed) error? I did this during an open market session. I did try it on the weekend when the market was closed, and I did get different error from the server. 4109 is a MQL4 run time error, and not a server error. I get the same error when I hard code everything:
OrderSend(Symbol(), OP_BUYSTOP, 1, 1.1900, 3, Low[1], 0,"BUYSTOP",0,0,Green);
Does anyone know how we are meant to use OP_BUYSTOP/OP_SELLSTOP in an OrderSend properly? Can someone give me a working sample code? I'd like to see the parameters. and what is the real meaning of 4109?
By the way, I set the slippage = 3, and there is enough gap for the StopLoss.
Thanks in advance.
search the forums for "Trade not allowed" and related terms.
The MT4 client only allows one thread at a time to communicate with the server. So if you have 2 ea's going at once and they both trigger orders at the same instant, only one will get through. That is why you use the IsTradeAllowed(). That way if the thread isn't open for that particular script eventhough the conditions for order execution are present, the execution code wont run and it should (theoretically) just wait until the next tick. (i.e. call of the start() )
The MT4 client only allows one thread at a time to communicate with the server. So if you have 2 ea's going at once and they both trigger orders at the same instant, only one will get through. That is why you use the IsTradeAllowed(). That way if the thread isn't open for that particular script eventhough the conditions for order execution are present, the execution code wont run and it should (theoretically) just wait until the next tick. (i.e. call of the start() )
I think I've found the answer, but I'd also like to register a possible bug. I use MT4 build 186.
Slawa, can you confirm this.
1. Whenever I use OP_BUYSTOP/OP_SELLSTOP command that works on Expert Advisors, it won't work on straight script. I will always get 4109 (Trade not allowed).
2. Whenever I use OP_BUYSTOP/OP_SELLSTOP command where the price has more decimal places, I would get 4107 (Price Invalid). Is that correct? So for example, EURUSD price of "1.16925750" must be rounded off FOUR decimal places to "1.1693".
Thank you all, thank you GT!
Slawa, can you confirm this.
1. Whenever I use OP_BUYSTOP/OP_SELLSTOP command that works on Expert Advisors, it won't work on straight script. I will always get 4109 (Trade not allowed).
2. Whenever I use OP_BUYSTOP/OP_SELLSTOP command where the price has more decimal places, I would get 4107 (Price Invalid). Is that correct? So for example, EURUSD price of "1.16925750" must be rounded off FOUR decimal places to "1.1693".
Thank you all, thank you GT!
Forex Trader:
Error 4109 is ERR_TRADE_NOT_ALLOWED.
Use something like this,
thanks so much
Error 4109 is ERR_TRADE_NOT_ALLOWED.
Use something like this,
Bwalya Tambule:
thanks so much
thanks so much
You are in the top diggers. Answering a 12 years topic to say thanks ! You should be really happy :-)
Forum on trading, automated trading systems and testing trading strategies
EA: Can you detect Live Status?
Alain Verleyen, 2017.02.07 21:24
11 years old, you beat them all.You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I have a problem with issuing OP_SELLSTOP/OP_BUYSTOP.
I issued:
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 it with
Now, I get "OrderSend BUYSTOP failed with error #4109"
Funnily enough, I had a period when the first code above actually worked last week. Does anyone have any idea?
Thanks.