I managed t produce some error info but doesn'T makle things clearer:
as the screen shot shows the ResultRetcode() is 10016 ( TRADE_RETCODE_INVALID_STOPS ) and the messae box prints the values that have been used.
To me this looks like valid stops for a SELL market order:
entry price at ~ 51000
SL ~ 61000
TP: 24696
still the modify call returns false and return code is 10016
Files:
Enable both Ask and Bid prices in the chart settings.
Vladimir Karputov:
Enable both Ask and Bid prices in the chart settings.
Enable both Ask and Bid prices in the chart settings.
Are you refering to the Bid/Ask price lines? They both are activated and showing. Just so close you cannot see clearly on the screen shot.
Is your idea that the spread is so wide that either TP or SL are invalid? That's not the case. I made an extreme example to make sure.
Vladimir Karputov:
Enable both Ask and Bid prices in the chart settings.
is it possible that there is a limit for SL/TP? Some max distance?
Enable both Ask and Bid prices in the chart settings.
thanks for the forward,. I will check.
![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
I'm experiencing a very strange behaviour on MT5 with
trade.PositionModify() calls.
I have an EA that automatically sets SL and TP for every new order, no matter whether stoplimit(= order) or market order(= position).
The strange thing is, it works fine for 3 times or so, sometimes only once, then on the next trade SL and TP are very much smaller, allthough same calculation and
almmost same SL/TP as price may have moved a little bit in between.
the smaller value, when this error occuirs, seems to be always the same, as if some default was used but IM a tno point providing such default.
There is no error thrown. The call itself returns true and when I read the ResultRetcode() it always gives me 10009 which is TRADE_RETCODE_DONE.
as you can see on the screen shot and the order list below from 5 orders 4 have been modified correctly but the one selected has different SL/TP values.
This happens totally out of any pattern. Sometimes after some correctly modifed trades sometimes right on the first one.
I do print our SL and TPs right before the modification and they are always correct.
I already chased the thing through the debugger but was not able to reproduce the error for a single time.
following he relevant code:
following the code that invokes the code above