customized BB width
Alexis:
I would really appreciate your help. I was reading your exchange with Bill and thought it would be great to be able to customize the BB width indicator with inputs on the BB parameters. I took my best shot at trying to do this using your Custom EFS 2 BB code plus the BB width code. Unfortunately, I cannot get it to plot anything for the BB width. Any thoughts?
David
var fpArray = new Array();
function preMain() {
setPriceStudy(false);
setStudyTitle("Bollinger Band Width");
setCursorLabelName("Bandwidth", 0)
setDefaultBarFgColor(Color.blue, 0);
askForInput();
var x=0;
fpArray[x] = new FunctionParameter("Length", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(1);
setDefault(20);
}
fpArray[x] = new FunctionParameter("StdDev", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(0);
setDefault(2);
}
fpArray[x] = new FunctionParameter("Source", FunctionParameter.STRING);
with(fpArray[x++]){
addOption("open");
addOption("high");
addOption("low");
addOption("close");
addOption("hl2");
addOption("hlc3");
addOption("ohlc4");
setDefault("close");
}
fpArray[x] = new FunctionParameter("Symbol", FunctionParameter.STRING);
with(fpArray[x++]){
setDefault("");
}
fpArray[x] = new FunctionParameter("Interval", FunctionParameter.NUMBER);
with(fpArray[x++]){
setDefault("");
}
fpArray[x] = new FunctionParameter("Offset", FunctionParameter.NUMBER);
with(fpArray[x++]){
setDefault(0);
}
fpArray[x] = new FunctionParameter("Params", FunctionParameter.BOOLEAN);
with(fpArray[x++]){
setName("Show Parameters");
setDefault(false);
}
}
var bInit = false;
var xUpBB = null;
var xMidBB = null;
var xLoBB = null;
function main(Length,StdDev,Source,Symbol,Interval,Offset,P arams) {
if(bInit == false){
if(Symbol == null) Symbol = getSymbol();
if(Interval == null) Interval = getInterval();
var vSymbol = Symbol+","+Interval;
xUpBB = offsetSeries(upperBB(Length,StdDev,eval(Source)(sy m(vSymbol))),Offset);
xMidBB = offsetSeries(middleBB(Length,StdDev,eval(Source)(s ym(vSymbol))),Offset);
xLoBB = offsetSeries(lowerBB(Length,StdDev,eval(Source)(sy m(vSymbol))),Offset);
setShowTitleParameters(eval(Params));
bInit = true;
}
return new Array ((xUpBB - xLoBB) / xMidBB * 100, 0.0));
}
Alexis:
I would really appreciate your help. I was reading your exchange with Bill and thought it would be great to be able to customize the BB width indicator with inputs on the BB parameters. I took my best shot at trying to do this using your Custom EFS 2 BB code plus the BB width code. Unfortunately, I cannot get it to plot anything for the BB width. Any thoughts?
David
var fpArray = new Array();
function preMain() {
setPriceStudy(false);
setStudyTitle("Bollinger Band Width");
setCursorLabelName("Bandwidth", 0)
setDefaultBarFgColor(Color.blue, 0);
askForInput();
var x=0;
fpArray[x] = new FunctionParameter("Length", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(1);
setDefault(20);
}
fpArray[x] = new FunctionParameter("StdDev", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(0);
setDefault(2);
}
fpArray[x] = new FunctionParameter("Source", FunctionParameter.STRING);
with(fpArray[x++]){
addOption("open");
addOption("high");
addOption("low");
addOption("close");
addOption("hl2");
addOption("hlc3");
addOption("ohlc4");
setDefault("close");
}
fpArray[x] = new FunctionParameter("Symbol", FunctionParameter.STRING);
with(fpArray[x++]){
setDefault("");
}
fpArray[x] = new FunctionParameter("Interval", FunctionParameter.NUMBER);
with(fpArray[x++]){
setDefault("");
}
fpArray[x] = new FunctionParameter("Offset", FunctionParameter.NUMBER);
with(fpArray[x++]){
setDefault(0);
}
fpArray[x] = new FunctionParameter("Params", FunctionParameter.BOOLEAN);
with(fpArray[x++]){
setName("Show Parameters");
setDefault(false);
}
}
var bInit = false;
var xUpBB = null;
var xMidBB = null;
var xLoBB = null;
function main(Length,StdDev,Source,Symbol,Interval,Offset,P arams) {
if(bInit == false){
if(Symbol == null) Symbol = getSymbol();
if(Interval == null) Interval = getInterval();
var vSymbol = Symbol+","+Interval;
xUpBB = offsetSeries(upperBB(Length,StdDev,eval(Source)(sy m(vSymbol))),Offset);
xMidBB = offsetSeries(middleBB(Length,StdDev,eval(Source)(s ym(vSymbol))),Offset);
xLoBB = offsetSeries(lowerBB(Length,StdDev,eval(Source)(sy m(vSymbol))),Offset);
setShowTitleParameters(eval(Params));
bInit = true;
}
return new Array ((xUpBB - xLoBB) / xMidBB * 100, 0.0));
}
Comment