In the following simple script, I am finding that I must reload the file for real-time values.
function preMain() {
setStudyTitle("Code Test");
}
function main(nBars) {
if(nBars == null)
nBars = 5;
var vStudy1 = new MAStudy(nBars, -1, "OHLC/4", MAStudy.SIMPLE);
var vStudy2 = new MAStudy(nBars, 0, "OHLC/4", MAStudy.SIMPLE);
var vMALastBar = vStudy1.getValue(MAStudy.MA);
var vMAThisBar = vStudy2.getValue(MAStudy.MA);
if(vMALastBar > vMAThisBar) {
setBarBgColor(Color.lime);
}
else if(vMALastBar < vMAThisBar) {
setBarBgColor(Color.red);
}
else if(vMALastBar == vMAThisBar) {
setBarBgColor(Color.yellow);
}
}
Sure, I could call
setComputeOnClose();
But that negates the real-time features that I need.
Further, each time a new price bar starts, it always the background color is always red. Will fixing the first issue address this as well?
Thanks in advance,
Greg
function preMain() {
setStudyTitle("Code Test");
}
function main(nBars) {
if(nBars == null)
nBars = 5;
var vStudy1 = new MAStudy(nBars, -1, "OHLC/4", MAStudy.SIMPLE);
var vStudy2 = new MAStudy(nBars, 0, "OHLC/4", MAStudy.SIMPLE);
var vMALastBar = vStudy1.getValue(MAStudy.MA);
var vMAThisBar = vStudy2.getValue(MAStudy.MA);
if(vMALastBar > vMAThisBar) {
setBarBgColor(Color.lime);
}
else if(vMALastBar < vMAThisBar) {
setBarBgColor(Color.red);
}
else if(vMALastBar == vMAThisBar) {
setBarBgColor(Color.yellow);
}
}
Sure, I could call
setComputeOnClose();
But that negates the real-time features that I need.
Further, each time a new price bar starts, it always the background color is always red. Will fixing the first issue address this as well?
Thanks in advance,
Greg
Comment