... add on ...
I just realized, if the price is too far in the positive area of the chart it throws as well an error: 10013 which is "invalid request" according to doc.
So I guess I need to limit possible SL/TPs to something like the price min/max of maybe the last 6 months or so.
![Documentation on MQL5: Constants, Enumerations and Structures / Codes of Errors and Warnings / Trade Server Return Codes Documentation on MQL5: Constants, Enumerations and Structures / Codes of Errors and Warnings / Trade Server Return Codes](https://c.mql5.com/36/46/documentation-on-mql5-constants__20.png)
Documentation on MQL5: Constants, Enumerations and Structures / Codes of Errors and Warnings / Trade Server Return Codes
- www.mql5.com
Trade Server Return Codes - Codes of Errors and Warnings - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
On MT5 I have an EA running on a BTCUSD chart.
When a new market or stoplimit order is opened by the user, the EA is supposed to automatically add SL and TP.
All good in general but on BTCUSD it may happen that when opening a sellstop or limitsell order that it's TP goes into the negtive price section of the chart.
and this always gives me a return code of 10016, which stands for invalid stops according to doc, and the modification of the order is not successful.
I added the caluclated SL and TP as horizontal lines to the order and they are technically correct. Both sit at the expected positions.
It seems it is actually the negative price that makes the SL or TP invalid. On MT4 this is no issue at all, just on MT5.
the code for the actual modification is standard and works fine as long as SL/TP are positive.
I tried afterwards to enter SL/TP manually for the order, through MT5's interface but there as well, a ngetive SL or TP is not allowed.
Sure, not so many charts have negative price areas. still ... is this a bug or am I missing something?