Your lots must be a multiple of lotStep and between min and max.
Ok, I can fix that with NormalizedDouble, buy how to close partially once at specified distance?
Metaquotes language: OrderComment() is not able to be modified - Futures Trading - Expert Advisors and Automated Trading - MQL5 programming forum
Not a good idea to use comments, brokers can change comments, including complete replacement.
- Changing your TP target.
- Check for SL at BE or better, and if not change it before the partial close.
As for NormalizeDouble, It's use is usually wrong, as it is in your case.
-
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.) (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 - General - MQL5 programming forum
How to Normalize - Expert Advisors and Automated Trading - MQL5 programming forum
Can't modify comments
Metaquotes language: OrderComment() is not able to be modified - Futures Trading - Expert Advisors and Automated Trading - MQL5 programming forum
Not a good idea to use comments, brokers can change comments, including complete replacement. That's easy, check if the market is at your "specified distance." The hard part is not doing it more than once — remembering that you already did the partial. Think:
- Changing your TP target.
- Check for SL at BE or better, and if not change it before the partial close.
As for NormalizeDouble, It's use is usually wrong, as it is in your case.
- 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.) (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 - General - MQL5 programming forum
How to Normalize - Expert Advisors and Automated Trading - MQL5 programming forum
But the case is that when you make a partial close manually in the MT terminal you can set any comment, and don't actually find the way to do it by MQL coding.
Then, changing TP target is not valid for this purpose from the point of partial close is taken from TP-OP distance, and TP is fixed.
Just realized that could be done by setting BE higher/lower tan OP, that could work. Thank you very much.
But still having the problema of keeping OrderComment() as defined at entry to keep an eye on stats.
- 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 think it's just posible to make it by using OrderComment or so, but no idea about how to do it.
This code close orders partially till exhausted:
Hope someone can help to fix this issue.