I am trying to compute the ratio difference between close price and VWAP. I pick up ALEX's VWAP because it can be computed at any intraday time point set up by user. The following is the EFS,but it just shows nothing on the chart. Any suggestion is appreciated.
var fpArray = new Array();
function preMain() {
setPriceStudy(false);
setStudyTitle("diffVWAP");
setCursorLabelName("diffVWAP",0);
setDefaultBarFgColor(Color.blue,0);
setPlotType(PLOTTYPE_SQUAREWAVE,0);
setDefaultBarThickness(1,0);
askForInput();
var x=0;
fpArray[x] = new FunctionParameter("StartTime", FunctionParameter.STRING);
with(fpArray[x++]){
setName("Start Time");
setDefault(930);
}
fpArray[x] = new FunctionParameter("Symbol", FunctionParameter.STRING);
with(fpArray[x++]){
setDefault();
}
fpArray[x] = new FunctionParameter("Interval", FunctionParameter.STRING);
with(fpArray[x++]){
setDefault();
}
fpArray[x] = new FunctionParameter("Params", FunctionParameter.BOOLEAN);
with(fpArray[x++]){
setName("Show Parameters");
setDefault(false);
}
}
var diffVWAP = null;
var bInit = false;
var VWAP = null;
var amLib = addLibrary("amStudies.efsLib");
function main(StartTime,Symbol,Interval,Params){
var VWAP = efsInternal("xVWAP");
var diffVWAP= (close() - VWAP) / VWAP;
return getSeries(diffVWAP);
}
function xVWAP(StartTime,Symbol,Interval,Params) {
if(bInit==false){
with( amLib ) {
if(Symbol == null) Symbol = getSymbol();
if(Interval == null) Interval = getInterval();
var vSymbol = Symbol+","+Interval;
xVWAP = amVWAP2(StartTime+"",sym(vSymbol));
setShowTitleParameters(eval(Params));
bInit=true;
}
}
return getSeries(xVWAP );}
var fpArray = new Array();
function preMain() {
setPriceStudy(false);
setStudyTitle("diffVWAP");
setCursorLabelName("diffVWAP",0);
setDefaultBarFgColor(Color.blue,0);
setPlotType(PLOTTYPE_SQUAREWAVE,0);
setDefaultBarThickness(1,0);
askForInput();
var x=0;
fpArray[x] = new FunctionParameter("StartTime", FunctionParameter.STRING);
with(fpArray[x++]){
setName("Start Time");
setDefault(930);
}
fpArray[x] = new FunctionParameter("Symbol", FunctionParameter.STRING);
with(fpArray[x++]){
setDefault();
}
fpArray[x] = new FunctionParameter("Interval", FunctionParameter.STRING);
with(fpArray[x++]){
setDefault();
}
fpArray[x] = new FunctionParameter("Params", FunctionParameter.BOOLEAN);
with(fpArray[x++]){
setName("Show Parameters");
setDefault(false);
}
}
var diffVWAP = null;
var bInit = false;
var VWAP = null;
var amLib = addLibrary("amStudies.efsLib");
function main(StartTime,Symbol,Interval,Params){
var VWAP = efsInternal("xVWAP");
var diffVWAP= (close() - VWAP) / VWAP;
return getSeries(diffVWAP);
}
function xVWAP(StartTime,Symbol,Interval,Params) {
if(bInit==false){
with( amLib ) {
if(Symbol == null) Symbol = getSymbol();
if(Interval == null) Interval = getInterval();
var vSymbol = Symbol+","+Interval;
xVWAP = amVWAP2(StartTime+"",sym(vSymbol));
setShowTitleParameters(eval(Params));
bInit=true;
}
}
return getSeries(xVWAP );}