Announcement

Collapse
No announcement yet.

Interval calculation in lower time frame

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

  • Interval calculation in lower time frame

    When using :

    if (nState == BARSTATE_NEWBAR)
    xStochK = stochK(27,13,13,inv(myFp[x]));

    where myFp[x] = 30, and I am running on a 2 minute chart, returns the 30 minute stochastic calculated at the 2 minute interval - that is, I will get 15 different fluctuating values during the 30 minute period, rather than the value at the close of the last 30 minute bar.

    How can I return the value at the close of the last 30 minute bar, at the close of each 2 minute bar, and only return a new value every 15 X 2 min bars? I suspect I will need to keep track of time and calculate my own 30 minute open/close times, however am not sure how to do this.

    Hope I explained that ok, and appreciate any help.

    Cheers

  • #2
    Anyone from eSignal want to respond to this before it get's lost in the bowels of the forum? Did I give sufficient info and explanation? Appreciate any help.

    Cheers.

    Comment


    • #3
      Here is a screenshot of my EFS result, the top indicator being calculated live using the code below, and the bottom indicator (same code) loaded when the market closed. The results are different, with the one loaded after the event using the value of the last bar of each time period for it's calculation. The live display uses the value of the longer period, as at each time period of the chart when the calculation was made. (the completion of each 2 minute bar).

      Anyone prepared to offer a suggestion on how I may force the use of the actual bar calculation of the longer period?
      Attached Files

      Comment


      • #4
        Hi,

        PHP Code:
        if (nState == BARSTATE_NEWBAR)
        xStochK stochK(27,13,13,inv(myFp[x])); 
        Some things that may help.

        Notes:

        1 -BARSTATE_NEWBAR- is true only on the first tick of a new bar and not on the last tick of the last bar.
        2 Try -getBarStateInterval("interval")- if you want to execute code based on the first tick of the new bar of the external interval.
        3 I think that the problem lies in the -myFp[x])=- part of the code. Consider -debugPrintln(myFp[x]);- just before this code to veryfy that the output is 30 as you intend. Also you could verify this by replacing -inv(myFp[x])- with -inv(30)- the code should then work fine.



        Here are some forum posts that may help you figure it out.





        Wayne
        Last edited by waynecd; 04-30-2010, 10:06 PM.

        Comment


        • #5
          Thank you, Wayne. Wasn't aware of the "getBarStateInterval" statement. You have given me enough to keep me moving, and I am grateful. My interval logic is correct, and the barstate referenced is the working time frame (2 minutes). Being able to reference the external timeframe with getBarStateInterval is the missing piece of the puzzle.

          Cheers.
          Last edited by merkro; 04-30-2010, 10:13 PM.

          Comment


          • #6
            Hi,

            Thats great.

            Wayne

            Comment

            Working...
            X