How to convert the price difference into a whole number? - page 3

 
Fernando Carreiro:

My example is with points!

please write it as a formula
 
Ivan Negreshniy: please write it as a formula

OHLC: 1.21031/ 1.21054 / 1.21029 / 1.21030 becomes 121031002399989999

  • Open (points): 121031 converted into unsigned 6 decimal value
  • High - Open (points): 121054 - 121031 = 23 is 0023 converted into signed 4 decimal value
  • Low - Open (points): 121029 - 121031 = -2 is 9998 converted into signed 4 decimal value
  • Close - Open (points): 121030 - 121031 = -1 is 9999 converted into signed 4 decimal value

Signed 4 decimal value (0-4999 positive, 5000-9999 negative, 9999 = -1, 9998 = -2, etc.)

Please note that this is just an example. You will have to experiment and find the ideal number of digits for the prices and the delta prices so as to fit into 64 bit long.

 
Fernando Carreiro:

OHLC: 1.21031/ 1.21054 / 1.21029 / 1.21030 becomes 121031002399989999

  • Open (points): 121031 converted into unsigned 6 decimal value
  • High - Open (points): 121054 - 121031 = 23 is 0023 converted into signed 4 decimal value
  • Low - Open (points): 121029 - 121031 = -2 is 9998 converted into signed 4 decimal value
  • Close - Open (points): 121030 - 121031 = -1 is 9999 converted into signed 4 decimal value

Signed 4 decimal value (0-4999 positive, 5000-9999 negative, 9999 = -1, 9998 = -2, etc.)

Please note that this is just an example. You will have to experiment and find the ideal number of digits for the prices and the delta prices so as to fit into 64 bit long.

Thank you, interesting solution, I will experiment ...
 
Ivan Negreshniy: Thank you, interesting solution, I will experiment ...

It is just a packed decimal which can then be converted into binary. It has been used by many people in many fields since early years of computing.

 
Fernando Carreiro:

It is just a packed decimal which can then be converted into binary. It has been used by many people in many fields since early years of computing.

I need the non-traditional packaging I mentioned before, trade importance of the bar (internal direction of price change) and the non sensitivity of the integral value to small price changes should be preserved as a result.

 
Ivan Negreshniy: I need the non-traditional packaging I mentioned before, trade importance of the bar (internal direction of price change) and the non sensitivity of the integral value to small price changes should be preserved as a result.

You will have to explain in more detail or with examples as I don't understand what you mean by "importance of bar" or "non sensitivity of the integral value to small price changes".

 

Fernando Carreiro:

You will have to explain in more detail or with examples as I don't understand what you mean by "importance of bar" or "non sensitivity of the integral value to small price changes".

Вам придется объяснять более подробно или с примерами, поскольку я не понимаю, что вы подразумеваете под «значением бар» или «нечувствительностью целочисленного значения к небольшим изменениям цен» .

Under the integral value of the bar I understand the packed value, in your example 121031002399989999 and under the insensitivity of this value, I understand that if the original prices change by 1-2 points, this will not affect to integral value.
 
Ivan Negreshniy:
Under the integral value of the bar I understand the packed value, in your example 121031002399989999 and under the insensitivity of this value, I understand that if the original prices change by 1-2 points, this will not affect to integral value.
OK understood! Then you just reduce it by removing least significant digits. For example, working in "pips" instead of "points"!
 
Fernando Carreiro:
OK understood! Then you just reduce it by removing least significant digits. For example, working in "pips" instead of "points"!
Yes, and to determine the direction of the bar, we can put in the first position (Close-Open)
 
Ivan Negreshniy:
Yes, and to determine the direction of the bar, we can put in the first position (Close-Open)
Yes, that is a solution. In that case you can simple use a the actual sign (+/-) of the whole value to determine the direction in a quick way.
Reason: