Announcement

Collapse
No announcement yet.

Help Finding Pesky Variable

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

  • Help Finding Pesky Variable

    Hi All: I am working on learning how to program with EFS. I am using the following EFS files which were written from the May 2008 issue of Stocks and Commodities Magazine. The article title is “The Quest for Reliable Crossovers” by Sylvain Vervoort:

    ZeroLag_HA_Tema_Cross.efs
    and
    HA_ZeroLag_TEMA.efs
    aND
    ZeroLag_TEMA.efs

    From the ZeroLag_TEMA EFS, a function is referencing nLength:
    function calcTEMA(nLength,xSource){

    also from the HA_ZeroLag_TEMA EFS, a function is referencing nLength:
    function calcTEMA(nLength,xSource){

    I cannot find where nLength came from. Where was it Dimensioned? Where was it Initialized?

    These files are working, so I know nLength is a valid variable. For my growth and learning could someone please help me understand this?

    Thank you,
    Don

  • #2
    nPeriods is set by the user and defaults to 10.

    Code:
        var fp1 = new FunctionParameter("nPeriods", FunctionParameter.NUMBER);
            fp1.setName("Periods");
            fp1.setLowerLimit(1);
            fp1.setDefault(10);
    The Main() declaration has it as a parameter that it gets from the eSignal engine.

    Code:
    function main(nPeriods) {
    When it calls the internal function with nPeriods as one of the calling parameters:



    Code:
     xTema2      = efsInternal("calcTEMA", nPeriods, xTema1);
    But the called function accepts it as nPeriods as input for nLength:


    Code:
    function calcTEMA(nLength,xSource){

    So the value is passed as nPeriods but is used in the function as nLength.

    Garth
    Garth

    Comment


    • #3
      Garth: Thank you for your great response.

      Okay, next question: when EFS File “Zero Lag HA TEMA Crossover” calls the external function using this line of code:

      xZTema = efsExternal("ZeroLag_TEMA.efs", nPeriods, sSource);

      It looks like it is passing two variables “nPeriods” and “sSource”. Is this correct?
      Last edited by schu7044; 02-17-2009, 12:34 PM.
      Don

      Comment


      • #4
        I received an email that says...

        Hello schu7044, Alexis C. Montenegro has just replied.
        The email doesn't give the message and its not on this thread. Could you try reposting--or is there somewhere else I should be looking?
        Don

        Comment


        • #5
          <Okay, next question:
          <
          <When EFS File “Zero Lag HA TEMA Crossover” calls the external <function using this line of code:
          <
          <xZTema = efsExternal("ZeroLag_TEMA.efs", nPeriods, sSource);
          <
          <It looks like it is passing two variables “nPeriods” <and “sSource”. Is this correct?
          <
          <Response from gspiker:
          <
          <That is correct.
          <
          <Garth

          Okay everyone, please stay with me and thanks for your patience and help:

          So the TEMA_ Crossover.efs calls the external file ZeroLag_TEMA.efs and passes “nPeriods.”
          From what I can tell, “nPeriods” has been set to 55 by TEMA_ Crossover.efs.

          [CODE]
          '/*/ nPeriods is set to 55, and later sent to external function (a).
          var fp1 = new FunctionParameter("nPeriods", FunctionParameter.NUMBER);
          fp1.setName("Periods");
          fp1.setLowerLimit(0);
          fp1.setDefault(55);
          [CODE]

          The ZeroLag_TEMA.efs file has ALSO set “nPeriods” but to equal 10—not 55.

          [CODE]
          var fp1 = new FunctionParameter("nPeriods", FunctionParameter.NUMBER);
          fp1.setName("Periods");
          fp1.setLowerLimit(1);
          fp1.setDefault(10);
          [CODE]

          So that’s where I sit. What is “nPeriods” at this point? 55? 10?

          This is the main function for ZeroLag_TEMA.efs.

          [CODE]
          '/*/ The calling program (c) passes: nPeriods = 55 and sSource = "HLC/3"
          '/*/ this variable was initiated and passed as a STRING...

          function main(nPeriods, sSource)
          if (bVersion == null) bVersion = verify();
          [CODE]

          p.s. How do I get more than one line at a time into the QUOTE and CODE boxes?
          Last edited by schu7044; 02-18-2009, 07:48 AM.
          Don

          Comment


          • #6
            Don

            The email doesn't give the message and its not on this thread. Could you try reposting--or is there somewhere else I should be looking?
            The email notification you are referring to was for my reply to your first question which I subsequently deleted as Garth had already replied.
            With regards to the question in the post quoted below nPeriods will be whatever you are passing to the efs being called through the efsExternal() call. In this case it will be 55
            You can easily verify this by inserting after line 67 of the ZeroLag_TEMA.efs a debug statement such as the following
            PHP Code:
            debugPrintln(nPeriods); 
            and then looking at the value returned in the Formula Output Window
            The value of 10 set as the default in the ZeroLag_TEMA.efs would be used only if you are running that efs as a stand alone formula or if you were not passing any parameters when calling it ie if your efsExternal() call were for example written as follows
            PHP Code:
             efsExternal("ZeroLag_TEMA.efs"); 
            p.s. How do I get more than one line at a time into the QUOTE and CODE boxes?
            The Quote and Code boxes only take one line. Just use the vB tags in the body of your message as explained in the vB Code [help] (the link is also available in the page in which you compose your messages)
            Alex


            Originally posted by schu7044
            <Okay, next question:
            <
            <When EFS File “Zero Lag HA TEMA Crossover” calls the external <function using this line of code:
            <
            <xZTema = efsExternal("ZeroLag_TEMA.efs", nPeriods, sSource);
            <
            <It looks like it is passing two variables “nPeriods” <and “sSource”. Is this correct?
            <
            <Response from gspiker:
            <
            <That is correct.
            <
            <Garth

            Okay everyone, please stay with me and thanks for your patience and help:

            So the TEMA_ Crossover.efs calls the external file ZeroLag_TEMA.efs and passes “nPeriods.”
            From what I can tell, “nPeriods” has been set to 55 by TEMA_ Crossover.efs.

            [CODE]
            '/*/ nPeriods is set to 55, and later sent to external function (a).
            var fp1 = new FunctionParameter("nPeriods", FunctionParameter.NUMBER);
            fp1.setName("Periods");
            fp1.setLowerLimit(0);
            fp1.setDefault(55);
            [CODE]

            The ZeroLag_TEMA.efs file has ALSO set “nPeriods” but to equal 10—not 55.

            [CODE]
            var fp1 = new FunctionParameter("nPeriods", FunctionParameter.NUMBER);
            fp1.setName("Periods");
            fp1.setLowerLimit(1);
            fp1.setDefault(10);
            [CODE]

            So that’s where I sit. What is “nPeriods” at this point? 55? 10?

            This is the main function for ZeroLag_TEMA.efs.

            [CODE]
            '/*/ The calling program (c) passes: nPeriods = 55 and sSource = "HLC/3"
            '/*/ this variable was initiated and passed as a STRING...

            function main(nPeriods, sSource)
            if (bVersion == null) bVersion = verify();
            [CODE]

            p.s. How do I get more than one line at a time into the QUOTE and CODE boxes?

            Comment


            • #7
              Thank you for your help understanding where the post (I thought was missing) went and your answer on passing variables.
              Don

              Comment


              • #8
                Don
                You are most welcome
                Alex


                Originally posted by schu7044
                Thank you for your help understanding where the post (I thought was missing) went and your answer on passing variables.

                Comment

                Working...
                X