Announcement

Collapse
No announcement yet.

Getting value of prior efs indicator value

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

  • Getting value of prior efs indicator value

    Folks,

    I'm a little stumped as to how to get the last five bars (could be any number, 5 is what I am interested in) of an indicator. Why? Instead of looking at just the current symbol value and indicator value I want to compare the indicator value to the last 5 bars of the indicator value and do a range check. If the last five bar are within a similar range, I want to do nothing. If there is a signficant change, then I want to trigger an action.

    To make things difficult, this isn't from a built-in but a custom formula.

  • #2
    this will help you find the highest hi of the last bars, there is a LL function in the Helpers folder

    function preMain() {
    setPriceStudy(true);
    }

    function main(nInputLength) {
    if(nInputLength == null)
    nInputLength = 20;

    var nLength = nInputLength;
    var i;
    var hh = 0;

    var vValues = high(0, -nLength);
    if(vValues == null)
    return null;

    for(i = 0; i < nLength; i++) {
    if(i == 0) {
    hh = vValues[i];
    } else {
    hh = Math.max(hh, vValues[i]);
    }
    }
    return hh;
    }

    Comment


    • #3
      Looking at past indicator values..

      Here is an example of retrieving stochastics values from the past and current.

      PHP Code:
      var study = new StochStudy(523);
      var 
      LastStoK = -1;
      var 
      LastStoD = -1;


      function 
      main()
      {
      //  get current indicator values..
       
      var vFast study.getValue(StochStudy.FAST);
       var 
      vSlow study.getValue(StochStudy.SLOW);


      //  get previous indicator values..
       
      var LastStoK study.getValue(StochStudy.FAST, -1);
       var 
      LastStoD study.getValue(StochStudy.SLOW, -1);

      //  adding -2, -3, -4 and recording these values, should give you the values you want.

      Brad
      Brad Matheny
      eSignal Solution Provider since 2000

      Comment


      • #4
        Hmmm.

        Well, here's the trick though. And it's quite possible I'm just being thick. Unfortunately the efs in question is totally custom. It does not call any built-ins at all and therefore the sample you kindly provided won't work. Or will it?

        I guess I can make the efs more generic (it has a rather lengthy strategy component) and then create yet another study to call it from and see if that method you just supplied worked. That's going to increase overhead, but I guess that cannot be helped.

        Comment


        • #5
          custom indicator tracking...

          DeepFoo.... (cool handle - won't ask).

          Then your solution is simple... You need to create variables that track the last values of the indicator before you record the new value.. To do this based on a bar-to-bar basis, you would use something like...



          PHP Code:
          var lastbardate 0;
          var 
          indicatorminus1bar 0;
          var 
          indicatorminus2bar 0;
          var 
          indicatorminus3bar 0;
          var 
          indicatorminus4bar 0;
          var 
          indicatorminus5bar 0;

          function 
          main()
          {

           if (
          getValue("rawtime"0) != lastbardate) {
             
          //  record previous indicator values.
             
          indicatorminus5bar indicatorminus4bar;
             
          indicatorminus4bar indicatorminus3bar;
             
          indicatorminus3bar indicatorminus2bar;
             
          indicatorminus2bar indicatorminus1bar;
             
          indicatorminus1bar CurrentIndicatorvalue;
             
          lastbardate getValue("rawtime"0);
           }

          // calculate indicator.
          CurrentIndicatorvalue calculateyourindicator.....


          This will record the previous 5 bars indicator values for you to use and recall...

          Brad
          Brad Matheny
          eSignal Solution Provider since 2000

          Comment


          • #6
            deepfoo,

            I'm a bit confused, are you trying to just get the last five values of the same efs, or are you calling another EFS and trying to get the last five values?

            There are fairly simple ways of doing both.
            Garth

            Comment


            • #7
              to GSpiker

              What I am trying to get and compare are the last five values (may want to play with this a bit, maybe an average of the last ten, not sure yet) that the efs produces. Not the price, but the indicator value itself.

              The idea is that this is a directional indicator which sometimes gives "bad" signals. What I am trying to do is look back and make sure within some range that a turn in the indicator has really takne place to avoid whipsaws.

              Make sense?

              Sorry, I'm just not a ecmascript whiz. I'm sure it is simple to plug these values into variables and then calc them against the current one, but it might as well be rocket science for me. And yes, I'd prefer to do all this inside the original efs itself and not make a call.

              Comment


              • #8
                OK then...thanks. That is pretty easy.

                Use the ref() command.

                ref(-1,-5);

                That should get you the last five values that the study returned (not counting the current bar).

                Does that help?
                Garth

                Comment


                • #9
                  A little more info Garth...

                  DeepFoo stated it is a custom indicator... so I assume it is programmed into EFS and not being called as a builtin indicator. Does your advice still hold true...

                  I was under the assumption that custom EFS indicators do not act like builtin indicators??

                  I'm sure my solution will work because I have it working with the Ergotic TSI indicator.

                  Let me know...

                  Brad
                  Brad Matheny
                  eSignal Solution Provider since 2000

                  Comment


                  • #10
                    Brad,

                    I just think you were taking it a bit further than he needed. If I understand correctly deep just wanted the EFS to reference its own return values. Which is what ref() is for.

                    Garth
                    Garth

                    Comment


                    • #11
                      ref() function

                      gspiker,

                      that sounds perfect as i assume this will let me pluck any range i like....

                      here is the next problem. the docs for this are offline at the moment as the links were updated recently i guess and point to a network or local drive instead of the correct page.

                      do you happen to have the doc? if you can cut and paste in the ref() stuff that would be great

                      Comment


                      • #12
                        Hi,

                        Yes you can reference as far back as you need.
                        It is really the same as getValue() in many ways.

                        ref(Offset,Number of bars).

                        I don't have access to the doc's, but there is this link that might (or might not) help:

                        http://forum.esignalcentral.com/show...=&threadid=517
                        Garth

                        Comment


                        • #13
                          Ah-ha...

                          I think this ought to do it. And now I know why I couldn't find docs anywhere on this, it apperas to have been largely undocumented. I found the efs samples though in file share. thanks.

                          I may also need to look at Brad's solution as well. Not quite sure which is going to work. The real challenge I guess is applying logic to make sure the results are valid.

                          Comment

                          Working...
                          X