I have the following code in my script
if(getBarState()==BARSTATE_NEWBAR && getCurrentBarIndex() == 0) {
var vMA = MA.getValue(External.MA);
}
where MA uses an external function which provides a 5 period Moving Average of the close price.
Can you please confirm that the BARSTATE_NEWBAR if statement above does the following:
Wait for first tick of a new bar then calculate the 5period MA of 5 PREVIOUS bars (i.e. bars -1 to -5) and not the current (new) bar close?
Because I think if I reload the study it slightly changes the value, making me think that in fact it calculates the 5 periods as the last 4 bars and the close of the brand new bar (which is actually the open price at the time...)?
if(getBarState()==BARSTATE_NEWBAR && getCurrentBarIndex() == 0) {
var vMA = MA.getValue(External.MA);
}
where MA uses an external function which provides a 5 period Moving Average of the close price.
Can you please confirm that the BARSTATE_NEWBAR if statement above does the following:
Wait for first tick of a new bar then calculate the 5period MA of 5 PREVIOUS bars (i.e. bars -1 to -5) and not the current (new) bar close?
Because I think if I reload the study it slightly changes the value, making me think that in fact it calculates the 5 periods as the last 4 bars and the close of the brand new bar (which is actually the open price at the time...)?
Comment