| stevehopwoodforex.com https://www.stevehopwoodforex.com/phpBB3/ Print view |
|
| HELP WITH ERROR 4107 https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=2914 |
Page 1 of 18 |
| Author: | fx800 [ Mon Aug 05, 2013 5:41 pm ] |
| Post subject: | HELP WITH ERROR 4107 |
Firstly, my congratulations to Steve and Shelley for a very formidable ea, the Bob and Shelley again. I tried to modify the ea to enter by a pending order rather than buyopen/sellopen in order to avoid a premature entry like the one shown below. I am getting error 4107. Tried goggling for help without any success. Would appreciate any help from the brilliant coders in Steve's forum. Thanks in advance. peter |
|
| Author: | phil_trade [ Mon Aug 05, 2013 5:57 pm ] |
| Post subject: | Re: HELP WITH ERROR 4107 |
OrderSend Error 4107 (Backtesting) January 24, 2011 (Last updated on September 22, 2011) 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 Empty4 expert advisors, not during their live or demo run. The error is called ERR_INVALID_PRICE_PARAM (Invalid price) in the Empty4 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 Empty4 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, ...); |
|
| Author: | fx800 [ Mon Aug 05, 2013 6:15 pm ] |
| Post subject: | Re: HELP WITH ERROR 4107 |
Many thanks, Phil Trade. I have applied NormalizeDouble to takeprofit and stoploss and wait to see if it fixes the problem. peter |
|
| Author: | phil_trade [ Mon Aug 05, 2013 6:36 pm ] |
| Post subject: | Re: HELP WITH ERROR 4107 |
add a Print to see all prices ( Price/SL/TP and Bid) in journal so you can understand. |
|
| Author: | phil_trade [ Mon Aug 05, 2013 6:40 pm ] |
| Post subject: | Re: HELP WITH ERROR 4107 |
?? which lines of code did you modified to get Pending order ? |
|
| Author: | fx800 [ Mon Aug 05, 2013 6:46 pm ] |
| Post subject: | Re: HELP WITH ERROR 4107 |
I have added the functions Has Buy Filled and Has Sell Filled, and the Pending order code Code: Select all Code: Select all |
|
| Author: | fx800 [ Tue Aug 06, 2013 9:50 am ] |
| Post subject: | Re: HELP WITH ERROR 4107 |
Two more examples where a pending order a few pips above High[1] would have avoided a premature entry. |
|
| Author: | phil_trade [ Tue Aug 06, 2013 10:08 am ] |
| Post subject: | Re: HELP WITH ERROR 4107 |
the better way to debug is to add Lprint() with Bid/ Pending Price, SL ans TP to see why OrderSend is rejected |
|
| Author: | fx800 [ Tue Aug 06, 2013 11:09 am ] |
| Post subject: | Re: HELP WITH ERROR 4107 |
I am often puzzled why using the following BuyStop/SellStop code doesn't work. Can someone please explain. Thanks. Code: Select all Code: Select all |
|
| Author: | phil_trade [ Tue Aug 06, 2013 11:29 am ] |
| Post subject: | Re: HELP WITH ERROR 4107 |
what do you mean by "doesn't work" ? |
|
| All times are UTC | Page 1 of 18 |
|
Powered by phpBB® Forum Software © phpBB Limited |
|