Announcement

Collapse
No announcement yet.

efsExternal for multiple intervals

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

  • efsExternal for multiple intervals

    In a 70T interval chart I want to check a condition in a 400T interval chart and return a flag of "long" or "short" using efsExternal.

    I read Alex's various threads on efsInternal and efsExternal, including the 01-09-2006 thread to Z11, and I obviously still don't get it.

    Also, do I need to pass the symbol also (in this case AB H6) or will the external efs default to the symbol being used in my main efs?

    Thanks in advance.


    // my external efs


    var vTrend = "flat";

    function preMain() {
    setColorPriceBars(true);
    setPriceStudy(true);
    setStudyTitle("VerifyTrend");


    var vFast1 = new FunctionParameter("vFast1", FunctionParameter.NUMBER);
    vFast1.setLowerLimit(1.00);
    vFast1.setDefault(5.00);
    var vFast2 = new FunctionParameter("vFast2", FunctionParameter.NUMBER);
    vFast2.setLowerLimit(1.00);
    vFast2.setDefault(10.00);

    } // end preMain


    function main(vFast1, vFast2) {

    var vMA1e = new MAStudy(vFast1, 0, "Close", MAStudy.EXPONENTIAL);
    var vMA1s = new MAStudy(vFast2, 0, "Close", MAStudy.SIMPLE);

    if ( vMA1e.getValue(MAStudy.MA) < vMA1s.getValue(MAStudy.MA) ) { // short condition
    setPriceBarColor( Color.red);
    vTrend = "short";
    }
    else {
    setPriceBarColor( Color.lime);
    vTrend = "long";
    }

    return (vTrend);

    } // end Main



    *********

    // In my main efs I am calling the external efs as follows:

    vTrend = efsExternal("VerifyTrend.efs",5,10,inv("400T") );

    drawText(vTrend,BelowBar4);


    When I print it I get an "(object Series)" error.

  • #2
    ratherBgolfing
    To my knowledge the efsInternal() and efsExternal() functions can only retrieve values and not strings which is what is instead returned by your VerifyTrend.efs script.
    In that script change "long" and "short" to 1 and -1 respectively.
    Alex

    Comment


    • #3
      Thanks Alex

      i made the change and get the same result.

      Am I passing the 400T properly.

      Also, do I need to pass the symbol also (per my earlier post)?

      Comment


      • #4
        ratherBgolfing
        In your drawText() command you need to use the value and not the series object. Try replacing vTrend with vTrend.getValue(0).
        As to your second question you would pass the symbol only if you want the external efs (or function) to run in the context of a symbol that is different from the chart symbol
        Alex

        Comment


        • #5
          Alex,

          vTrend.getValue(0) gives me the error:

          Parameter Number 1 of Function drawText is invalid.

          Thanks re symbol; that makes sense.

          Comment


          • #6
            ratherBgolfing
            Run a null check on the value prior to using it in the drawText() command
            Alex

            Comment


            • #7
              Alex

              Now using:

              if (vTrend == null) vTrend = 4;
              drawText(vTrend, BelowBar4);

              Still printing out "(object Series)"

              Comment


              • #8
                Alex

                Tried passing 5 mins instead of 400T to see if that made a diff...it did not.

                vTrend = efsExternal("VerifyTrend.efs", 5, 10, inv(5));

                Comment


                • #9
                  ratherBgolfing
                  I just tested it at my end and it works fine (see image below)
                  Alex

                  Comment


                  • #10
                    Did you change my external efs code?

                    I get a return of null now...

                    var vTrend = efsExternal("VerifyTrend.efs",5,10,inv("400t"));
                    if (vTrend.getValue(0) == null) drawText ("null",BelowBar4);
                    else drawText(vTrend.getValue(0),BelowBar4);

                    this prints "null" below every bar

                    please post the code you are using for the external efs...thanks.

                    Comment


                    • #11
                      Alex

                      Got it....forgot to take the " "s off when I changed from "short" and "long"

                      Thanks

                      Comment

                      Working...
                      X