Hi, i'm started to coding a few months ago, now that I've managed to do my own strategy, I want to automate it. My problem is that my strategy needs to get the price between the high and low but i want that difference in whole number,
not as 0.0000300, instead of 300.
At the moment my code get the difference between prices, but i have not managed to convert it in a whole number. If someone could guide me to any solution it will be well appreciated.
Btw i have some ideas but don't how to code them:
1.- Convert the price decimals to integer, eliminating the point.
2.- Convert the price by multiplying it for a number that depends on the decimals that has the pair in wich i'm working. The problem is that I would have to check for every pair the decimal places.
Hope someone could help me, and sorry for this horrible english.
Use the function or variable for the symbol's point size: https://www.mql5.com/en/docs/check/point
( High - Low ) / _Point;

- www.mql5.com
Use the function or variable for the symbol's point size: https://www.mql5.com/en/docs/check/point
int(round(( High - Low ) / _Point));
;)
;)
I purposely did not include the rounding or the typecasting and only the point conversion for a reason, as it is unclear what the OP will do with that afterwards.
For example, if he intends to use it for setting stops or opening prices for pending orders, then he would have to align it with the tick size.
That is why I did not include any extras, and only presented the answer for obtaining whole numbers as he requested.
I purposely did not include the rounding or the typecasting and only the point conversion for a reason, as it is unclear what the OP will do with that afterwards.
For example, if he intends to use it for setting stops or opening prices for pending orders, then he would have to align it with the tick size.
That is why I did not include any extras, and only presented the answer for obtaining whole numbers as he requested.
Perhaps from your experience, can also answer another question, such as determining(packing) in one digit the full integral characteristic of the bar(OHLC prices).
Given that there is no need to re-extract prices (unpacking), but the result is desirable to have a unique for each bar value, rounded which is not sensitive to the small differences in prices that we see in some forex brokers.
Perhaps from your experience, can also answer another question, such as determining(packing) in one digit the full integral characteristic of the bar(OHLC prices).
Given that there is no need to re-extract prices (unpacking), but the result is desirable to have a unique for each bar value, rounded which is not sensitive to the small differences in prices that we see in some forex brokers.
My apologies, but I don't understand your question. What do you mean by packing into one digit?
EDIT:
Are you perhaps trying to store the prices into a packed numerical space, like storing the OHLC prices into a 64-bit long integer?
If so, then you could condense the values by using point or tick values for the "Open", "delta High", "delta Low", "delta Close" and that should fit into a 64-bit Long integer!
The Open Price could be condensed into 20-24 bits and each of the delta values taking up 13-14 bits, resulting in a packed structure that could fit into a 64-bit Long Integer.
My apologies, but I don't understand your question. What do you mean by packing into one digit?
Sorry, but I still don't understand what you mean. I have reedited my previous post. Can you read it again and see if that is what you want?
Sorry, but I still don't understand what you mean. I have reedited my previous post. Can you read it again and see if that is what you want?
Sorry, but you seem to be using Google translate and all it is doing is creating complete confusion. I can't understand anything you are trying to communicate!
if High-Low = 0.0000300, he doesn't want a double 0.0000300 but he wants integer 300.

- 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'm started to coding a few months ago, now that I've managed to do my own strategy, I want to automate it. My problem is that my strategy needs to get the price between the high and low but i want that difference in whole number,
not as 0.0000300, instead of 300.
At the moment my code get the difference between prices, but i have not managed to convert it in a whole number. If someone could guide me to any solution it will be well appreciated.
Btw i have some ideas but don't how to code them:
1.- Convert the price decimals to integer, eliminating the point.
2.- Convert the price by multiplying it for a number that depends on the decimals that has the pair in wich i'm working. The problem is that I would have to check for every pair the decimal places.
Hope someone could help me, and sorry for this horrible english.