Announcement

Collapse
No announcement yet.

efsExternal on diff timeframe

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

  • efsExternal on diff timeframe

    Having a problem with efsExternal. I've an efs that works fine when I call the plain efsExternal. However, now I'd like to call it on the same symbol with different timeframe. No matter what I attempt, it won't work. Have searched the forums, but can't find and example that calls efsExternal on diff timeframe.

    Is it indeed possible to call an efsExternal on a different time frame, and if so, how would I modify the code below?

    FYI, I'm on a 3 min chart and want to call the efsExternal running on a 5 min chart.

    I must be missing something in the syntax?

    Thanks

    bigtee

    Code:
    Init == false) {
            // This code block executes only once at the beginning of initialization.
            Symbol = getSymbol();
            Interval = 5;
            var vSymbol = Symbol+","+Interval;
            
            // efs works with below line on same symbol same timeframe
            //var vExtEfs = efsExternal("/Downloads/RatioStop.efs");    
            
            // efs does not work with any of the below attempts to call the ext efs on different timeframe
            var vExtEfs = efsExternal("/Downloads/RatioStop.efs",sym(vSymbol) );
            //var vExtEfs = efsExternal("/Downloads/RatioStop.efs",sym("OIH, 5" ));
            //var vExtEfs = efsExternal("/Downloads/RatioStop.efs", inv(5));
            
            xUpper = getSeries(vExtEfs,0);
            xLower = getSeries(vExtEfs,0);
            
            
            
            bInit = true;  // Prevents this code block from executing again.
        }

  • #2
    Re: efsExternal on diff timeframe

    bigtee
    The variable vExtEfs needs to be a global variable (ie declared outside of the main function)
    This may or may not resolve the issue you are having. If it does not you may need to post the complete code rather than just a section of it.
    Alex


    Originally posted by bigtee
    Having a problem with efsExternal. I've an efs that works fine when I call the plain efsExternal. However, now I'd like to call it on the same symbol with different timeframe. No matter what I attempt, it won't work. Have searched the forums, but can't find and example that calls efsExternal on diff timeframe.

    Is it indeed possible to call an efsExternal on a different time frame, and if so, how would I modify the code below?

    FYI, I'm on a 3 min chart and want to call the efsExternal running on a 5 min chart.

    I must be missing something in the syntax?

    Thanks

    bigtee

    Code:
    Init == false) {
            // This code block executes only once at the beginning of initialization.
            Symbol = getSymbol();
            Interval = 5;
            var vSymbol = Symbol+","+Interval;
            
            // efs works with below line on same symbol same timeframe
            //var vExtEfs = efsExternal("/Downloads/RatioStop.efs");    
            
            // efs does not work with any of the below attempts to call the ext efs on different timeframe
            var vExtEfs = efsExternal("/Downloads/RatioStop.efs",sym(vSymbol) );
            //var vExtEfs = efsExternal("/Downloads/RatioStop.efs",sym("OIH, 5" ));
            //var vExtEfs = efsExternal("/Downloads/RatioStop.efs", inv(5));
            
            xUpper = getSeries(vExtEfs,0);
            xLower = getSeries(vExtEfs,0);
            
            
            
            bInit = true;  // Prevents this code block from executing again.
        }

    Comment


    • #3
      Alex, declaring the variable outside main did not fix the problem.

      This is a backtesting efs. I put the efs on the chart also, and if it is working you will see the background change colors when it is long and short.

      Again, it works until I try to change the time frame. The called RatioStop efs is one I downloaded from this forum.

      I've attempted to attach the efs file. If it does not go through, I'll be right back and embed the code.


      bigtee
      Attached Files

      Comment


      • #4
        bigtee
        A possible reason why your efs may not be working when you pass the sym() or inv() parameters (and conversely working when you don't pass any parameters) could be that the efs you are calling requires some parameters. You can see this by going in the Edit Studies window for that efs.
        If this is the case and you want to pass the sym() or inv() 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 in the main argument of that efs (this is explained in the Notes section in this article on the efsExternal() function in the EFS KnowledgeBase)
        If this instead is not the case then you need to post also the efs you are calling or provide a link to where it can be downloaded
        As to the script you have attached even though you have declared the variable vExtEfs as a global variable you are also declaring it locally. You need to remove the var from the line of code inside the bInit routine where you are initializing the variable.
        Alex


        Originally posted by bigtee
        Alex, declaring the variable outside main did not fix the problem.

        This is a backtesting efs. I put the efs on the chart also, and if it is working you will see the background change colors when it is long and short.

        Again, it works until I try to change the time frame. The called RatioStop efs is one I downloaded from this forum.

        I've attempted to attach the efs file. If it does not go through, I'll be right back and embed the code.


        bigtee

        Comment


        • #5
          Alex, I removed the "var" from lines 52, 55, 56, 57.

          No change. It still works on the simple version on line 52 but does not work anywhere else.

          The called efs has parameters, but there are defaults for all of them, and it does work without passing as long as you don't change time frames.

          Anyway, I've attached the called efs so you can see what it is.


          bigtee
          Attached Files

          Comment


          • #6
            bigtee
            To run an external efs in the context of a different symbol and/or interval the sym() or inv() function must be the last parameter passed to the called efs.
            Once you pass the sym() or inv() parameter you need to pass also all the other parameters that are expected by the called efs else the sym() or inv() parameter you are passing is simply going to be assigned to the first parameter of that efs (which will then use the defaults for all the other parameters that follow).
            In your case the sym() or inv() parameters are passing a value that is either not valid or out of range for the first parameter of the efs you are calling hence it does not function. It functions instead when you pass no parameters because in that case it uses the defaults set in that efs by the various FunctionParameter(s).
            For an example of this I would suggest that you review this and this thread on the same topic
            Alex


            Originally posted by bigtee
            Alex, I removed the "var" from lines 52, 55, 56, 57.

            No change. It still works on the simple version on line 52 but does not work anywhere else.

            The called efs has parameters, but there are defaults for all of them, and it does work without passing as long as you don't change time frames.

            Anyway, I've attached the called efs so you can see what it is.


            bigtee

            Comment

            Working...
            X