I want to use an efs (myIndicator) as input to another efs (myStrategy). If I try to plot myIndicator from within myStrategy, the plot does not stay current -- it stops plotting after the script is loaded. I created a very simple example:
I'm not clear about efsExternal not compatible with setComputeOnClose(). Does this I mean I can't use that in both the calling script and the called script? or only the calling script. I only need to get the indicator value once per bar (not every tick) so I tried various combinatins of using NEWBAR and/or setComputeOnClose. So the question is how to make the code efficient by calling myIndicator once per bar and still keep the plot current?
PHP Code:
// myIndicator
function preMain() {
setPriceStudy(false);
setComputeOnClose(); // tried with and with out this
setDefaultBarFgColor(Color.red, 0);
}
function main() {
var h = high();
var l = low();
var x = h-l;
return (x);
}
PHP Code:
// myStrategy
var xStudy = null;
var bInit = false;
}
function main() {
if(bInit == false){
xStudy = efsExternal("myIndicator.efs")
bInit = true;
}
var nState = getBarState();
if (nState == BARSTATE_NEWBAR) {
var myPlot = xStudy.getValue(0);
}
return (myPlot);
}