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
yes
and it was for your question below
STP=30 and TKP=20 both greater than zero " 0 ".
this Some times works and sometimes gives back Code10016 Invalid Stops
2020.05.14 16:43:17.106 2020.03.16 00:00:01 failed market sell 1.00 GBPUSD sl: 1.22918 tp: 1.22893 [Invalid stops]
2020.05.14 16:43:17.107 2020.03.16 00:00:01 CTrade::OrderSend: market sell 1.00 GBPUSD sl: 1.22918 tp: 1.22893 [invalid stops]
2020.05.14 16:43:17.819 2020.03.16 00:00:01 Sell() failed. Return code=10016. Code description: invalid stopsAt Price:1.22903000
2020.05.14 16:43:18.320 2020.03.16 00:00:01 FAIL Sell 1.22893 ---(0.00010)-----[1.22903]-----(0.00015)---1.22918
this Some times works and sometimes gives back Code10016 Invalid Stops
2020.05.14 16:43:17.106 2020.03.16 00:00:01 failed market sell 1.00 GBPUSD sl: 1.22918 tp: 1.22893 [Invalid stops]
2020.05.14 16:43:17.107 2020.03.16 00:00:01 CTrade::OrderSend: market sell 1.00 GBPUSD sl: 1.22918 tp: 1.22893 [invalid stops]
2020.05.14 16:43:17.819 2020.03.16 00:00:01 Sell() failed. Return code=10016. Code description: invalid stopsAt Price:1.22903000
2020.05.14 16:43:18.320 2020.03.16 00:00:01 FAIL Sell 1.22893 ---(0.00010)-----[1.22903]-----(0.00015)---1.22918
Thanks for your advice but I need more help on it
Here it is how I call my Sell anf Buy Functions.
I will be thankful if you explain a little bit more( I am really new in MQL)
Thanks for your advice but I need more help on it
Here it is how I call my Sell anf Buy Functions.
I will be thankful if you explain a little bit more( I am really new in MQL)
Thank You very Much
It Solved My Problem in many positions but Why still have messages like this
Thanks, Thanks.
Excuse me for wasting your time.
I find out
the problem was a calculation problem with difference between bid and ask or Spread
spread_Points must not bigger than Stopless and Takeprofit When the position wants to open.
Chris70:
For the sell order the take profit needs to be lower then the current price, but of course it still needs to be a positive number. According to your screenshot the requested take profit is -9.36716, which is no valid price.
There is nothing wrong with the calculation, because if you go from a price of 0.63284 down by an extreme distance such as ten thousand pips, you get a negative result: -9.36716 is the correct result in your example, but in real life, the price of a currency pair can't be negative. Try a much smaller number for TKP.
About the question regarding the result of SymbolInfoInteger(_Symbol,SYMBOL_TRADE_STOPS_LEVEL) : with many brokers there is a minimum distance between the current price and a requested trigger price of stop loss, take profit, stop buy order or stop sell order. Apparently, as you don't have low numbers for STP and TKP, this wasn't the problem in your case. But just keep in mind for the future that sometimes - depending on your broker and the symbol, a very low value for the distance in points (=your STP and TKP) can also sometimes cause errors. For example with my broker, I can't request a stop distance of less than 40 points for EURUSD or less than 52 points for GBPJPY... it may be different with your broker, just be aware that this problem sometimes exists --> that is what the SYMBOL_TRADE_STOPS_LEVEL is for: it tells you which minimum distance exactly won't cause trouble (and if it's zero: you can forget about it).I find out
the problem was a calculation problem with difference between bid and ask or Spread
spread_Points must not bigger than Stopless and Takeprofit When the position wants to open.
Chris70:
For the sell order the take profit needs to be lower then the current price, but of course it still needs to be a positive number. According to your screenshot the requested take profit is -9.36716, which is no valid price.
There is nothing wrong with the calculation, because if you go from a price of 0.63284 down by an extreme distance such as ten thousand pips, you get a negative result: -9.36716 is the correct result in your example, but in real life, the price of a currency pair can't be negative. Try a much smaller number for TKP.
About the question regarding the result of SymbolInfoInteger(_Symbol,SYMBOL_TRADE_STOPS_LEVEL) : with many brokers there is a minimum distance between the current price and a requested trigger price of stop loss, take profit, stop buy order or stop sell order. Apparently, as you don't have low numbers for STP and TKP, this wasn't the problem in your case. But just keep in mind for the future that sometimes - depending on your broker and the symbol, a very low value for the distance in points (=your STP and TKP) can also sometimes cause errors. For example with my broker, I can't request a stop distance of less than 40 points for EURUSD or less than 52 points for GBPJPY... it may be different with your broker, just be aware that this problem sometimes exists --> that is what the SYMBOL_TRADE_STOPS_LEVEL is for: it tells you which minimum distance exactly won't cause trouble (and if it's zero: you can forget about it).https://www.mql5.com/en/forum/326731
Conclusion:
When (Spread Transformed to point )> StopLoss , ( Invalid stops Error code=10016 )will generate.
so Simply we can use the following code to avoid of it .
Still wrong; when Spread > Stoploss, your code is trying to put the SL between Ask and Buy. You buy at the Ask and sell at the Bid.
MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25
Most brokers with variable spread widen considerably at end of day (5 PM ET) ± 30 minutes. My GBPJPY (OANDA) shows average spread = 26 points, but average maximum spread = 134.
Still wrong; when Spread > Stoploss, your code is trying to put the SL between Ask and Buy. You buy at the Ask and sell at the Bid.
MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25
Most brokers with variable spread widen considerably at end of day (5 PM ET) ± 30 minutes. My GBPJPY (OANDA) shows average spread = 26 points, but average maximum spread = 134.
Thanks a lot For this Detailed advice, Thanks again for time you take, I need read it several times to understand it completely.