1
  double _high = iHigh(Symbol(), Period(), 0);
  double _low = iLow(Symbol(), Period(), 0);
  double result = _high - _low;

Excuse my limited English.

The type of result is a double number, and I want to convert the double number to an integer number, but the number of digits after the decimal point of the result corresponding to each symbol is uncertain.

I really don't know what to do other than doing it differently depending on the symbol.

user3666197
  • 1
  • 6
  • 50
  • 92
Abbotton
  • 201
  • 2
  • 3

2 Answers2

0

Q : "How to convert the value of iHigh() - iLow() to integer?
... doing it differently depending on the symbol.
"

A :
Yes, we need to do it differently, depending on each the symbol.

Something like this may be a way to handle this :

...
int iSymbolSpecificDIGITs = SymbolInfoInteger( Symbol(), /* here, or
                                          OrderSymbol(),          if looping OrderBook */
                                               SYMBOL_DIGITS
                                               );
...
int iHiLoDIFF = (int)( MathPow( 10, iSymbolSpecificDIGITs ) * _high )
              - (int)( MathPow( 10, iSymbolSpecificDIGITs ) * _low  );
user3666197
  • 1
  • 6
  • 50
  • 92
0

Main thing is to add NomalizeDouble to the result and add Digits in the bracket to sum everything up:

 Alert(NormalizeDouble(result,Digits));

Or 

Print("result:" + NormalizeDouble(result,Digits));
Tman
  • 1
  • 1
  • With all respect, an attempt to ***"add Digits"*** does not convert double into integer. If in doubts, given an instrument has _Digits == 5 and aPriceDomainVALUE == 1827.604 ... adding these is (a) still a double 1833.604 and (b) such a sum does not represent anything meaningful – user3666197 Mar 13 '22 at 14:35