Announcement

Collapse
No announcement yet.

Getting value of study run on different symbol

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

  • Getting value of study run on different symbol

    I would like to make a call from a study in a chart running one symbol, to a file that runs a study on a different symbol. For example, I might use

    var XYZ = call("Directional_Breakout_ColorBarsDBC.efs");

    to get the value returned by the study for the attached file.

    However, that would only return the value for the symbol of the chart from which I was making the "call", such as the Russell 2000 if I was making the call from a chart using "AB #F". What I would like to do is to be able to make the call from my study running in a Russell 2000 chart, and receive the value returned by the "Directional_Breakout_ColorBarsDBC.efs" file for "$ADDQ".

    Is there a way to do this?

    Thanks

    Warren
    Attached Files

  • #2
    Warren
    Instead of using the call() function use the efsExternal() function to call the efs and pass the sym("your_symbol") series as the last parameter. This way the efs that is being called will run in the context of the symbol (or symbol/interval) that you are passing to it
    Alex

    Comment


    • #3
      Thanks much Alex.

      Your assistance is invaluable as usual.

      Warren

      Comment


      • #4
        Reference Error

        Alex:

        When I use the following:

        var ADDQDBOBC = efsExternal("Directional_Breakout_ColorBarsDBC.efs ", sym("$ADDQ, 3"));
        if (ADDQDBOBC == null) return;

        I get, "ReferenceError:efsExternal is not defined".

        I am running version 7.9.

        Warren

        Comment


        • #5
          Warren
          efsExternal() is only available with 7.9.1 or later.
          Regardless in 7.9 you still have available a similar functionality with the efs() function.
          Alex

          Comment


          • #6
            Alex:

            I have upgraded to 7.9.1. Now when I load the study using efsExternal, it returns:

            line 82: MAStudy parameter 3 invalid.

            This refers to line 82 of the file I attached originally. If I load that file independently, it loads fine.

            Warren

            Comment


            • #7
              Warren
              That may be because you are not passing all the parameters that the called efs is expecting. Excluding the symbol parameter for the time being this is how your efsExternal() call should look like

              PHP Code:
              efsExternal("Directional_Breakout_ColorBarsDBC.efs",20,0,"Close","MAStudy.SIMPLE",
                                  
              Color.blue,Color.yellow,Color.red); 
              To these you will need to add at the very end the sym("your symbol") parameter ie

              PHP Code:
              efsExternal("Directional_Breakout_ColorBarsDBC.efs",20,0,"Close","MAStudy.SIMPLE",
                                  
              Color.blue,Color.yellow,Color.redsym("your_symbol")); 
              Then you need to modify the called efs to expect the symbol parameter in the following way

              PHP Code:
              function main(LengthOffsetSourceTypecPoscZerocNegsymbol){ 
              If you do not need to control all the parameters from the calling efs (such as for example the colors) then I would suggest hard coding them in the called efs and removing the parameter names from both scripts.
              Alex

              Comment


              • #8
                Alex:

                Works great. Thanks for all the help.

                Warren

                Comment


                • #9
                  Warren
                  You are most welcome
                  Alex

                  Comment

                  Working...
                  X