Announcement

Collapse
No announcement yet.

Limit Decimal Points

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

  • Limit Decimal Points

    Can someone show a newcomer how to limit the number of decimal points the following script will display? This script just displays the bar range but, as written, I'm getting about 10 decimal places in the display.. Thanks

    function preMain() {
    setPriceStudy(true);
    setStudyTitle("h-l");
    setCursorLabelName("h-l", 0);
    setDefaultBarStyle(PS_SOLID, 0);
    setDefaultBarFgColor(Color.red, 0);
    setDefaultBarThickness(1, 0);
    setPlotType(PLOTTYPE_LINE, 0);
    }

    function main() {
    return high()-low()+"";
    }

  • #2
    jgc711
    Replace high()-low()+"" with (high(0)-low(0)).toFixed(n) where n is the number of decimals you wish to see
    For information on the toFixed() method see this article in the EFS KnowledgeBase
    Alex


    Originally posted by jgc711 View Post
    Can someone show a newcomer how to limit the number of decimal points the following script will display? This script just displays the bar range but, as written, I'm getting about 10 decimal places in the display.. Thanks

    function preMain() {
    setPriceStudy(true);
    setStudyTitle("h-l");
    setCursorLabelName("h-l", 0);
    setDefaultBarStyle(PS_SOLID, 0);
    setDefaultBarFgColor(Color.red, 0);
    setDefaultBarThickness(1, 0);
    setPlotType(PLOTTYPE_LINE, 0);
    }

    function main() {
    return high()-low()+"";
    }

    Comment


    • #3
      Thanks so much for your help.

      Comment


      • #4
        jgc711
        You are most welcome
        Alex


        Originally posted by jgc711 View Post
        Thanks so much for your help.

        Comment

        Working...
        X