MT4 OrderSend Error 4107 is a so-called MQL4 run-time error that is similar to OrderSend Error 129 but, unlike the latter, appears only during backtesting of the MT4 expert advisors, not during their live or demo run. The error is called ERR_INVALID_PRICE_PARAM (Invalid price) in the MT4 documentation; it has no counterpart in MT5. There are two main reasons for this 4107 error to appear:
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, ...);
Wish you can slove this question.