Announcement

Collapse
No announcement yet.

How to limit drawTextRelative to 2 digits behind dec point

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

  • How to limit drawTextRelative to 2 digits behind dec point

    Hi,

    When I take the high(x) or the low(x) of the GB future I get sometimes a value in my EFS script which looks like: 112.700000000000001 instead of 112.7. Since I make use of the drawTextRelative function it looks of course awfull.

    1.Is there a way to limit the output of the drawTextRelative function to two digits behind the decimal point.

    2. Why does this happen and if the efs script calculates with these values what happens? fe If the script substracts a number from this odd number?

    Thanks,

    RH

  • #2
    In answer to your question 1, use something like . . . .

    var highval = high();
    drawTextRelative( xvalue, yvalue, highval.toFixed(2), etc etc);

    I don't think you can add .toFixed(2) directly to high() because it gets confused with the brackets!

    Hope this helps

    rgds, Maurice

    Comment


    • #3
      RH
      In addition to the solution proposed by Maurice you can use the formatPriceNumber() function ie. formatPriceNumber(high())
      Alex

      Comment


      • #4
        Thanks for the quick response!,

        RH

        Comment

        Working...
        X