OrderSend Error 4107 is a
- Negative values in price, stoploss or takeprofit parameters of the OrderSend() function. Just make sure you pass the valid price parameters to this function, they surely shouldn’t be negative.
- Unnormalized doubles in price, stoploss or takeprofit parameters of the OrderSend() function. If your Forex broker uses 4 digits after the dot in quotes and you are trying to use 5 digits in your orders, then you’ll be getting error 4107 during backtesting. The best solution here is to always normalize all the price doubles using the standard MetaTrader function before passing them to OrderSend():
OpenPrice = NormalizeDouble(OpenPrice, Digits); StopLossPrice = NormalizeDouble(StopLossPrice, Digits); TakeProfitPrice = NormalizeDouble(TakeProfitPrice, Digits); OrderSend(Symbol(), OP_BUY, 1, OpenPrice, StopLossPrice, TakeProfitPrice, ...);
If you have your own ideas for dealing with MT4 Error 4107 or have some questions about it, feel free to reply to this post using the form below.
please i have this error message in demo trade not back testing what can i do to solve the problem. thanks
▼Reply
admin Reply:
September 6th, 2012 at 1:18 pm
Demo trading using expert advisor, right? Make sure it uses positive normalized values for open price, stop-loss and take-profit levels in its OrderSend() calls.
▼Reply
I wrote a very simple script to send an buystop order to the server. Till now, the EA kept reporting error 4107 all the time.What is wrong with my code?
▼Reply
admin Reply:
August 7th, 2013 at 7:11 am
Do you get error 4107 on OrderModify()? Because this code has no OrderSend() calls.
▼Reply
Hello Admin,
I am in the middle of this problem. Could i have your email?
Best,
I am ofcourse gling to post my learnings here but don’t want to bother everybody with the whole string?
▼Reply
Andriy Moraru Reply:
August 22nd, 2014 at 2:17 pm
Upload it to Google Docs or Dropbox and post the link here if there is a lot of text to share.
▼Reply