Announcement

Collapse
No announcement yet.

How to MA of a Custom efs

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

  • How to MA of a Custom efs

    How can I generate MA of a custome EFS file. Any idea. Can'tfind it anywhere

  • #2
    aladin31
    Enclosed below is an example of how to create an MA. Comments in the efs show you where to insert the code for your study and how to reference it
    Alex


    PHP Code:
    function preMain() {
        
        
    setPriceStudy(true);
        
    setStudyTitle("MA sample");
        
    setCursorLabelName("MA sample"0);
        
    setDefaultBarStyle(PS_SOLID0);
        
    setDefaultBarFgColor(Color.blue0);
        
        var 
    fp1 = new FunctionParameter("Length"FunctionParameter.NUMBER);
        
    fp1.setName("Length");
        
    fp1.setLowerLimit(1);
        
    fp1.setDefault(10);
    }

    var 
    aValue null

    function 
    main(Length) {

        
    //insert the code for the custom study here
           
        
    var vPlot close(0);//replace close(0) with the return of the custom study
        
        
    if (aValue == null) {
            
    aValue = new Array(Length);
        }
        if (
    getBarState() == BARSTATE_NEWBAR) {
            
    aValue.pop();  
            
    aValue.unshift(vPlot); 
        } else {
            
    aValue[0] = vPlot;
        }
        
        var 
    i=0;
        var 
    nSum 0;
        for (
    0Length; ++i) {
            
    nSum += aValue[i];
        }
        var 
    vSMA nSum/Length;
        

        return 
    vSMA;

    Comment


    • #3
      Alexis,
      Thanks for the code. However, I have been struggling to know what you mean by insert the code of custome study. Do U mean the entire efs program, or just the main part, or the name of the file.

      Could you please elaborate?

      Thanks again

      Comment


      • #4
        aladin31
        I mean all your code that is in main that is used to define your custom indicator.
        If your script has parts that are outside of main or are in preMain then you will need to insert those in the equivalent places in the code I provided.
        Alex

        Comment


        • #5
          Thanks

          Comment

          Working...
          X