Announcement

Collapse
No announcement yet.

EFS questions by shaeffer

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

  • #46
    I've have an EFS, say Bobby.efs that I acquired on the net but it is locked. It is an oscillator in which I compare the current value (bob) and the (-1) value (bob1) as in previous efs discussions here.

    I've updated it per our recent discussions to make bob1 global and I've included the null checks. But as the series is created within Bobby.efs (i.e. it is not an eSignal series), I can't define a global series variable or null-check it. Assuming the Bobby.efs calcs are of equivalent complexity to a stochastic calc, will this efs be more likely to be a resource hog because I can't define its series globally? Or does the efsExternal() command define the series equally as well?

    Thanks
    shaeffer
    PHP Code:
    var bob1   null;

    function 
    main() {

      var 
    bob efsExternal"/My Formulas/Bobby.efs" );
       if (
    getBarState() == BARSTATE_NEWBAR) {
            
    bob1 bob.getValue(-1);
        }
        
        if (
    bob == null || bob1 == null) return; 
    ..........
    --------
    return 
    bob;

    Comment


    • #47
      Originally posted by Alexis C. Montenegro
      shaeffer
      In the for loop you do not need to use setBarBgColor() but only setDefaultBarBgColor()
      For the efs2 version of the Stochastic study you need to use both the stochK() and the stochD() functions
      Alex
      Your barBgColor suggestion makes sense, thanks Alex.

      After all your and Jason's help, I think I could fairly quickly add the two global variables to then define the two (Fast and Slow) stochastic series. Would it be an improvement though to the EFS1 method which requires only one series?

      Regards
      shaeffer

      Comment


      • #48
        shaeffer
        The efsExternal() function creates a series just as if it were one of the built-in study functions.
        For your script to work correctly you need to apply the same construct that Jason has shown you earlier in this thread and specifically in the last example in this post.
        The only differences will be in the naming of the variables which are going to be xBob, nBob and nBob1 (instead of xHist, nHist, nHist1) and in the line inside the bInit routine where you intialize xBob which will be
        PHP Code:
        if(bInit==false){
            
        xBob efsExternal("/myefs.efs");
            
        bInit=true;

        FYI you can find several complete and detailed examples on the use of the efsExternal() function in this and this thread
        Alex



        Originally posted by shaeffer
        I've have an EFS, say Bobby.efs that I acquired on the net but it is locked. It is an oscillator in which I compare the current value (bob) and the (-1) value (bob1) as in previous efs discussions here.

        I've updated it per our recent discussions to make bob1 global and I've included the null checks. But as the series is created within Bobby.efs (i.e. it is not an eSignal series), I can't define a global series variable or null-check it. Assuming the Bobby.efs calcs are of equivalent complexity to a stochastic calc, will this efs be more likely to be a resource hog because I can't define its series globally? Or does the efsExternal() command define the series equally as well?

        Thanks
        shaeffer
        PHP Code:
        var bob1   null;

        function 
        main() {

          var 
        bob efsExternal"/My Formulas/Bobby.efs" );
           if (
        getBarState() == BARSTATE_NEWBAR) {
                
        bob1 bob.getValue(-1);
            }
            
            if (
        bob == null || bob1 == null) return; 
        ..........
        --------
        return 
        bob;

        Comment


        • #49
          The previous suggestion to treat the external efs like a built in study worked great, thanks Alex.

          But when I tried to apply this efs in a 60 minute timeframe to a 15 minute chart, by inserting inv(60) in the efsExternal line below, I get an error message " Parameter Number 3 of Function getValue is invalid ".

          I tried using ....getValue(0, inv(60)) and getValue(-1, inv(60)), but still no luck.

          What is the correct way to load this external efs in a 60 minute timeframe for use in other than a 60 minute chart? Then, would the BARSTATE_NEWBAR command act on the 60 minute internal, or the chart interval?

          Thank you
          shaeffer

          PHP Code:
          var xBob   null;
          var 
          nBob1  null;
          var 
          bInit  false;

          function 
          main() {

              if(
          bInit==false){
                  
          xBob efsExternal("/My Formulas/Bobby.efs"inv(60));
                  
          bInit=true;
              }

              var 
          nBob xBob.getValue(0);  
              if (
          getBarState() == BARSTATE_NEWBAR) {
                  
          nBob1 xBob.getValue(-1); 
              }
              
              if (
          nBob == null || nBob1 == null) return; // 

          Comment


          • #50
            shaeffer
            At this time the efsExternal() function requires at least two parameters in order for the inv() function to control the context in which the external efs is running.
            The solution in your case is to add a parameter (for example 0) to use just as a placeholder in the efsExternal() call ie
            xBob = efsExternal("/My Formulas/Bobby.efs", 0, inv(60));
            Once you implement this change the called efs should run in the context of the interval that is being passed.to it.
            It is my understanding that this extra parameter (which is a remnant of the old efs() function) is not documented because it should no longer be required in one of the next releases

            Then, would the BARSTATE_NEWBAR command act on the 60 minute internal, or the chart interval?
            In this case getBarState() will run in the context of the main interval. Use getBarStateInterval() if you want it to run that section of code in the context of the external interval.
            Alex

            Comment


            • #51
              Hello Alex,

              I added the extra '0' parameter, and the efs will now load with no Formula Output errors, but all that appears is:
              1. Study Title,
              2. Brown background

              But to get the Brown background, I have to '//' out the null check line, otherwise just the black default Background (pre preMain()) appears.

              With the null check commented out, it seems that the 4th condition (nJag < 10) is being seen continuously (hence the brown background). I suspect nJag is getting a null result from the efsExternal call. But if I remove the ...,0,inv(60) from the efsExternal line and allow the null check, it works fine.

              So somehow the efsExternal..inv(60) line is still not working, Or have I done something else wrong?

              Thank you
              shaeffer

              PHP Code:
              function preMain() {
                  
              setStudyTitle("JagC-60");
                  
              setShowTitleParametersfalse );
                  
              setShowCursorLabel(false);
                  
              setDefaultBarStyle(PS_SOLID);
                  
              setDefaultBarFgColor(Color.RGB(255,100,30));  // orange
                  
              setDefaultBarThickness(2);
                  
              setPlotType(PLOTTYPE_LINE);
                  
              setDefaultChartBG(Color.black);
              }
              var 
              color0 Color.white;
              var 
              color1 Color.cyan;
              var 
              xJag   null;
              var 
              nJag1   null;
              var 
              bInit  false;

              function 
              main() {

              color1 color0;

                  if(
              bInit==false){
                      
              xJag efsExternal("/My Formulas/JagC.efs",0,inv(60));
                      
              //xJag = efsExternal("/My Formulas/JagC.efs");
                      
              bInit=true;
                  }

                  var 
              nJag xJag.getValue(0);  
                  if (
              getBarState() == BARSTATE_NEWBAR) {
                      
              nJag1 xJag.getValue(-1); // retrieve the previous bar's closing number from the xJag series.
                  
              }
                  
              //   if (nJag == null || nJag1 == null) return; // validate your variables before processing conditions   
                  

                  
              if(nJag 90  &&  nJag1 >= 90  ){                     //Crossed Down thru 90
                      
              color0 Color.RGB(140,13,80);  //1. Pink
                      
                  
              }else if(nJag <= nJag1 && nJag >= 10 && nJag 90){     //Falling but above 10
                      
              color0 Color.maroon;          //2. Maroon
                      
                  
              }else if(nJag 10 &&  nJag1 nJag){                 // Rising uner 10
                      
              color0 Color.olive;           //5. Olive
                      
                  
              }else if(nJag 10 ){                               //unDer 10
                      
              color0 Color.RGB(110,50,0);   //3 Brown
                      
                  
              }else if(nJag 10 && nJag1 <= 10){                   //Crossed Up thru 10  
                      
              color0 Color.blue;           //4. Blue
                      
                  
              }else if(nJag 90  &&  nJag1 nJag){                  //slope Down above 90
                      
              color0 Color.RGB(180,70,0);  //1. Orange
                      
                  
              }else if(nJag 90){                                            //Above 90
                      
              color0 Color.RGB(0,0,100);    //5. Midnight Blue
                      
                  
              }else if(nJag nJag1){                               // Rising but under 90
                      
              color0 Color.RGB(0,100,45);   //6. Green
                      
                  
              }else{
                      
              setChartBGColor.yellow );                     // a check, should never happen
                  
              }
              //---------------------------------------   
                  
              if (color0 != color1){
                    
              setChartBG(color0);
                  }    
                  
              return 
              nJag;
              //return;

              Comment


              • #52
                shaeffer
                In order to replicate the problem you will need to provide the efs that is being called
                Alex

                Comment


                • #53
                  Here is the core efs being called, Alex, but unfortunately it is locked. This core efs in combination with my efs has worked in all time frames when inv(xx) is not used. It has only been when I tried to use these combined efs's in a time interval different from the chart interval that a problem occurred. So hopefully there is not something within the locked efs that prevents its use with inv(xx)

                  Thanks
                  shaeffer
                  Attached Files

                  Comment


                  • #54
                    shaeffer
                    The reason it is not working is because the efs that you are calling requires several parameters. You can see this by going in the Edit Studies window for jagc.
                    So if you want to pass the inv(60) parameter to that efs then you also have to pass ALL the parameters that the efs is expecting in the same order in which they are defined. Your call to the jagc efs should therefore be structured as follows
                    xJag = efsExternal("/My Formulas/JagC.efs", pds, slw, triggerLen, emaLen, inv(60));
                    You will need to replace pds, slw, triggerLen and emaLen with the required values. If you do not know in what format these parameters need to be then you will need to contact the author of that script
                    Alex

                    Comment


                    • #55
                      Good detective work Alex, to look at Edit Studies to find the needed variables. For future reference, will the required variables for an efsExternal call always appear in the Edit Studies list, and in the order they appear in the Edit Studies list?

                      I will try to find out these parameters from the original efs author.

                      Regards
                      shaeffer

                      Comment


                      • #56
                        shaeffer
                        In general that is how I [and some others] do it but it may not always be the case.
                        Alex

                        Comment


                        • #57
                          I think I've determined the correct parameters so that efsExternal call is now working with inv(60). Thank you Alex.

                          Comment

                          Working...
                          X