Currently the script below is returning #NAME?. I have multiples dde scripts opened on a few charts working perfectly but for the life of me can't crack this one.
Is it because the data for Ask and Bid vol are being returned in an array???
Any help greatly appreciated.
William
function preMain() {
setStudyTitle("Bid\/Ask Volume ");
setCursorLabelName("Ask Vol", 0);
setCursorLabelName("Inside Vol", 1);
setCursorLabelName("Bid Vol", 2);
setDefaultBarFgColor(Color.green, 0);
setDefaultBarFgColor(Color.black, 1);
setDefaultBarFgColor(Color.red, 2);
setDefaultBarThickness(8, 0);
setDefaultBarThickness(6, 1);
setDefaultBarThickness(4, 2);
setPlotType(PLOTTYPE_HISTOGRAM, 0);
setPlotType(PLOTTYPE_HISTOGRAM, 1);
setPlotType(PLOTTYPE_HISTOGRAM, 2);
var fp0 = new FunctionParameter("sType", FunctionParameter.STRING);
fp0.setName("Analysis");
fp0.addOption("Bar");
fp0.addOption("Cumulative");
fp0.setDefault("Bar");
}
var nBidVol = null;
var nInsideVol = null;
var nAskVol = null;
var vVol = null;
var bPrimed = false;
var nAsk = null;
var nBid = null;
var bEdit = true;
var ddeup = null;
var ddedown = null;
function main(sType) {
if (getCurrentBarIndex() < 0) return;
var nState = getBarState();
if (nState == BARSTATE_NEWBAR) {
if (sType == "Bar" || day(0) != day(-1)) {
nBidVol = 0;
nInsideVol = 0;
nAskVol = 0;
}
vVol = 0;
}
var vPrevVol = null;
if (vVol != null && bPrimed == true) vPrevVol = vVol;
var nTempAsk = getMostRecentAsk();
var nTempBid = getMostRecentBid();
if (nTempAsk != null && nTempAsk != 0) nAsk = nTempAsk;
if (nTempBid != null && nTempBid != 0) nBid = nTempBid;
var vClose = close();
vVol = volume();
var vTradeVol = vVol - vPrevVol;
if (bPrimed == false && vVol != null) {
bPrimed = true;
return;
} else {
if (vClose <= nBid) {
nBidVol += vTradeVol;
} else if (vClose >= nAsk) {
nAskVol += vTradeVol;
} else {
nInsideVol += vTradeVol;
}
}
return new Array(nAskVol, nInsideVol, nBidVol);
if (bEdit == true) {
var sym = getSymbol();
sym = sym.replace(" #F", "");
sym = sym.replace(" ", "_");
debugPrintln("Example DDE link: '=eSignal|EFS!" + sym + "_ask");
ddeup = new DDEOutput(sym + "_ask" + getInterval());
ddedown = new DDEOutput(sym + "_bid" + getInterval());
bEdit = false;
retVal = nAskVol.getValue(0)
xretVal = nBidVol.getValue(0)
if(retVal != null) ddeup.set(retVal);
if(xretVal != null) ddedown.set(xretVal);
}
return;
}
Is it because the data for Ask and Bid vol are being returned in an array???
Any help greatly appreciated.
William
function preMain() {
setStudyTitle("Bid\/Ask Volume ");
setCursorLabelName("Ask Vol", 0);
setCursorLabelName("Inside Vol", 1);
setCursorLabelName("Bid Vol", 2);
setDefaultBarFgColor(Color.green, 0);
setDefaultBarFgColor(Color.black, 1);
setDefaultBarFgColor(Color.red, 2);
setDefaultBarThickness(8, 0);
setDefaultBarThickness(6, 1);
setDefaultBarThickness(4, 2);
setPlotType(PLOTTYPE_HISTOGRAM, 0);
setPlotType(PLOTTYPE_HISTOGRAM, 1);
setPlotType(PLOTTYPE_HISTOGRAM, 2);
var fp0 = new FunctionParameter("sType", FunctionParameter.STRING);
fp0.setName("Analysis");
fp0.addOption("Bar");
fp0.addOption("Cumulative");
fp0.setDefault("Bar");
}
var nBidVol = null;
var nInsideVol = null;
var nAskVol = null;
var vVol = null;
var bPrimed = false;
var nAsk = null;
var nBid = null;
var bEdit = true;
var ddeup = null;
var ddedown = null;
function main(sType) {
if (getCurrentBarIndex() < 0) return;
var nState = getBarState();
if (nState == BARSTATE_NEWBAR) {
if (sType == "Bar" || day(0) != day(-1)) {
nBidVol = 0;
nInsideVol = 0;
nAskVol = 0;
}
vVol = 0;
}
var vPrevVol = null;
if (vVol != null && bPrimed == true) vPrevVol = vVol;
var nTempAsk = getMostRecentAsk();
var nTempBid = getMostRecentBid();
if (nTempAsk != null && nTempAsk != 0) nAsk = nTempAsk;
if (nTempBid != null && nTempBid != 0) nBid = nTempBid;
var vClose = close();
vVol = volume();
var vTradeVol = vVol - vPrevVol;
if (bPrimed == false && vVol != null) {
bPrimed = true;
return;
} else {
if (vClose <= nBid) {
nBidVol += vTradeVol;
} else if (vClose >= nAsk) {
nAskVol += vTradeVol;
} else {
nInsideVol += vTradeVol;
}
}
return new Array(nAskVol, nInsideVol, nBidVol);
if (bEdit == true) {
var sym = getSymbol();
sym = sym.replace(" #F", "");
sym = sym.replace(" ", "_");
debugPrintln("Example DDE link: '=eSignal|EFS!" + sym + "_ask");
ddeup = new DDEOutput(sym + "_ask" + getInterval());
ddedown = new DDEOutput(sym + "_bid" + getInterval());
bEdit = false;
retVal = nAskVol.getValue(0)
xretVal = nBidVol.getValue(0)
if(retVal != null) ddeup.set(retVal);
if(xretVal != null) ddedown.set(xretVal);
}
return;
}
Comment