Skip to content

fix(MultiMarketPower): guard OnCalculate forward-fill against bar 0 - #181

Open
AlbertoAmadorBelchistim wants to merge 1 commit into
AtasPlatform:Developfrom
AlbertoAmadorBelchistim:fix/multimarketpower-bar-zero
Open

AlbertoAmadorBelchistim wants to merge 1 commit into
AtasPlatform:Developfrom
AlbertoAmadorBelchistim:fix/multimarketpower-bar-zero

Conversation

@AlbertoAmadorBelchistim

Copy link
Copy Markdown
Contributor

Split out of #173 as requested in the review.

OnCalculate forward-fills empty values of the forming bar from the previous bar:

if (ds is ValueDataSeries vds && vds[bar] is 0)
    vds[bar] = vds[bar - 1];

When the forming bar is bar 0 (a chart with a single bar, e.g. right after the history response on a new instrument or a very short range), bar - 1 is -1 and the indexer is called with a negative index. The fix returns early for bar 0, where there is no previous value to carry forward:

if (!_bigTradesIsReceived || bar != CurrentBar - 1 || bar == 0)
    return;

No behavior change for any other bar. Single-line change, rebased on the current Develop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant