Announcement

Collapse
No announcement yet.

More Decimal Places for Forex indicator

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

  • More Decimal Places for Forex indicator

    I am using a ATR indicator and would like to display more than the 2 decimal places that show up. The chart for the GBP shows up with 4 but my indicator only shows up with 2. How can I make this into 4 decimals for the indicator?
    PHP Code:
    var vATR null
    var 
    fpArray = new Array(); 

    function 
    preMain() { 

       var 
    x

       
    setStudyTitle("ATR Stop"); 
       
    setCursorLabelName("ATR Stop"0); 
       
    setDefaultBarFgColor(Color.blue0); 
       
    setPlotType(PLOTTYPE_LINE,0); 
       
    setDefaultBarThickness(2,0); 
             
       
    x=0
       
    fpArray[x] = new FunctionParameter("Length"FunctionParameter.NUMBER); 
       
    with(fpArray[x]){ 
          
    setLowerLimit(1);       
          
    setDefault(15); 
       } 
       
    x++; 
       
    fpArray[x] = new FunctionParameter("Symbol"FunctionParameter.NUMBER); 
       
    with(fpArray[x]){ 
          
    setDefault(""); 
       } 
       
    x++; 
       
    fpArray[x] = new FunctionParameter("Interval"FunctionParameter.NUMBER); 
       
    with(fpArray[x]){ 
          
    setDefault(""); 
       } 


    function 
    main(Length,Symbol,Interval) { 

       if(
    getBuildNumber()<689
          return; 

       if(
    Symbol==nullSymbol=getSymbol(); 
       if(
    Interval==nullInterval=getInterval(); 
       
    vSymbol=Symbol+","+Interval
        
       if (
    vATR == nullvATR atr(Length,sym(vSymbol)); 
      
    /******************************************** 
    Insert your code following this text block    
    Use vATR.getValue(0) for your code            
    *********************************************/ 

       
    return vATR.getValue(0); 


  • #2
    LJK
    At this time EFS does not allow to define the number of decimals displayed by a plot.
    You may want to submit a suggestion by sending an email to [email protected]
    In the mean time you have two work arounds available. The first one is to multiply the return by a constant (for example 1000). For the second you would do the following. Just above the return statement add the lines
    PHP Code:
    if(vATR.getValue(0)==null) return;
    var 
    adjustATR vATR.getValue(0).toFixed(4); 
    Then replace the return statement with the following
    PHP Code:
    return new Array (vATR.getValue(0),adjustATR); 
    The .toFixed() method converts a value to a string thereby allowing you to define the number of decimals. Although an efs will not plot a string it will return it to the Cursor Window. The drawback is that you will have a double display for the ATR in the Cursor Window
    Alex

    Comment

    Working...
    X