Announcement

Collapse
No announcement yet.

Help...! efsExternal - Arghhh...

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

  • Help...! efsExternal - Arghhh...

    Greetings -

    I have spent untold hours trying to get the efsExternal call to work.

    Scoured the Forums, cut and paste code out of the EFS KnowledgeBase -- I simply cannot get this code to work - arghhh - lol...!

    Any help would be much appreciated.

    I am trying call the status of another script - "14C_27L_Arrow" from a 3.0R NQ M9 chart.

    If that script isLong - go long on 1.5R chart, here is what is NOT working:

    -----------------------------------------------

    LSMA_Array[0] = LinearRegValue;

    var LSMA = LinearRegValue

    var xCCI = cci(27)


    if (bInit == false) {
    xStudy1 = wma(30);
    xStudy2 = wma(17, sym("NQ H9,4R"));
    bInit = true;
    }

    var v = xStudy1.getValue(0);
    if(v == null)
    return;

    var x = xStudy2.getValue(0);
    if(x == null)
    return;



    if(close(0) >= LSMA && xCCI > 0) {
    if(!Strategy.isLong()) && efsExternal("14C_27L_Arrow") Strategy.isLong()) {
    Strategy.doLong("Crossing Up",Strategy.CLOSE,Strategy.THISBAR) && (drawShapeRelative(0, open(-1), Shape.UPARROW , 4, Color.blue, Shape.BOTTOM));
    }
    } else if(close(0) <= LSMA && xCCI < 0) {
    if(!Strategy.isShort()) {
    Strategy.doShort("Crossing Down",Strategy.CLOSE,Strategy.THISBAR) && (drawShapeRelative(0, open(-1), Shape.DOWNARROW , 4, Color.red, Shape.BOTTOM));
    }
    }

    if(Strategy.isLong()) {
    setBarBgColor(Color.teal);
    } else if(Strategy.isShort()) {
    setBarBgColor(Color.brown);
    }

    return LSMA_Array[nOffset];
    return v;

    }

    -------------------------------------------------

    Thank you again for any help you can offer...!

    cb

  • #2
    Re: Help...! efsExternal - Arghhh...

    cb
    The first issue is that the syntax you are using in your efsExternal() call ie efsExternal("14C_27L_Arrow") is incorrect and should be efsExternal("14C_27L_Arrow.efs") assuming it is in the same folder of the calling efs else you would also need to define the path.
    If you then want the external script to run in the context of an interval that is different from the one being charted you need to pass that interval to the efsExternal() call using the inv() function. For the description and syntax required by this function see the linked article in the EFS KnowledgeBase.
    You may also want to review this thread which should provide you with a basic understanding of how to use the efsExternal() function
    That said what is the called efs returning? The efsExternal() function only retrieves numbers returned by another efs and not strings, booleans, etc so you may need to consider that.
    Alex


    Originally posted by cba33558
    Greetings -

    I have spent untold hours trying to get the efsExternal call to work.

    Scoured the Forums, cut and paste code out of the EFS KnowledgeBase -- I simply cannot get this code to work - arghhh - lol...!

    Any help would be much appreciated.

    I am trying call the status of another script - "14C_27L_Arrow" from a 3.0R NQ M9 chart.

    If that script isLong - go long on 1.5R chart, here is what is NOT working:

    -----------------------------------------------

    LSMA_Array[0] = LinearRegValue;

    var LSMA = LinearRegValue

    var xCCI = cci(27)


    if (bInit == false) {
    xStudy1 = wma(30);
    xStudy2 = wma(17, sym("NQ H9,4R"));
    bInit = true;
    }

    var v = xStudy1.getValue(0);
    if(v == null)
    return;

    var x = xStudy2.getValue(0);
    if(x == null)
    return;



    if(close(0) >= LSMA && xCCI > 0) {
    if(!Strategy.isLong()) && efsExternal("14C_27L_Arrow") Strategy.isLong()) {
    Strategy.doLong("Crossing Up",Strategy.CLOSE,Strategy.THISBAR) && (drawShapeRelative(0, open(-1), Shape.UPARROW , 4, Color.blue, Shape.BOTTOM));
    }
    } else if(close(0) <= LSMA && xCCI < 0) {
    if(!Strategy.isShort()) {
    Strategy.doShort("Crossing Down",Strategy.CLOSE,Strategy.THISBAR) && (drawShapeRelative(0, open(-1), Shape.DOWNARROW , 4, Color.red, Shape.BOTTOM));
    }
    }

    if(Strategy.isLong()) {
    setBarBgColor(Color.teal);
    } else if(Strategy.isShort()) {
    setBarBgColor(Color.brown);
    }

    return LSMA_Array[nOffset];
    return v;

    }

    -------------------------------------------------

    Thank you again for any help you can offer...!

    cb

    Comment


    • #3
      You might want to check out this thread for further information..



      If you have additional questions, let us know?
      Brad Matheny
      eSignal Solution Provider since 2000

      Comment


      • #4
        Help...! efsExternal - Arghhh...

        Thank you Alexis and Doji...!

        For the External call, I am trying to see if the "14C_27L_Arrow.efs" script is long or short on a 3 Range bar chart - and pass the 'yes or no' of that call to to the script running on a 1.5 Range bar chart.

        The External script is using to the 20 period LMSA on the 3 Range bar chart to determine if it is long or short.

        Perhaps instead of using an External long/short call to determine if the 3 Range bar chart is long or short, I should call the External price status above or below the 3 Range bar 20 period LMSA...?

        Thanks --

        cb

        Comment


        • #5
          Re: Help...! efsExternal - Arghhh...

          cb
          You should be able to accomplish what you want by having the called efs return a number corresponding to its state for example 1 if long, 0 if flat and -1 if short. Once you do that you can use the efsExternal() call to retrieve those values hence determine the state of the called efs
          Alex


          Originally posted by cba33558
          Thank you Alexis and Doji...!

          For the External call, I am trying to see if the "14C_27L_Arrow.efs" script is long or short on a 3 Range bar chart - and pass the 'yes or no' of that call to to the script running on a 1.5 Range bar chart.

          The External script is using to the 20 period LMSA on the 3 Range bar chart to determine if it is long or short.

          Perhaps instead of using an External long/short call to determine if the 3 Range bar chart is long or short, I should call the External price status above or below the 3 Range bar 20 period LMSA...?

          Thanks --

          cb

          Comment


          • #6
            Help...! efsExternal - Arghhh...

            Hi Alexis --

            Thank you so much for your help -- but unfortunately, I just cannot get this to work:

            The "14C_25L_Arrow.efs" - Script being called - Setting Value of xState to +1 for Long or -1 for Short:
            ----------------------------------------------------

            if(xState==null) return;

            if(close(0) >= LMSA && xCCI > 0) {
            if(!Strategy.isLong()) {
            Strategy.doLong("Crossing Up",Strategy.CLOSE,Strategy.THISBAR) && (drawShapeRelative(0, open(-1), Shape.UPARROW , 4, Color.blue, Shape.BOTTOM));
            }
            } else if(close(0) <= LMSA && xCCI < 0) {
            if(!Strategy.isShort()) {
            Strategy.doShort("Crossing Down",Strategy.CLOSE,Strategy.THISBAR) && (drawShapeRelative(0, open(-1), Shape.DOWNARROW , 4, Color.red, Shape.BOTTOM));
            }
            }

            if(Strategy.isLong()) {
            setBarBgColor(Color.teal) && setBar(Bar.Value, 1);
            } else if(Strategy.isShort()) {
            setBarBgColor(Color.brown) && setBar(Bar.Value, -1);
            }
            --------------------------------------------------

            The Calling Script - 20C_25L_Arrow_100_EXT.efs - Calling the xState value from the above script:

            -------------------------------------------------
            var xState = efsExternal("14C_25L_Arrow.efs");
            if(xState.getValue(0)==null) return;

            if(close(0) >= LSMA && xCCI > -100) {
            if(!Strategy.isLong() && xState.getValue(0)==1) {
            Strategy.doLong("Crossing Up",Strategy.CLOSE,Strategy.THISBAR) && (drawShapeRelative(0, open(-1), Shape.UPARROW , 4, Color.blue, Shape.BOTTOM));
            }
            } else if(close(0) <= LSMA && xCCI < 100) {
            if(!Strategy.isShort()) && xState.getValue(0)==-1) {
            Strategy.doShort("Crossing Down",Strategy.CLOSE,Strategy.THISBAR) && (drawShapeRelative(0, open(-1), Shape.DOWNARROW , 4, Color.red, Shape.BOTTOM));
            }

            --------------------------------------------

            There is/are syntax errors in the calling or called scripts...?

            Hopefully this will be the last time I will need to ask about this - thanks again...!


            cb

            Comment


            • #7
              Re: Help...! efsExternal - Arghhh...

              cb
              First of all you are using incorrect syntax in both scripts when executing multiple commands ie
              PHP Code:
              if(myCondition==true){
                  
              doThis && doThat;

              should be written as follows
              PHP Code:
              if(myCondition==true){
                  
              doThis;
                  
              doThat;

              Secondly in the following lines of code of the called efs
              PHP Code:
              if(Strategy.isLong()) {
                  
              setBarBgColor(Color.teal) && setBar(Bar.Value1); 
              } else if(
              Strategy.isShort()) {
                  
              setBarBgColor(Color.brown) && setBar(Bar.Value, -1);

              the syntax used in the setBar() function is incorrect. Additionally the use of that function is improper if you are using it to set the current value of the returned item as that is not what it does.
              Those lines of code should be similar to the following example where based on the condition you assign a value to a variable which is then returned by the efs
              PHP Code:
              if(Strategy.isLong()) {
                  
              setBarBgColor(Color.teal);
                  var 
              myState 1
              } else if(
              Strategy.isShort()) {
                  
              setBarBgColor(Color.brown);
                  var 
              myState = -1;
              } else {
                  var 
              myState 0;
              }
              //then you need to return the variable myState
              return myState
              In looking at your code it seems to me that you are somewhat unfamiliar with programming in EFS. If that is the case then I would suggest that you review the JavaScript for EFS video series and the Core JavaScript Reference Guide. Those will provide you with a thorough introduction to programming in JavaScript which is at the foundation of EFS. Then go through the EFS KnowledgeBase and study the Help Guides and Tutorials which will provide you with many of the specifics of EFS.
              Alex


              Originally posted by cba33558
              Hi Alexis --

              Thank you so much for your help -- but unfortunately, I just cannot get this to work:

              The "14C_25L_Arrow.efs" - Script being called - Setting Value of xState to +1 for Long or -1 for Short:
              ----------------------------------------------------

              if(xState==null) return;

              if(close(0) >= LMSA && xCCI > 0) {
              if(!Strategy.isLong()) {
              Strategy.doLong("Crossing Up",Strategy.CLOSE,Strategy.THISBAR) && (drawShapeRelative(0, open(-1), Shape.UPARROW , 4, Color.blue, Shape.BOTTOM));
              }
              } else if(close(0) <= LMSA && xCCI < 0) {
              if(!Strategy.isShort()) {
              Strategy.doShort("Crossing Down",Strategy.CLOSE,Strategy.THISBAR) && (drawShapeRelative(0, open(-1), Shape.DOWNARROW , 4, Color.red, Shape.BOTTOM));
              }
              }

              if(Strategy.isLong()) {
              setBarBgColor(Color.teal) && setBar(Bar.Value, 1);
              } else if(Strategy.isShort()) {
              setBarBgColor(Color.brown) && setBar(Bar.Value, -1);
              }
              --------------------------------------------------

              The Calling Script - 20C_25L_Arrow_100_EXT.efs - Calling the xState value from the above script:

              -------------------------------------------------
              var xState = efsExternal("14C_25L_Arrow.efs");
              if(xState.getValue(0)==null) return;

              if(close(0) >= LSMA && xCCI > -100) {
              if(!Strategy.isLong() && xState.getValue(0)==1) {
              Strategy.doLong("Crossing Up",Strategy.CLOSE,Strategy.THISBAR) && (drawShapeRelative(0, open(-1), Shape.UPARROW , 4, Color.blue, Shape.BOTTOM));
              }
              } else if(close(0) <= LSMA && xCCI < 100) {
              if(!Strategy.isShort()) && xState.getValue(0)==-1) {
              Strategy.doShort("Crossing Down",Strategy.CLOSE,Strategy.THISBAR) && (drawShapeRelative(0, open(-1), Shape.DOWNARROW , 4, Color.red, Shape.BOTTOM));
              }

              --------------------------------------------

              There is/are syntax errors in the calling or called scripts...?

              Hopefully this will be the last time I will need to ask about this - thanks again...!


              cb

              Comment

              Working...
              X