Announcement

Collapse
No announcement yet.

efs and decimal

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

  • efs and decimal

    Hi, I have this problem I can not solve: I created the indicator, which should replicate the ATR, he rounded the last decimal, while the eSignal not. How can I fix? I need decimals.


    Click image for larger version

Name:	Average True Range.png
Views:	1
Size:	55.6 KB
ID:	247025

    Code:
    function preMain() {
    setPriceStudy(false);
    setStudyTitle("Average True Range 2");
    setCursorLabelName("Average True Range 2", 0)
    setDefaultBarFgColor(Color.blue,0);
    
    }
    
    function main() {
    var xATR        = atr(15) ;
    var STPL        = xATR;
    
    debugPrintln(xATR); 
    return ( STPL );
    
    }
    Last edited by luca73; 02-05-2016, 11:13 AM.

  • #2
    luca73
    You can resolve it without the need of any coding. Set the Format you want (up to 6 decimals) in the Edit dialog for the study
    As an aside I am not sure why you create and then return another variable (ie STPL) just to assign to it xATR. You might as well just return xATR.
    Also to make the formula more efficient you should initialize the atr() study once only either at BARSTATE_ALLBARS or within an initialization routine of your choice. Search the forum and you will find many examples of this as the topic has been covered at length before
    Alex


    Originally posted by luca73 View Post
    Hi, I have this problem I can not solve: I created the indicator, which should replicate the ATR, he rounded the last decimal, while the eSignal not. How can I fix? I need decimals.


    [ATTACH=CONFIG]16824[/ATTACH]

    Code:
    function preMain() {
    setPriceStudy(false);
    setStudyTitle("Average True Range 2");
    setCursorLabelName("Average True Range 2", 0)
    setDefaultBarFgColor(Color.blue,0);
    
    }
    
    function main() {
    var xATR        = atr(15) ;
    var STPL        = xATR;
    
    debugPrintln(xATR); 
    return ( STPL );
    
    }

    Comment


    • #3
      Thank you so much for your help, you're very kind

      Comment


      • #4
        luca73
        You are welcome
        Alex


        Originally posted by luca73 View Post
        Thank you so much for your help, you're very kind

        Comment

        Working...
        X