I dont understand the whole invalid stops thing.
This is my code and output. Im using a multiplier of ATR added or deducted to ASK.
2020.06.10 05:44:23.251 2020.05.01 11:51:40 <------------->
2020.06.10 05:44:23.251 2020.05.01 11:51:40 TESTY ATR_OUTPUT: 16.0
2020.06.10 05:44:23.251 2020.05.01 11:51:40 ASK: 19580.0
2020.06.10 05:44:23.251 2020.05.01 11:51:40 tp: 112.0
2020.06.10 05:44:23.251 2020.05.01 11:51:40 SL: 64.0
2020.06.10 05:44:23.251 2020.05.01 11:51:40 full tp: 19692.0
2020.06.10 05:44:23.251 2020.05.01 11:51:40 full SL: 19516.0
2020.06.10 05:44:23.251 2020.05.01 11:51:40 <------------->
2020.06.10 05:44:23.495 2020.05.01 11:51:40 failed market buy 0.01 @MJNK sl: 19516 tp: 19692 [Invalid stops]
2020.06.10 05:44:23.495 2020.05.01 11:51:40 CTrade::OrderSend: market buy 0.01 @MJNK sl: 19516 tp: 19692 [invalid stops]
Hi, or wrong values for tp sl or....have you checked stop levels?
Use MT function to discover how much is stop levels and check if the condition is satisfied. Broker requires Sl and TP must be distant of n points by current price.
Hi, or wrong values for tp sl or....have you checked stop levels?
Use MT function to discover how much is stop levels and check if the condition is satisfied. Broker requires Sl and TP must be distant of n points by current price.
I got it working by hardcoding a multiple value of 5 that I got from SPREAD. Although its probably coincidence it worked and Im still not sure how to do it dynamically. Its a shame the MQL5 docs dont seem to have examples. Plus a lot of example on this forum or elsewhere seem wrong.
Thanks much for the reply. :)
I got it working by hardcoding a multiple value of 5 that I got from SPREAD. Although its probably coincidence it worked and Im still not sure how to do it dynamically. Its a shame the MQL5 docs dont seem to have examples. Plus a lot of example on this forum or elsewhere seem wrong.
- Floating point has infinite number of decimals, it's your not understanding floating point and that some numbers can't be represented exactly. (like 1/10.)
Double-precision floating-point format - Wikipedia, the free encyclopedia - Print out your values to the precision you want with DoubleToString - Conversion Functions - MQL4 Reference.
- SL/TP (stops) need to be normalized to tick size (not Point) — code fails on metals. (On 5Digit Broker Stops are only allowed to be placed on full pip values. How to find out in mql? - MQL4 programming forum) and abide by the limits Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial and that requires understanding floating point equality Can price != price ? - MQL4 programming forum
- Open price for pending orders need to be adjusted. On Currencies, Point == TickSize, so you will get the same answer, but it won't work on Metals. So do it right: Trailing Bar Entry EA - MQL4 programming forum or Bid/Ask: (No Need) to use NormalizeDouble in OrderSend - MQL4 programming forum
- Lot size must also be adjusted to a multiple of LotStep and check against min and max. If that is not a power of 1/10 then NormalizeDouble is wrong. Do it right.
- MathRound() and NormalizeDouble() are rounding in a different way. Make it explicit.
MT4:NormalizeDouble - MQL5 programming forum
How to Normalize - Expert Advisors and Automated Trading - MQL5 programming forum - Prices you get from the terminal are already normalized.
- PIP, Point, or Tick are all different in general.
What is a TICK? - MQL4 programming forum

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I dont understand the whole invalid stops thing.
This is my code and output. Im using a multiplier of ATR added or deducted to ASK.
2020.06.10 05:44:23.251 2020.05.01 11:51:40 <------------->
2020.06.10 05:44:23.251 2020.05.01 11:51:40 TESTY ATR_OUTPUT: 16.0
2020.06.10 05:44:23.251 2020.05.01 11:51:40 ASK: 19580.0
2020.06.10 05:44:23.251 2020.05.01 11:51:40 tp: 112.0
2020.06.10 05:44:23.251 2020.05.01 11:51:40 SL: 64.0
2020.06.10 05:44:23.251 2020.05.01 11:51:40 full tp: 19692.0
2020.06.10 05:44:23.251 2020.05.01 11:51:40 full SL: 19516.0
2020.06.10 05:44:23.251 2020.05.01 11:51:40 <------------->
2020.06.10 05:44:23.495 2020.05.01 11:51:40 failed market buy 0.01 @MJNK sl: 19516 tp: 19692 [Invalid stops]
2020.06.10 05:44:23.495 2020.05.01 11:51:40 CTrade::OrderSend: market buy 0.01 @MJNK sl: 19516 tp: 19692 [invalid stops]