Curious - can someone explain this?

 

I'm looking into importing data from tickstory into MT5. I noticed that the OHLC data in the tickstory datafile is specified to 3 digits and the symbol specification in MT5 is 1 digit. When importing the data MT5 appears to round the data to 1 digit. I wanted to check that this rounding was being performed correctly so I pre-processed the tickstory csv data by rounding the OHLC myself then loaded this into MT5. Everything else was exactly the same. I then ran them back to back and to see whether the equity curves were identical and found they weren't.  This is what I got:

Rounding comparison


They start off identical and then something happens. I investigated further and found that although the bars were reading the same the Bollinger Band indicator values were very slightly different causing (see images) an additional trade to trigger and hence the difference in curves.



Now the only thing I can think of to explain the difference is that the indicator is using the raw values that I imported into the custom symbol. Does anyone know if this is what is going? Or maybe something I've missed?


Cheers

E

 
EdFuk: I'm looking into importing data from tickstory into MT5. I noticed that the OHLC data in the tickstory datafile is specified to 3 digits and the symbol specification in MT5 is 1 digit. When importing the data MT5 appears to round the data to 1 digit. I wanted to check that this rounding was being performed correctly so I pre-processed the tickstory csv data by rounding the OHLC myself then loaded this into MT5. Everything else was exactly the same. I then ran them back to back and to see whether the equity curves were identical and found they weren't.  This is what I got: They start off identical and then something happens. I investigated further and found that although the bars were reading the same the Bollinger Band indicator values were very slightly different causing (see images) an additional trade to trigger and hence the difference in curves. Now the only thing I can think of to explain the difference is that the indicator is using the raw values that I imported into the custom symbol. Does anyone know if this is what is going? Or maybe something I've missed?
  1. If you want the CustomSymbol to use 3 digits instead of 1, then set its contract specification to use 3 digits instead of 1 (point size of 0.001 instead of 0.1).
  2. Even though visually the two values seem to be the same when displayed to 1 digit, the actual values stored in double precision floating point, may not actually be the same.
    13933.100 or 13933.101 or 13933.110, will all apear as 13933.1 when only displaying 1 digit.
    FYI: 13933.1 would be stored as 13933.1000000000003637978807092 in a "double".
  3. Yes, your suspicion is correct regarding the fact that the indicator is using the "raw" values stored in double precision floating point which you imported as such.

EDIT: It is unfortunate, that MetaQuotes and several other retail trading platforms, decided to use floating point data-type to store price quotes. The correct way, as used by high-end financial software, is to use fixed point or binary coded decimal instead. Even the oldest of financial based languages like COBOL did that.

     
    Fernando Carreiro #:
    1. If you want the CustomSymbol to use 3 digits instead of 1, then set its contract specification to use 3 digits instead of 1 (point size of 0.001 instead of 0.1).
    2. Even though visually the two values seem to be the same when displayed to 1 digit, the actual values stored in double precision floating point, may not actually be the same.
      13933.100 or 13933.101 or 13933.110, will all apear as 13933.1 when only displaying 1 digit.
      FYI: 13933.1 would be stored as 13933.1000000000003637978807092 in a "double".
    3. Yes, your suspicion is correct regarding the fact that the indicator is using the "raw" values stored in double precision floating point which you imported as such.

    EDIT: It is unfortunate, that MetaQuotes and several other retail trading platforms, decided to use floating point data-type to store price quotes. The correct way, as used by high-end financial software, is to use fixed point or binary coded decimal instead. Even the oldest of financial based languages like COBOL did that.

      Thanks Fernando

       

      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)

       
      William Roeder #:

      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)

      OK, so the question is why are they using floating point data types for the values?


      I also think the reason for the difference in the equity curves is caused by the fact the indicators are using the raw data and not the rounded. It's not directly as a result of the anything to do with the storage of the floating point numbers it's the way MT5 uses it.

       
      EdFuk #: OK, so the question is why are they using floating point data types for the values?

      Because that is how MetaTrader deals with quote price data. It is all in double precision floating point.

      EdFuk #: I also think the reason for the difference in the equity curves is caused by the fact the indicators are using the raw data and not the rounded. It's not directly as a result of the anything to do with the storage of the floating point numbers it's the way MT5 uses it.

      I've already explain the issue to you in my previous post #1.

       
      Thanks for the input everyone, appreciated.
       
      EdFuk #: Thanks for the input everyone, appreciated.
      You are welcome!
       
      Comments that do not relate to this topic, have been moved to "Off Topic Posts".
      Reason: