Announcement

Collapse
No announcement yet.

efsExternal( .. )

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • efsExternal( .. )

    Gentlemen/Ladies:

    The following is from efs2 documentation:

    New in EFS2. Returns a series object representing the values as calculated from the given external EFS script. You would then use the getSeries() function to extract a specific series value if multiple series are returned.

    Parameters

    pathToEFS
    the path and filename of the EFS script to call

    sym/inv
    optional. if used, the external EFS will be loaded into the specified symbol or interval's context

    parameters
    optional. parameters, if any, required by the EFS script you are calling


    I am trying to understand what sym/inv definition means:

    if in a 5 -min chart, say, I do:

    var x = efsExternal("x.efs", sym(getSymbol()+","+15));

    ...


    and in x.efs:

    function main (vSymbol) {

    var y = moneyFlow(20);
    var mF = null
    ...
    if (getBarState() == NEWBAR_STATE) {
    ...do somthing..
    }

    return y.getValue(0);

    }

    now, in x.efs, is moneyFlow(20) now actually moneyFlow(20, inv(15))?

    and getBarState() - is that checking the barstate of 15 min interval or 5 min interval?

    I did some debugPrint in x.efs and am not sure what they are actually doing....

    Please help.
    Thank you,

    ziggy

  • #2
    z11
    When you pass sym() or inv() as the last parameter of efsInternal() or efsExternal() functions the whole function or efs that is being called will run in the context of the symbol/interval that is being passed.
    So in your example x.efs is running in the 15 minute interval which means that moneyFlow() is based on the 15 min data series and getBarState() executes on the 15 minute interval
    Alex

    Comment


    • #3
      Thanks for the reply.

      That was my initial understanding.
      But after calling an efs with sym(getSymbol+","+15) as the last parameter, the efs being called are returning values more like the ones in the calling efs's 3 minute chart's value.

      And I mean to extending that understanding, calling studies such as close()/high() etc in x.efs should get 15 min interval data? But they are not.

      Also to be clear, based on efs2 documentation, in calling efsExternal, sym() / inv() need not to be the last parameter to force correct external interval...right?

      Comment


      • #4
        z11
        Post the efs or a complete working example that illustrates the problem you are seeing.
        sym() or inv() need to be the last parameter to force the external function or efs to run in the context of the symbol or interval that is being passed
        Alex

        Comment


        • #5
          function preMain() {

          setPriceStudy(false);

          }
          var bInit = false;
          var vInt = getInterval();
          var vInt2 = 15;
          var vSym = getSymbol();
          function main() {
          if (getBarState() == BARSTATE_ALLBARS) {
          return null;
          }

          if (bInit == false) {
          var x = efsExternal("x.efs", sym(vSym+","+vInt));
          var x2 = efsExternal("x.efs", sym(vSym+","+vInt2));
          bInit = true;
          }
          var xx = getSeries(x,0);
          var xx_1 = xx.getValue(0);
          var xx_2 = xx.getValue(-1);
          var xx_3 = xx.getValue(-2);

          var xx2 = getSeries(x2,0);
          var xx2_1 = xx2.getValue(0);
          var xx2_2 = xx2.getValue(-1);
          var xx2_3 = xx2.getValue(-2);
          return new Array (xx_1, xx_2, xx_3, xx2_1, xx2_2, xx2_3);
          }



          in x.efs:

          function main( vSym) {

          var s1 = moneyFlow(20);
          var m1 = s1.getValue(0);

          debugPrintln(m1 + " " + close(0));

          return (m1/close(0));
          }


          *** here I got same values from both efsExternal calls thereby indicating that second efsExternal was also in 3 min

          interval from which the call efs is run and not the 15 minute interval.

          Thanks

          ziggy

          Comment


          • #6
            z11
            efsExternal() requires at least two parameters for the sym() or inv() functions to control the external efs.
            The solution in your case is to add a value (for example 0) to use just as a placeholder in the efsExternal() call ie
            xx2 = efsExternal("x.efs", 0, sym(vSym+","+vInt2));
            and in the called efs add a parameter name to the main definition ie
            function main(placeholder,vSym)
            Once you implement this change the called efs will run in the context of the sym() or inv() that is being passed.
            Alex

            Comment


            • #7
              Thank you very much, Alex. That indeed cured everything!

              While I am absolutely grateful for your exitence in this community, I nevertheless is quite frustrated at eSignal's precarious attitude toward their documentation, which errors (2 I have encountered in the last 2 weeks which were both clarified by you) have caused me no less than 10 hours of frustration.

              Thank you again,

              ziggy

              Comment

              Working...
              X