Announcement

Collapse
No announcement yet.

Ref values for higher interval series

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

  • Ref values for higher interval series

    What would be the proper way to retrieve the value of a series declared in an external time interval for a number of chart's bars back?

    For example, the values of a 15 min indicator 7 chart bars back, where the base interval is 2min.

    Thank you.
    Mihai
    Last edited by mbuta; 06-17-2005, 07:32 PM.
    Mihai Buta

  • #2
    To EFS Specialists,

    I assume [because nobody replied] that there is no way to access external interval based indicators value for a number of base chart bars back.

    I would appreciate a confirmation of this conclusion from EFS specialists.

    Thank you.
    Mihai Buta
    Mihai Buta

    Comment


    • #3
      Hi Mihai,

      That depends, if the value you wish to return is part of the regular base chart return then you can use ref(-x) ie:

      PHP Code:
      function main() {
         var 
      someCalcValue = ...
         var 
      valueToRetrieveLater ema(20inv(15));

          var 
      v7BarsBack ref(-7);
          var 
      valueToRetrieve v7BarsBack[1];

          return new Array(
      someCalcValuevalueToRetrieveLater);

      then you can use ref(-7) to retrieve the array at that chart bar, and then take the 2nd element.


      Using the ema(20, inv(15), -7) as you've probably discovered sync's up the 15 interval to the current 2 min interval, but then takes 7 bars back on the 15 min interval instead of the chart base interval.

      The first iteration of EFS2 a year ago originally did this (chart base interval instead of external time interval), but was changed since the current way made more sense to everyone.

      It's quite possible to set an option to retrieve the 'old' way, if you really need it, but it won't be done for 7.9.1, which is in the later stages of testing already.

      Or, you could try something with efsInternal(). I haven't tested this to see if it will work, but it should:

      PHP Code:
      function main() {
          var 
      unsyncedEMA15 efsInternal("unsyncedSeries");
          var 
      v7BarsBack unsyncedEMA15.getValue(-7);

          return 
      whatever;
      }

      function 
      unsyncedSeries() {
          return 
      ema(20inv(15));

      Actually this probably won't work as the initial starting point is not sync'd.

      Note to other readers, if you wish to sync an efsInternal(), efs() or efsExternal() to the current timeframe, pass in the inv() or sym() as the last parameter to those efs*() functions. Since we didn't do that above, the Series will be returned as a raw value.

      My suggestion for you Mihai is to keep track of that chart value x bars back, if not using ref(-x) (I assume you're not plotting that value, but merely using it other calculations), then use your own Array (scoped outside of your main()), to which you maintain 7 elements, inserting at the end, and removing from the top, when it's filled up, the top of that Array that you manage will hold the value that you need.

      Comment


      • #4
        Hi Dion,

        Thank you for clarifications.

        I believe that both ways of retrieving external interval values make sense, but based on base interval even more so [at least for me].

        All decision are made in base interval. Pivots, divergencies, are all based on base chart bars. Personally, I don't know when/why I would need to refer to external interval bars, but maybe others need them.
        Please consider keepping both and to have them available.
        In the mean time, I will stick with my emmulation of higher inrtervals, because there I can retrieve them as I want.

        Thank you.
        Regards,
        Mihai
        Mihai Buta

        Comment


        • #5
          Dion, one more question please.

          Is there any reason why base inteval series don't "fill-back" to the first bar, like those declared in an external time interval do?

          This would really help us reduce the overhead, by reducing the number of bars needed. For example, now I need about 600 bars to get 300 useful [CCI eats a lot of them].
          Note: I tried the FillBack feature of EFS2, could not make it work.

          Thank you.
          Mihai
          Mihai Buta

          Comment


          • #6
            Not sure I understand?

            Comment


            • #7
              Mihai

              Is there any reason why base inteval series don't "fill-back" to the first bar, like those declared in an external time interval do?

              Studies declared on an external interval don't actually "fill-back". What you refer to is only an effect caused by the fact that the data of the external interval (which is usually higher) tends to begin further back in time than that of the chart interva for the same number of barsl. So, at the point in time where the lower interval chart begins, the study is already primed on the higher interval and plots from the first bar of the lower interval. However if you switched that same chart to the higher interval you would see that it takes the study the same amount of bars to prime.
              In the chart below you can see a practical example of this. I have set the Time Template for the Daily interval to load only 10 days. As you can see on the 60 minute chart (also set to plot 10 days) the average which is based on Daily starts exactly on the same bar in which it starts on the higher interval ie there is no fill-back.
              The setIntervalsBackFill() statement will not resolve this because it is used to compensate for the reverse situation ie a lower external interval study plotted on a higher interval chart
              Alex

              Comment


              • #8
                Dion, Alex,

                Maybe I did not explained it right. The picture blow clarifies the issue:



                This is cci(10), cci(20), cci(20,inv(15)), cci(20(inv(30)). The base interval is 5min.

                You can see that 15min and 30 min plots start at first bar, whereas 5min plots start only after the needed number of bars to calculate them [like in EFS1] elapse [regardless of the higher interval].

                My question was: why the base interval plot can't plot from bar 1? In other words, to be treated same way as higher intervals are [data is there, available anyway].

                Thank you.
                Mihai
                Mihai Buta

                Comment


                • #9
                  Sorry, it seems logical to me =).

                  You're only requesting 600 bars worth of 5 min data, so that's what you've received from the server.

                  The EFS engine is applying the same time template to the 15 and 30 min chart, so it's requesting 600 bars there too, which end up way BEFORE the start of your 600 bars of 5 minute data.

                  Have you considered using a Dynamic time template?

                  Comment


                  • #10
                    I see. Did not think it is requesting 600 bars of higher interval. If it does, it makes sense, of course.

                    So, how can we "fake" the same thing in base interval?
                    Because, like I said, instead of cci(20, inv(30)), I am using cci(20*6) and takes 240 bars to get it plotted.

                    I did try Dynamic template, but did not see any diference. If I should, I will look again, maybe my setting were wrong.

                    Thanks,
                    Mihai
                    Mihai Buta

                    Comment


                    • #11
                      Hi,

                      Dynamic time template does dot change anything.

                      Mihai
                      Mihai Buta

                      Comment


                      • #12
                        There isn't much that you can do, the time template will retrieve what you tell it, the base interval will always have a 'blank' number of bars before it has enough for calculations. The reason why the higher ones don't have any is that those bars aren't displayed. Ifyou need more, then just request 1200 bars instead of 600.

                        Comment

                        Working...
                        X