
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
Hello! I have an issue with my ModifyOrder function.
I believe it is something to do with the calculation of digits for SL/TP...for All fx currency works, for XAU,XAG works, for XTI XNG doesn't not work .For XTI is opening the order but then ModifyOrder comes with error and order is left without SL/TP, and for XNG the same. But for all JPY pairs works :
2021.11.11 23:04:37.173 TEST 3 VRT-2 XTIUSD,Daily: open #188694311 sell 0.04 XTIUSD at 80.15 ok
2021.11.11 23:04:37.173 TEST 3 VRT-2 XTIUSD,Daily: invalid takeprofit for OrderModify function
2021.11.11 23:04:37.173 TEST 3 VRT-2 XTIUSD,Daily: Alert: Modify order #188694311: Error 4051 - invalid function parameter value
2021.11.11 23:04:37.173 TEST 3 VRT-2 XTIUSD,Daily: Price: 0.0, SL: 85.14, TP: -19.85, Expiration: 1970.01.01 00:00:00
2021.11.11 23:00:05.761 TEST 3 VRT-2 XNGUSD,Daily: open #188692649 sell 0.10 XNGUSD at 5.200 ok
2021.11.11 23:00:05.761 TEST 3 VRT-2 XNGUSD,Daily: invalid takeprofit for OrderModify function
2021.11.11 23:00:05.761 TEST 3 VRT-2 XNGUSD,Daily: Alert: Modify order #188692649: Error 4051 - invalid function parameter value
2021.11.11 23:00:05.761 TEST 3 VRT-2 XNGUSD,Daily: Price: 0.0, SL: 5.999, TP: -4.8, Expiration: 1970.01.01 00:00:00
Below is my code
And then OrderModify:
stoploss will be 0.7302000000000001 if I put on CADCHF
127.447 on EURJPY
But if I put like this
stoploss will be 0.7302 if I put on CADCHF
127.447 on EURJPY
Why _Digits is giving so many digits on CADCHF . Because it looks like Normalizing is not working with _Digits
Floating-point has an infinite number of decimals, it's you, not understanding floating-point and that some numbers can't be represented exactly. (like 1/10.)
Double-precision floating-point format - Wikipedia
See also The == operand. - MQL4 programming forum (2013)
If you want to see the correct number of digits, convert it to a string with the correct/wanted accuracy.
question about decima of marketinfo() - MQL4 programming forum (2016)
You used NormalizeDouble, It's use is usually wrong, as it is in your case.
Floating point has a 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
See also The == operand. - MQL4 programming forum (2013)
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 non-currencies.
On 5Digit Broker Stops are only allowed to be placed on full pip values. How to find out in mql? - MQL4 programming forum (2011)
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 (2012)
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 non-currencies. So do it right.
Trailing Bar Entry EA - MQL4 programming forum (2013)
Bid/Ask: (No Need) to use NormalizeDouble in OrderSend - MQL4 programming forum (2012)
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. (2013)
MathRound() and NormalizeDouble() are rounding in a different way. Make it explicit.
MT4:NormalizeDouble - MQL5 programming forum (2017)
How to Normalize - Expert Advisors and Automated Trading - MQL5 programming forum (2017)
Prices you get from the terminal are already correct (normalized).
PIP, Point, or Tick are all different in general.
What is a TICK? - MQL4 programming forum (2014)