Announcement

Collapse
No announcement yet.

getValue syntax

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

  • getValue syntax

    Good Morning,

    Is there a way to change the syntax or structure of the moving average formulas in the following portion of an EFS to force the getValue command (including the look back in variable M1A2) to calculate the 1 minute moving average on a 1 minute only bases and not on each tick when this EFS is applied to a 10 tick chart for both real time and playback modes?

    Best Regards,

    Alan




    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 (qwsx);

    }

  • #2
    Alan
    You can enclose your conditions inside a getBarStateInterval("1")==BARSTATE_NEWBAR statement to force the formula to evaluate them only at the completion of the higher interval (note that the interval inside the brackets must be a string hence the "1")
    In doing that you will however need to reference the prior bars ie getValue(0) and getValue(-3) need to be getValue(-1) and getValue(-4) respectively. The logic is exactly the same as if you were using getBarState()
    Alex

    Comment


    • #3
      getVaule

      Alex,

      As always, thank you for the kind help.

      The following EFS is an attemp to implement your suggestions. When I enter getBarStateInterval into the EFS, it does not turn blue like getBarState. When I searched the Knowledgebase there is no referance to this command. This EFS returns 0 when plotted.

      Your continued assisatance is appreciatated.

      Version 7.91 Build 732

      Best Regards,

      Alan


      /************************************************** ****
      TEST55c
      ************************************************** ********/

      var x1MA1 = null;
      var x1MA2 = null;

      function preMain() {

      setStudyTitle("TEST55c");
      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)

      if(getBarStateInterval("1")==BARSTATE_NEWBAR){

      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(-1));
      var M1A2 = (x1MA2.getValue(-4));

      }

      qwsx = 0.0;

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

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

      }


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

      }

      Comment


      • #4
        Alan
        It does not turn blue because that function has not yet been added to the list of efs keywords. That however does not imply that it will not work.
        As to the documentation for that function click here and download the updated EFS2 chm file saving it in the eSignal directory. This is the Help file that is accessed directly from within the Formula Editor
        Alex

        Comment


        • #5
          getValue

          Alex,

          I downloaded the file and located getbarstateinterval in the index but the page will not open. I tried just opening the file again without saving it and the same problem occurs.

          Is there a setting I need to change to accesss this file?

          Best Regards,

          Alan

          Comment


          • #6
            Alan
            Not that I am aware of. However someone else was having a similar problem so you may want to try searching the forum
            Alex

            Comment

            Working...
            X