Announcement

Collapse
No announcement yet.

Array of closes from one timeframe into another

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

  • #16
    Robert,

    Regarding a barcounter, just to let you know, there is a new function, getCurrentBarCount(); which eliminates, at least in the native chart, the need to iterate a variable every newbar. This new function however would not work for keeping track of the bars from the other intervals.

    Comment


    • #17
      I have now installed 7.9.1 and looked at the functions:-

      getBarStateInterval("interval")
      getBarStateSymbol("symbol" or "symbol,interval")

      and cannot see how to use in a bar counting method as all I get is a bunch of zeros.

      What I want to achieve is a bar counting result from a higher timeframe into a smaller timeframe.

      Robert

      Comment


      • #18
        Robert
        I am not sure as to how you are using getBarStateInterval() or getBarStateSymbol() anyhow here is what I see at my end when using the enclosed script

        PHP Code:
        var vCounter 1;

        function 
        main(){

            if(
        getBarStateInterval("D")==BARSTATE_NEWBAR){
                
        vCounter++;
            }
            
            return 
        vCounter;

        The Time Template used in the charts enclosed below is set to load 10 Days of data as Intraday Default. As you can see any interval used will return correctly 9 as the count (10 being today but not plotting any data at this time)
        Alex





        Comment


        • #19
          Robert
          FWIW I have created a function library that contains the functions you mentioned (ie trueHigh, trueLow, etc).
          You can find it here together with its documentation.
          Alex


          Originally posted by rcameron
          If we could get the functions I mentioned soon that would be great, with full capability to call full arrays as well as referencing other symbols and timeframes. The formula for each function would be as follows:-

          truehigh(nOff) = Math.max( close(-(nOff+1)), high(-(nOff) )

          truelow(nOff) = Math.min( close(-(nOff+1)), low(-(nOff) )

          range(nOff) = high(nOff) - low(nOff);

          truerange(nOff) = Math.max (Math.max (Math.abs(high(-(nOff)) - low(-(nOff))), Math.abs(close(-(nOff+1)) - high(-(nOff)))), Math.abs(close(-(nOff+1))- low(-(nOff)))) );

          Comment

          Working...
          X