BarIndex not correct

Forums ProRealTime English forum ProScreener support BarIndex not correct

Viewing 7 posts - 1 through 7 (of 7 total)
  • #178124

    I am having a fundamental problem developing a screener… I don’t appear to understand the bar indexes.

    Working on a screener on the monthly timescale, and I am finding that BarIndex, and indeed using many functions that should act on the current bar, simply do not work as I would expect.

    For example, BarIndex is always 2 lower than the actual number of bars displayed in the chart (easy to see on stocks that haven’t been around long) and ‘low’ is returning the low of the previous bar, not the current bar… doing low[0], returns the same value.

    What I am assuming is that BarIndex actually returns the index of the first bar in the data, not the count of bars as described in the documentation, but what I don’t understand is why the current bar is not bar 0.

    This disparity is making things like this script to detect when a stock set an ATL last month to break completely.

    I am able to get around the BarIndex issue by using BarIndex+1… for example to find the All time low price I have to use

    Or it ignores the price of the first month… which can be important.

    But I have no idea how to get the low of the current bar as index 0 always seems to point to the previous bar, thus ‘low’ and ‘low[0]’ return last months low; ‘low[-1]’ give me an index error.

    Can someone please explain to me the logic of the way the bars are indexed?

    Also, is the a quick way to return the index of the bar rather than the price when using lowest or highest, or perhaps a way to look up the index using a price once I have it.

    Finally, why is there no search on these forums… I tried using the search under my profile picture, but it returns stuff from all over, not just this forum.

    #178129

    To try and answer my own questions I created an indicator:

    RETURN barIndex as "barIndex"

    And it shows the first/oldest bar being bar 0.  So that clears somethings up for me.  That should make the current bar’s index barindex (makes sense).

    I think my confusion was that low and lowest take an offset from the current bar.  So when you do lowest[barindex] your saying to look back that many bars… but because bars start at 0, you need to add one to barindex it to include bar 0.

    However none of this explains why lowest and low ignore the current bar…. when I graph barindex, the current bar is given a value, so I would think low[0] should return the low of the current bar, but it returns the low of the previous complete candle.

    #178131

    Low[0], or simply Low, is the current bar’s Low.

    Unless you have end-of-day data, in which case candles are updated with 1-bar delay.

     

    #178133
    JS

    About the Index, when an index runs from 0 to 10 (0 1 2 3 4 5 6 7 8 9 10) then the actual number of bars  is 11

    N = 11

    i = 0 to 10

    #178136

    Low[0], or simply Low, is the current bar’s Low.

    Unless you have end-of-day data, in which case candles are updated with 1-bar delay.

    This may be my problem? I am on the “end-of-day” plan while I evaluate the tool, I wonder if this prevents use of the current bar in higher timeframes a well? If so, I think that might be frustrating for users like me. I want to get ATH and ATL data, so using monthly and yearly timeframes is the only way that would be possible, but if I cannot look at the most recent year or month (up through yesterday’s close), then I may miss an important data point in my scan.

    #178138

    End-of-day data means your are always one bar behind.

    One day on the daily TF, one week on the weekly TF, and so on…

    That should not affect your evaluation. You can make any test you want with indicators, screeners and strategies on past data.

     

    #178330

    End-of-day data means your are always one bar behind.

    I was afraid of that. While it makes sense on daily, its much more challenging for higher timeframes. I suppose I can test in multiple timeframes to find the actual lowest price as of yesterdays close.

Viewing 7 posts - 1 through 7 (of 7 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login