Announcement

Collapse
No announcement yet.

GlobalValue

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

  • GlobalValue

    Good Afternoon,

    The following script is a stripped down version of an indicator I use in EFS. It operates on a 1 minute based chart and calculates either a +1 or -1 indicator. (Not just the simple moving average shown here.) This indicator is then passed to a tick based chart using the globalVariable and then ploted. When the two charts are viewed side by side, it appears the tick based chart periodically has more changes from +1 to -1 than the minute based chart. When I load the minute based EFS onto the tick based chart it computes the same extra changes from +1 to -1 as does the globalVariable plot.

    How can I get the indicator passed from the minute based chart to the tick chart or the minute based EFS loaded onto the tick chart to compute exactly the same as the minute based chart without any of these extra changes.

    In other words, I want the exact plot changing from +1 to -1 presented in the minute chart plotted on the tick chart with no modifictions.

    Thank you in advance for your support.

    Best regards,

    Alan



    function main() {

    var vSymbol1 = Symbol1+","+Interval1;
    x1MA1 = offsetSeries(eval(sma)(3,eval(low)(sym(vSymbol1))) ,0);

    var M1A1 = (x1MA1.getValue(-2));

    setGlobalValue("tvul",M1A1);

    return (M1A1);

    }

  • #2
    Hi Alan2004,

    I would recommend that you try using the "efsExternal()" command to call the 1 minute efs from within the efs operating from within the tick chart.

    Comment


    • #3
      GlobalValue

      Steve,

      Thank you for the assistance.

      The following portion of script is trying to read the setGlobalVariable output from efs file "TEST77". The data is output from a second efs file "TEST55" to file "tvul" and the variable output is "M1A1". Also the only variable being plotted in TEST55 is the output data. Both efs files "TEST55" and "TEST77" were running side by side when I loaded the efs into the tick chart.

      I receive an error message that "Formula file not found". I can not find any clear guidence in the Knowledge Base as to how to correct the code for the efsExternal formula.

      You assistance is greatly apreciated.

      Best Regrards,

      Alan








      function main() {

      wer = 0;

      var wer = efsExternal( "TEST77.efs");

      if(wer >= 0.1) {
      aa3 = 1;
      }

      if(wer < 0.1) {
      aa3 = -1;
      }

      return (aa3);

      }

      Comment


      • #4
        Hello Alan,

        Please post the Test77.efs as an attachment. We need to see that code in order to help you solve this problem.

        In general, I think the possible solution for you will be to use the multiple interval functionality of EFS2 (i.e. sym()/inv()) rather than the setGlobalValue()/getGlobalValue() routine, which won't be synchronized on a historical basis. The setGlobalValue()/getGlobalValue() is mostly intended for two separate formulas passing information from one to the other during real time processing.
        Jason K.
        Project Manager
        eSignal - an Interactive Data company

        EFS KnowledgeBase
        JavaScript for EFS Video Series
        EFS Beginner Tutorial Series
        EFS Glossary
        Custom EFS Development Policy

        New User Orientation

        Comment


        • #5
          GlobalValue

          Jason,

          Thank you for the help.

          I have constructed the following simple moving average cross overs to demonstrate the problems I am encountering. All comments are relative to running these scripts on $INDU for 09/07/05.

          The first EFS is TEST55.

          This plots an indicator of +1/-1 when the moving averages cross over. This is run on a 1 minue chart. This passes the indicator out using setGlobalVariable. This is the base case I am trying to get passed over to a 10T chart of $INDU or better yet calculated inside the 10T chart.

          The second EFS is TEST77.

          This reads in the globalvariable and plots it on a 10T chart. AT 12:40 on the 10T chart I get a +1/-1 reversal that does not show up on the 1 minute chart. I only want to see the reversals which actually occur on the 1 minute chart.

          The third EFS is TEST33.

          This is a copy of the TEST55 EFS with the globalvariable removed so the 1 minute calculations are updated and plotted on each 10T. Note that there are +1/-1 reversals at 11:17 and 13:04 which do not show up on the 1 minute chart and they are different times from the TEST77 chart. I do not want these to be plotted on the 10T chart.

          The fourth EFS is TEST99.

          This is my attempt to get efsExternal runnig and this produces an error message.

          The objective is to get the 1 minute +1/-1 indicators to plot on the 10T chart with only the reversals which show up on the 1 minute chart. The points would be plotted as close as possible to the whole minute recognising that the whole minute may not be an actual 10T point.

          Your help is greatly appreciated.

          Best regards,

          Alan

          PHP Code:
          /******************************************************
          TEST55
          **********************************************************/

          var x1MA1 null;
          var 
          x1MA2 null;

          function 
          preMain() {
              
              
          setStudyTitle("TEST55");
              
          setCursorLabelName("MA1"0);
              
          setDefaultBarStyle(PS_SOLID0);
              
          setDefaultBarStyle(PS_SOLID1);
              
          setDefaultBarStyle(PS_SOLID2);
              
          setDefaultBarStyle(PS_SOLID3);
              
          setDefaultBarFgColor(Color.black0);
              
          setDefaultBarFgColor(Color.black1);
              
          setDefaultBarFgColor(Color.black2);
              
          setDefaultBarFgColor(Color.blue3);
              
          setDefaultBarThickness(10);
              
          setDefaultBarThickness(11);
              
          setDefaultBarThickness(12);
              
          setDefaultBarThickness(33);
              
          setPlotType(PLOTTYPE_LINE0);
              
          setPlotType(PLOTTYPE_LINE1);
              
          setPlotType(PLOTTYPE_LINE2);
              
          setPlotType(PLOTTYPE_LINE3);
              
              
          Symbol1 "$playback";
              
          Interval1 "1M";    
              
          }

          function 
          main() {

          var 
          TT3 = (0)
          var 
          WW3 = (2)
          var 
          QQ3 = (-2)

          var 
          vSymbol1 Symbol1+","+Interval1;
          x1MA1 offsetSeries(eval(sma)(5,eval(close)(sym(vSymbol1))),0);
          x1MA2 offsetSeries(eval(sma)(21,eval(close)(sym(vSymbol1))),0);

              
          var 
          M1A1 = (x1MA1.getValue(0));
          var 
          M1A2 = (x1MA2.getValue(-3));

          qwsx 0.0;

          if(
          M1A1 >= M1A2) {
                      
          qwsx  1.5;
          }

          if(
          M1A1 M1A2) {
                      
          qwsx  = -1.5;

          }

          if(
          qwsx!=null)
          setGlobalValue("tvul",qwsx);
           
              return new Array ( 
          TT3WW3QQ3qwsx);
              

          PHP Code:
          /*********************************************************
          TEST77
          **********************************************************/

          var x1MA1 null;
          var 
          x1MA2 null;

          function 
          preMain() {
              
              
          setStudyTitle("TEST77");
              
          setCursorLabelName("MA1"0);
              
          setDefaultBarStyle(PS_SOLID0);
              
          setDefaultBarStyle(PS_SOLID1);
              
          setDefaultBarStyle(PS_SOLID2);
              
          setDefaultBarStyle(PS_SOLID3);
              
          setDefaultBarFgColor(Color.black0);
              
          setDefaultBarFgColor(Color.black1);
              
          setDefaultBarFgColor(Color.black2);
              
          setDefaultBarFgColor(Color.blue3);
              
          setDefaultBarThickness(10);
              
          setDefaultBarThickness(11);
              
          setDefaultBarThickness(12);
              
          setDefaultBarThickness(33);
              
          setPlotType(PLOTTYPE_LINE0);
              
          setPlotType(PLOTTYPE_LINE1);
              
          setPlotType(PLOTTYPE_LINE2);
              
          setPlotType(PLOTTYPE_LINE3);
              
              
          Symbol1 "$playback";
              
          Interval1 "1M";    
              
          }

          function 
          main() {

          var 
          TT3 = (0)
          var 
          WW3 = (2)
          var 
          QQ3 = (-2)
          wer 0;

          var 
          wer getGlobalValue("tvul");

           
              return new Array ( 
          TT3WW3QQ3wer);
              

          PHP Code:
          /******************************************************
          TEST33
          **********************************************************/

          var x1MA1 null;
          var 
          x1MA2 null;

          function 
          preMain() {
              
              
          setStudyTitle("TEST33");
              
          setCursorLabelName("MA1"0);
              
          setDefaultBarStyle(PS_SOLID0);
              
          setDefaultBarStyle(PS_SOLID1);
              
          setDefaultBarStyle(PS_SOLID2);
              
          setDefaultBarStyle(PS_SOLID3);
              
          setDefaultBarFgColor(Color.black0);
              
          setDefaultBarFgColor(Color.black1);
              
          setDefaultBarFgColor(Color.black2);
              
          setDefaultBarFgColor(Color.blue3);
              
          setDefaultBarThickness(10);
              
          setDefaultBarThickness(11);
              
          setDefaultBarThickness(12);
              
          setDefaultBarThickness(33);
              
          setPlotType(PLOTTYPE_LINE0);
              
          setPlotType(PLOTTYPE_LINE1);
              
          setPlotType(PLOTTYPE_LINE2);
              
          setPlotType(PLOTTYPE_LINE3);
              
              
          Symbol1 "$playback";
              
          Interval1 "1M";    
              
          }

          function 
          main() {

          var 
          TT3 = (0)
          var 
          WW3 = (2)
          var 
          QQ3 = (-2)

          var 
          vSymbol1 Symbol1+","+Interval1;
          x1MA1 offsetSeries(eval(sma)(5,eval(close)(sym(vSymbol1))),0);
          x1MA2 offsetSeries(eval(sma)(21,eval(close)(sym(vSymbol1))),0);

              
          var 
          M1A1 = (x1MA1.getValue(0));
          var 
          M1A2 = (x1MA2.getValue(-3));

          qwsx 0.0;

          if(
          M1A1 >= M1A2) {
                      
          qwsx  1.5;
          }

          if(
          M1A1 M1A2) {
                      
          qwsx  = -1.5;

          }

           
              return new Array ( 
          TT3WW3QQ3qwsx);
              

          PHP Code:
          /*********************************************************
          TEST99
          **********************************************************/

          var x1MA1 null;
          var 
          x1MA2 null;

          function 
          preMain() {
              
              
          setStudyTitle("TEST99");
              
          setCursorLabelName("MA1"0);
              
          setDefaultBarStyle(PS_SOLID0);
              
          setDefaultBarStyle(PS_SOLID1);
              
          setDefaultBarStyle(PS_SOLID2);
              
          setDefaultBarStyle(PS_SOLID3);
              
          setDefaultBarFgColor(Color.black0);
              
          setDefaultBarFgColor(Color.black1);
              
          setDefaultBarFgColor(Color.black2);
              
          setDefaultBarFgColor(Color.blue3);
              
          setDefaultBarThickness(10);
              
          setDefaultBarThickness(11);
              
          setDefaultBarThickness(12);
              
          setDefaultBarThickness(33);
              
          setPlotType(PLOTTYPE_LINE0);
              
          setPlotType(PLOTTYPE_LINE1);
              
          setPlotType(PLOTTYPE_LINE2);
              
          setPlotType(PLOTTYPE_LINE3);
              
              
          Symbol1 "$playback";
              
          Interval1 "1M";    
              
          }

          function 
          main() {

          var 
          TT3 = (0);
          var 
          WW3 = (2);
          var 
          QQ3 = (-2);

          var 
          wer efsExternal"TEST55.efs");


           
              return new Array ( 
          TT3WW3QQ3wer);
              

          Comment


          • #6
            Hello Alan,

            I'm a bit confused as to what you are trying to accomplish. As I stated previously, the setGloblaValue/getGlobalValue routine should only be used to pass data form one study to another that are processing in real time. There is no historical synchronization being performed for this routine, which is creating the problem you are seeing. Your Test55 and Test33 studies are also hard coded to use the sma series on the "$playback,1M" symbol/interval, which will not receive any updates in real time. The current set of logic that you are using cannot be expected to work on the historical bars or in real time.

            Are you trying to plot the ma cross of the 1-minute chart of $INDU on a 10T chart of $INDU? Please clarify.

            If so, then change Symbol1 in main to getSymbol(). Then just run Test55 (same for Test33) on the 10T chart and skip the setGloblaValue/getGlobalValue routine altogether.

            The error message you are getting from Test99 means that the file, Test55.efs, is not in the same folder as Test99. When you don't specify the path to the file, it looks to the same folder where the parent study resides.

            var wer = efsExternal( "TEST55.efs");

            Check your path and enter something like below.

            var wer = efsExternal( "\\Formulas\\somotherFolder\\TEST55.efs");


            Also, just a suggestion, but I think the way you are declaring your sma studies with offsetSeries and eval is unnecessary since the specified offset is 0. Perhaps you have some other purpose, but if not try replacing that code with the following.

            PHP Code:

            //x1MA1 = offsetSeries(eval(sma)(5,eval(close)(symvSymbol1))),0);
            //x1MA2 = offsetSeries(eval(sma)(21,eval(close)(symvSymbol1))),0);

                
            if (x1MA1 == nullx1MA1 sma(5close(sym(vSymbol1)));
                if (
            x1MA2 == nullx1MA2 sma(21close(sym(vSymbol1))); 
            Jason K.
            Project Manager
            eSignal - an Interactive Data company

            EFS KnowledgeBase
            JavaScript for EFS Video Series
            EFS Beginner Tutorial Series
            EFS Glossary
            Custom EFS Development Policy

            New User Orientation

            Comment


            • #7
              Cross Over

              Jason,

              The attached chart shows the differences in the cross overs.

              Best Regards,

              Alan
              Attached Files

              Comment


              • #8
                Cross Over

                Jason,

                Thank you for the help.

                Let me state the objective: On a 10T chart, apply an EFS which computes the cross over of 2 moving averages which are calculated on a 1 minute basis, NOT updated on a 10T basis. This means the cross overs would look similar if ploted on a 1 minute chart or on a 10T chart except for the extra distance between the cross overs on the 10T chart due to the typically larger number of 10Ticks between each 1 minute inervals.

                The preceeding post shows 2 charts. The first is a 1 minute chart with EFS TEST55 applied. (EFS follows) The second chart is a 10T chart with the same TEST55 EFS applied. Note the 10T chart has an extra cross over as reported in yesterdays post. The globalvariable has been removed and the getSymbol() has been updated as you suggested. I believe the tick chart computes on a 10T basis and this causes the extra cross over.

                The problem is I do not want the 1 minute moving averages computed each 10T and then the cross over evaluated. I only want the cross over point computed once per minute like in the 1 minute chart. This would result in the elimination of the extra cross over as shown in the second chart.

                Can this be done in the 10T EFS?

                If not, is there a way to import the cross over data from the 1 minute chart where the extra cross over does not exist and plot it on the 10T chart?

                Is there a problem in "hard coding" the "$playback, 1M" when the EFS is used in a playback mode? If I want to use this EFS for real time data I would just incert the stock symbol.

                I moved the TEST99 file into the same folder as the TEST55 EFS and the error has been eliminated. I do not get any data flowing from the TEST55 EFS into the TEST99 EFS which only plots 0. Am I missing something in either file?

                Thank you for your help.

                Best Regards,

                Alan



                /************************************************** ****
                TEST55
                ************************************************** ********/

                var x1MA1 = null;
                var x1MA2 = null;

                function preMain() {

                setStudyTitle("TEST55");
                setCursorLabelName("MA1", 0);
                setDefaultBarStyle(PS_SOLID, 0);
                setDefaultBarStyle(PS_SOLID, 1);
                setDefaultBarStyle(PS_SOLID, 2);
                setDefaultBarStyle(PS_SOLID, 3);
                setDefaultBarFgColor(Color.black, 0);
                setDefaultBarFgColor(Color.black, 1);
                setDefaultBarFgColor(Color.black, 2);
                setDefaultBarFgColor(Color.blue, 3);
                setDefaultBarThickness(1, 0);
                setDefaultBarThickness(1, 1);
                setDefaultBarThickness(1, 2);
                setDefaultBarThickness(3, 3);
                setPlotType(PLOTTYPE_LINE, 0);
                setPlotType(PLOTTYPE_LINE, 1);
                setPlotType(PLOTTYPE_LINE, 2);
                setPlotType(PLOTTYPE_LINE, 3);

                Symbol1 = "$playback";
                Interval1 = "1M";

                }

                function main() {

                var TT3 = (0)
                var WW3 = (2)
                var QQ3 = (-2)

                var vSymbol1 = getSymbol()+","+Interval1;
                x1MA1 = offsetSeries(eval(sma)(5,eval(close)(sym(vSymbol1) )),0);
                x1MA2 = offsetSeries(eval(sma)(21,eval(close)(sym(vSymbol1 ))),0);


                var M1A1 = (x1MA1.getValue(0));
                var M1A2 = (x1MA2.getValue(-3));

                qwsx = 0.0;

                if(M1A1 >= M1A2) {
                qwsx = 1.5;
                }

                if(M1A1 < M1A2) {
                qwsx = -1.5;

                }


                return new Array ( TT3, WW3, QQ3, qwsx);

                }


                /************************************************** *******
                TEST99
                ************************************************** ********/

                var x1MA1 = null;
                var x1MA2 = null;

                function preMain() {

                setStudyTitle("TEST99");
                setCursorLabelName("MA1", 0);
                setDefaultBarStyle(PS_SOLID, 0);
                setDefaultBarStyle(PS_SOLID, 1);
                setDefaultBarStyle(PS_SOLID, 2);
                setDefaultBarStyle(PS_SOLID, 3);
                setDefaultBarFgColor(Color.black, 0);
                setDefaultBarFgColor(Color.black, 1);
                setDefaultBarFgColor(Color.black, 2);
                setDefaultBarFgColor(Color.blue, 3);
                setDefaultBarThickness(1, 0);
                setDefaultBarThickness(1, 1);
                setDefaultBarThickness(1, 2);
                setDefaultBarThickness(3, 3);
                setPlotType(PLOTTYPE_LINE, 0);
                setPlotType(PLOTTYPE_LINE, 1);
                setPlotType(PLOTTYPE_LINE, 2);
                setPlotType(PLOTTYPE_LINE, 3);

                Symbol1 = "$playback";
                Interval1 = "1M";

                }

                function main() {

                var TT3 = (0);
                var WW3 = (2);
                var QQ3 = (-2);

                var wer = efsExternal( "TEST55.efs");

                return new Array ( TT3, WW3, QQ3, wer);

                }

                Comment


                • #9
                  Cross Over

                  Jason,

                  In the following post, I earlier indicated a problem with the TEST99 EFS not picking up the TEST55 data. I resolved this by removing the first 3 variable returns in TEST55 and only retuning the single cross over variable. When I run the revised scripts, I still get the extra crossover in the exact same spot as aplying the TEST55 1 minute cross over to a 10T chart.

                  Does this mean the efsExternal function calls the entire 1 minute efs every time a 10T is plotted on the 10T chart and that is how it picks up the extra cross over?

                  Best Regards,

                  Alan

                  Comment

                  Working...
                  X