When the efs engine calculates rsi(10, atr(5)), or similar.
All is fine under computeOnClose() or running normally.
However, I want to create a custom nested indicator using
efsInternal so cannot use computeOnClose() and as I do not
want to overload my cpu every tick I wanted to use GetBarState()
and only calculate on a NEWBAR.
The problem is that this barState method produces erratic results
which I just cannot get to the bottom of. I am fairly confident
that the logic is correct but if after loading two examples of
the nested indicator and leaving them for several bars, I then
'reload' one of them, it redraws a line which is substantially
different from the other copy. More importantly any further
calculations are erroneous. I've been struggling with this for a
while now and this simple example is the distillation from much
more complex indicators all of which are erratic!
All is fine under computeOnClose() or running normally.
However, I want to create a custom nested indicator using
efsInternal so cannot use computeOnClose() and as I do not
want to overload my cpu every tick I wanted to use GetBarState()
and only calculate on a NEWBAR.
The problem is that this barState method produces erratic results
which I just cannot get to the bottom of. I am fairly confident
that the logic is correct but if after loading two examples of
the nested indicator and leaving them for several bars, I then
'reload' one of them, it redraws a line which is substantially
different from the other copy. More importantly any further
calculations are erroneous. I've been struggling with this for a
while now and this simple example is the distillation from much
more complex indicators all of which are erratic!
PHP Code:
var newInd = 0;
function main(){
var vState = getBarState();
if (vState == BARSTATE_NEWBAR){
newInd = rsi(10, atr(5));
} else {
return newInd;
}
//do more calculations at NEWBAR
return newInd;
}
Comment