Announcement

Collapse
No announcement yet.

close(0) Contains Floating Point in Bar Replay

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • close(0) Contains Floating Point in Bar Replay

    While in bar replay mode, close(0) becomes a floating point value. This occurs only in my CME currency markets (6E, 6C, 6S).

    While debugging my formula, I use debugPrint to see the value of close(0). If the chart is in real-time live market data, the value of close(0) is correct (no floating point) as in 6E of 1.4485. But if I enter Bar Replay Mode, almost every past closing value is now a floating pointing value: 1.44849999999999999.

    This discrepancy affects the logic in my formula when I want to compare the closing value to a different value; if the close is equal to the open. In real-time live data, the formula works correctly - they are equal. But once in bar replay or if I refresh the data, that condition is no longer true because the close is now floating point.

    Does anyone know why this happens? Is there an easy way to correct this?

    Thanks

  • #2
    Put this as a global variable:

    var vTick;

    Put this in your preMain()

    PHP Code:
    function preMain()
    {
      
    vTick getMinTick();  
      
    // if you use the $PLAYBACK symbol then use for 6E, 6C, 6S:
      // vTick = 0.0001;

    Put this at the bottom of your EFS:
    PHP Code:
    Number.prototype.round = function(tick)
    {
      return 
    Math.round(this tick) * tick;

    Example:
    PHP Code:
    var close(0).round(vTick); 
    Last edited by SteveH; 04-13-2011, 05:49 PM.

    Comment


    • #3
      Thank you Steve. I appreciate the suggestion.

      Comment

      Working...
      X