MT4: OrderSend error 4107 during back-test

Report any bugs with the Tickstory Lite software here. Please give as much detail as possible so the issue can be identified and resolved as soon as possible.
Post Reply
admin
Site Admin
Posts: 99
Joined: Thu Jul 19, 2012 9:17 am

MT4: OrderSend error 4107 during back-test

Post by admin »

When back-testing on a 4-digit Metatrader 4 terminal, users could encounter the following error:
OrderSend error 4107
Error opening BUYSTOP order []: (4107) invalid price parameter for trade function
invalid price 1.28236000 for OrderSend function
You can resolve the issue by either:

- Modifying your MQ4 mode (if you have access to it). You will need to amend all the "OrderSend" and "OrderModify" commands so they adjust your prices to 4-digits. You can do this by wrapping all prices in the function "NormalizeDouble(price, Digits)". For example, if the code reads like the following:

Code: Select all

   ticket=OrderSend(Symbol(),OP_BUY, lots, Ask, slip, stoploss, takeprofit, EA, MagicNo, 0, Blue);

you will need to change it to:

Code: Select all

   ticket=OrderSend(Symbol(),OP_BUY, lots, NormalizeDouble(Ask, Digits), slip, stoploss, takeprofit, EA, MagicNo, 0, Blue);

- If you do not have the code, you can instead utilise a 5-Digit MT4 terminal to back-test your strategy.

If either option is not viable, an enhancement is planned for the next version of Tickstory to ensure prices are rounded for 4-digit brokers.

Regards.

Post Reply