Inconsistent BARINDEX and BARDATE returns

Optuma Forums Optuma Scripting Inconsistent BARINDEX and BARDATE returns

  • This topic has 5 replies, 2 voices, and was last updated 1 month ago by Mark.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #68893
    Mark
    • Topics: 2
    • Replies: 4
    • Posts: 6

    Hi all.

    I’ve just started to get into Optuma scripting and have found something that seems a little odd. I have an ASX200 watchlist and am checking both BARINDEX(Week()) and BARDATE(Week()) functions to later build into another script. I have end of day data and I would expect both functions to output the relevant value for the end of the current week (for listed stocks). However today (with Monday EOD data) I have 9 stock codes (TAH, SCG, MGR, LTR, LNK, GUD, CNU, BGA and A2M) with last week’s EOW position/date respectively.

    I’ve also taken a look at these using DAYOFWEEK(DAY()) to check which day is being attached to the data and it reports Friday (6) as opposed to the Monday (2) reported for the rest.

    Has anybody come across this before? I’m sure there are many gaps in my knowledge at this stage of my learning and am more than open to all suggestions as to how to work around this!

    Thanks in advance,
    Mark

    • This topic was modified 1 month ago by Mark.
    #68899
    Darren
    • Topics: 70
    • Replies: 871
    • Posts: 941

    Hi Mark,

    All charts will have the same BarDate for a given day, but not the same BarIndex as they are counting different things.

    The BarDate value (ie 44,764 for Friday) is the number of calendar days since December 31st, 1899.

    The BarIndex value is the number of data bars available for a chart, and because stocks have different starting dates the BarIndex values will therefore be different. Put two Show Views below a chart, and change one to BARINDEX() and the other to BARDATE() to plot the values and you’ll see the difference.

    Additionally, when you switch timeframes from a daily to weekly chart there are fewer bars on the chart, so the BarIndex value will  be lower (the BarDate on a weekly will always be Friday’s value).

    If you can explain in more detail what you are trying to achieve we can point you in the right direction, or arrange a consultation and help build it for you.

    #68903
    Mark
    • Topics: 2
    • Replies: 4
    • Posts: 6

    Hi Darren and thanks for the quick response.

    Your notes are in line with my expectations after reading the knowledge base files regarding the functions however my observations didn’t coincide.

    It’s a new day today and the BARDATE and BARINDEX functions are working as expected after the data were updated. What I *think* may have happened is that I opened Optuma around market close and received an incomplete update due to my time zone; perhaps in that moment the data came through incomplete with the 9 stocks still reporting Friday’s data but showing Monday’s chart?

    Unfortunately I didn’t take a screenshot but the 9 stocks mentioned in the OP showed the end of last week’s bar with the BARINDEX function (as in, the bar position number on the chart could indicate 809 for example but the function would show 808) and the BARDATE showed the previous week’s EOW for the same stocks; the functions seemingly failing to recognise the last bars that were plotted in the chart.  It was curious. I’ll try and replicate it and show you what I mean but I’d be semi certain that it was something to do with the time of day that dataset was updated.

    Ultimately I’m trying to create an script to identify when Gann trend lines are potentially available to confirm – 12 bars minimum in the count with 3 higher lows (or lower highs) – I’d love to use the BARINDEX function to log the positions of the swing points (eg S0 = position 900, S2 = 896, S4 = 890 would fail the test as there are <12 bars in the sequence) so am working towards something along those lines. Something similar to a BARID(Week(), S0…S4) function of sorts to reference these points is what I’m chasing so I can do the count but I assume there’s a function not yet in my repertoire that will do the job…

    #68907
    Mark
    • Topics: 2
    • Replies: 4
    • Posts: 6

    Hi again.

    Managed to capture another example of this; screenshot attached. It’s a work in progress so please excuse the scrappiness.

    The daynum column highlighted contains the script bardate(Day()) and [Script12] is the script:

    a1=last(bardate(Day()));
    strdate(a1)

    It’s ugly but I’ve been using it to check for non-active stocks – where the daynum result <> Script12 there is a difference between the last bar on the chart and today’s date – thus the stock can be ignored for further scripting. However, today it seems Orica is on the 02/08 date and the rest are on 03/08. I’ve closed and reopened the sheet to see if it’s an update issue but no change was observed.

    Hopefully this is a bit clearer?

    Screenshot 2022-08-03 204028

    • This reply was modified 1 month ago by Mark.
    #68919
    Darren
    • Topics: 70
    • Replies: 871
    • Posts: 941

    OK thanks. Not sure why it’s returning those numbers but send the workbook to support and we’ll take a look.

    In the meantime, have a look at the SwingStat() function: that calculates various measures for the swings – including length. This will count the length of the latest confirmed swing:

    For each previous swing add the [x] offset to the end, so if the current swing is up adding [2] to the end will calculate the length of the previous swing up.

    In this example, the current swing up is 12 bars, twice as long as the previous swing up (6), and one day longer than the preceding down swing (of course, the current length could change depending on what happens with the next bar: if it’s higher than 96.05 then the count will increase to 15).

    Capture

    • This reply was modified 1 month ago by Darren.
    #68927
    Mark
    • Topics: 2
    • Replies: 4
    • Posts: 6

    Thanks again Darren; I’ve sent through the workbook and we’ll see how it goes.

    Thanks also for the SwingStat() function idea – I’ll try and work out how to integrate it into my counts as I’d like to have a minimum of 12 bars with 3 higher swing lows (in the case of looking to establish a new uptrend line) before triggering.

    Have a great weekend!

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

Pin It on Pinterest