Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
Hi,
i need to use the OrderSend function (MQL4 language) in my EA to open some orders and i have the stop loss and the take profit value in two different string, instead the OrderSend receive them as double value.
So i use this syntax:
Unfortunatly, i always get the error 130, some errors with the stop loss and the take profit values.
I don't know why, i tried with the point and the comma character to insert the values (example 1.07637 and 1,07637).
If i run the same function by passing the parameters directly from the code it works:
Can anyone help me understanding why?
Thank you so much in advance
Christian
Hi, i tried to read something about this without success.
I'm a beginner with the EA and it's not very simple for me. I tried to stamp the variables value befor call the OrderSend with the Print functin but seems they are right (on the screen, i don't know if they are wrong then in the program variable).
I understood i need to use a value with 5 decimal digits (in the manually example above it works) but i didn't understand why the NormalizaDouble didn't work.
Christian
Hi, i tried to read something about this without success.
I'm a beginner with the EA and it's not very simple for me. I tried to stamp the variables value befor call the OrderSend with the Print functin but seems they are right (on the screen, i don't know if they are wrong then in the program variable).
I understood i need to use a value with 5 decimal digits (in the manually example above it works) but i didn't understand why the NormalizaDouble didn't work.
Christian
- 2022.01.09
- www.mql5.com
Hi, i tried to read all the article and made some tests:
my broker is a 5 digits broker and i verified that with
MarketInfo(order_params[0],MODE_TICKSIZE)
with the result 0,00001.
So i tried this sintax to open an order with OrderSend by adding the NormalizeDouble with 5 digits:
int order_result = OrderSend(order_params[0], order_params[1], StringToDouble(order_params[2]), order_params[3], slippage, NormalizeDouble(StringToDouble(order_params[4]),5), NormalizeDouble(StringToDouble(order_params[5]),5), );
I read (and i hope i understood correctly) i have to round the stop loss value according to the broker TICKSIZE, but in my case it is 0,00001 so it shouldn't be necessary.
Unfortunatly i get the same error 130 :(
What i didn't understand in your opinion? I think something happen during the conversion from string to double but i don't understand what...
Christian
NormalizeDouble(StringToDouble(order_params[4]),5), NormalizeDouble(StringToDouble(order_params[5]),5),
You used NormalizeDouble, It's use is usually wrong, as it is in your case.
-
Floating point has an infinite number of decimals, it's you were not understanding floating point and that some numbers can't be represented exactly. (like 1/10.)
Double-precision floating-point format - Wikipedia, the free encyclopediaSee 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 #10 (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.
(MT4 2013)) (MT5 2022)) -
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)
You used NormalizeDouble, It's use is usually wrong, as it is in your case.
-
Floating point has an infinite number of decimals, it's you were not understanding floating point and that some numbers can't be represented exactly. (like 1/10.)
Double-precision floating-point format - Wikipedia, the free encyclopediaSee 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 #10 (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.
(MT4 2013)) (MT5 2022)) -
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)
Maybe, (MAYBE), i solved the problem by reading your articles:
First i get the broker TICKSIZE and then i rounded the value with that:
double tickSize = MarketInfo(Symbol(), MODE_TICKSIZE); double stoploss = MathRound(StringToDouble(order_params[4])/tickSize)*tickSize;
Now, the OrderSend seems work! :)
Drop the double to string to stringToDouble or reread the links provided.
I didn't understand your suggestion, sorry!
I have the stop loss value as a string so i need to convert it as a double to make the other adjustments;
if i drop the stringtodouble command then the compiler will do an implicit conversion.
Did you refer to this?
Christian
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
i need to use the OrderSend function (MQL4 language) in my EA to open some orders and i have the stop loss and the take profit value in two different string, instead the OrderSend receive them as double value.
So i use this syntax:
Unfortunatly, i always get the error 130, some errors with the stop loss and the take profit values.
I don't know why, i tried with the point and the comma character to insert the values (example 1.07637 and 1,07637).
If i run the same function by passing the parameters directly from the code it works:
Can anyone help me understanding why?
Thank you so much in advance
Christian