It appears as though the watch list doesn't like the fact I'm looking a price study and also calling an indicator (Acc/Dist) in the script.
Everything looks fine on a chart but the WatchList columns just have a little green square - no data.
I'm using the Acc/Dist to confirm the direction change (the intermediate steps aren't shown) and change the nBarCnt accordingly.
The purpose is to use the nBarCnt value in a WatchList to see what symbols had triggered a direction change.
Everything looks fine on a chart but the WatchList columns just have a little green square - no data.
I'm using the Acc/Dist to confirm the direction change (the intermediate steps aren't shown) and change the nBarCnt accordingly.
The purpose is to use the nBarCnt value in a WatchList to see what symbols had triggered a direction change.
PHP Code:
debugClear();
var fpArray = new Array();
function preMain() {
setPriceStudy(true);
setStudyTitle("test");
setCursorLabelName("HiAvg",0);
setDefaultBarFgColor(Color.blue,0);
setPlotType(PLOTTYPE_LINE,0);
setDefaultBarThickness(1,0);
setCursorLabelName("LoAvg",1);
setDefaultBarFgColor(Color.red,1);
setPlotType(PLOTTYPE_LINE,1);
setDefaultBarThickness(1,1);
setCursorLabelName("TradeBars", 2);
setShowSeries(false, 2);
setDefaultBarFgColor(Color.khaki, 2);
var x=0;
fpArray[x] = new FunctionParameter("LLen", FunctionParameter.NUMBER);
with(fpArray[x++]) {
setLowerLimit(1);
setDefault(8);
}
fpArray[x] = new FunctionParameter("HLen", FunctionParameter.NUMBER);
with(fpArray[x++]) {
setLowerLimit(1);
setDefault(10);
}
fpArray[x] = new FunctionParameter("Params", FunctionParameter.BOOLEAN);
with(fpArray[x++]) {
setName("Show Parameters");
setDefault(false);
}
}
var grID = 0;
var bInit = false;
var xMAlo = null;
var xMAhi = null;
var nL = 0;
var nH = 0;
var nWidth = 0;
var xAD = null;
var xMA = null;
var nAD = null;
var nMA = null;
var nBarCnt = 0;
function main(LLen, HLen, Params) {
if(bInit == false){
xMAlo = sma(LLen, low());
xMAhi = sma(HLen, high());
setShowTitleParameters(eval(Params));
xAD = accDist();
xMA = sma(57,xAD);
bInit = true;
}
// get the current Acc/Dist and direction
nAD = xAD.getValue(0);
nMA = xMA.getValue(0);
if (nMA == null || nAD == null) return;
nL = xMAlo.getValue(0);
nH = xMAhi.getValue(0);
if (nL == null || nH == null) return;
/*
do some stuff
*/
if (close() > nH) {
(nBarCnt <=0) ? nBarCnt = 1 : nBarCnt++;
} else if (close() < nL) {
(nBarCnt >0) ? nBarCnt = -1 : nBarCnt--;
} else {
nBarCnt = 0;
}
return new Array(nH, nL, nBarCnt);
}