Sorry for all the newbie questions. I'm looking at the BarIndexes.efs script, and I see where the script labels the bars using the getCurrentBarIndex() value. However, in other scripts I see the call to a series object (such as on created from stochK and stochD) using 0, with the comment that that's the current value (e.g., myStochD.getValue(0)), even when processing historical data (i.e., non-streaming). And, in running such a script, that seems to be fine.
The documentation says that getValue() takes an argument that is the bar index. So the concept of the 'current' bar index as returned from getCurrentBarIndex() seems to be different from that expected by a series object's getValue() method.
Is it that a series object, while processing historical bars, is 'current' with the bar being processed, so a value of 0 is to be used?
Here's a script that uses getValue(0) to return the plotted value in all cases, historical bars and streaming.
Why wouldn't the argument to getValue() not have been the return from getCurrentBarIndex()?
Thanks.
The documentation says that getValue() takes an argument that is the bar index. So the concept of the 'current' bar index as returned from getCurrentBarIndex() seems to be different from that expected by a series object's getValue() method.
Is it that a series object, while processing historical bars, is 'current' with the bar being processed, so a value of 0 is to be used?
Here's a script that uses getValue(0) to return the plotted value in all cases, historical bars and streaming.
PHP Code:
function preMain() {
setPriceStudy(false);
setCursorLabelName('gts.%K', 0);
setStudyMin(0);
setStudyMax(100);
setDefaultBarFgColor(Color.blue, 0);
}
//global Series Object variables
var QldKSeries = null;
function main() {
if (QldKSeries == null) QldKSeries = stochK(14, 1, 3);
return QldKSeries.getValue(0); // Current Bar Index value
}
Thanks.
Comment