Arrays with 1 tick data strange behaviour summing twice in the same bar

Forums ProRealTime English forum ProBuilder support Arrays with 1 tick data strange behaviour summing twice in the same bar

Viewing 10 posts - 1 through 10 (of 10 total)
  • #161988

    I’m trying to build a sort of volume profile indicator, using 1 tick chart data with arrays (PRT v11).
    I noticed something strange that I cannot explain myself.
    I don’t know if it’s linked to arrays, but probably is…

    From a vertical green vertical line (see code) to the following the volumes written should only increase for each level defined by a volumeBarWidth interval.
    Each time that a new bar appears I check volumes and add to that specific level in a precise position in one of the two arrays ($south and $north).

    On historical data all is fine, the problems appear when I leave it run live.
    When live it seems that sometimes the volumes are added twice (when lines “$north[i] = $north[i] + volume[1]” or “$south[i] = $south[i] + volume[1]” should add that just once).

    This is the code:

    In the picture attached there is an example of the problem that I spot when it runs live.
    See the green/red arrows and the text that I drawed with the cumulated volumes for that level since the green vertical line. The volume there was just 1.
    It grows from 5 to 7 when it should just grow by 1 (the volume column)…

    #162000

    Indeed, your logic is right, if volume[1] = 1, then your array should only have gain 1, since the 1-tick chart only last 1 tick!

    Does it happens a lot or only once in a while?

    #162017

    Unfortunately, it happens very often. 🤔
    So often that my volume profile is to be thrown into the trash for live. 😅

    #162023

    Try this one on one tick (I tryed on DAX), even more simple. And take a look at the image attached.
    The problem is big, and I think that must be fixed…

    If you replace a “$i[0]” with a normal variable all works correctly…

    #162089

    I attach here a video of the previous code launched on XBTUSD 1tick.
    From that video it’s clear that the bar is updated two times (looking at the current tick, then a new tick comes, check there if the value has changed).
    Apparently today on XBTUSD 1 tick it always add the amount twice, but what I noticed yesterday on dax is that sometimes it doesn’t always happen (I’ll check that again on monday with open markets).
    In the meanwhile I have sent a technical report with a link of this thread.
    If others sees the same problem on their platform maybe can do the same.

    Anyway I have tried on any other timeframes the same code and I checked that the letter changes each tick… And that’s ok, if they should work like that it’s fine…
    But on 1 tick bars even if the tick is only one seems to execute two times…

    #162095

    I noticed that for N ticks bars it runs N+1 times the “$i[0] = $i[0] + 1“, I think once for each tick plus the “close” when a new tick/bar comes… For tick timeframes I don’t think that this behaviour really makes sense (the last update don’t make sense I think)…
    I attach the video that I forgot to attach in the previous message.

    #162112

    Anyway at the moment I have found a workaround that seems to work…
    The idea is the following one:

    In this way I exploit this array behaviour for my own purpose, forcing it to update just once (the “$north[i] = $north[i] + volume[1]” should be executed just once with that).
    I don’t know if there are more elegant solutions… But for the moment I’ll go on with that.

    #162318

    I’m testing this code, in order to replicate that behavior, on DAX 1-tick, no problem until now, but I will let it run..

     

    #162343

    From that code you’ll always see a 1, even if the code is executed twice inside the same tick bar you’ll always have a 1.
    Anyway in this moment I don’t know if they just were build to work like that…
    It’s a little bit counterintuitive (because $name[0] is treated differently inside of the code from any other variable in the code, see #162023)… but now that I know how they work I can deal with that…

    Test a code like this to see the difference between historical and live behaviour of summation on an array:

    For me the strange thing is that the sum is executed twice on a live single tick bar (the first for the tick and the latter for the “closure” of the same tick which technically does not exist)… that’s all. But if they are designed to work like that… that’s fine…

    #162345

    ok, that’s clear for me now, i can replicate it with this  version of your last code:

    I’m trying to get more info and let you know.

    1 user thanked author for this post.
Viewing 10 posts - 1 through 10 (of 10 total)

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