I am trying to auto insert the value of the Interval = 2 * Interval of the current chart interval so that when I do the switching between different time frames the interval is automatically doubled & inserted rather than having to recalculate & be inserted by myself.
ie. Current Chart Interval= 300T
Interval = 2*"Current Chart Interval" = 600T
Below is the Custom Stochastic from the Efs2 Custom Folder Originally written by Alexis C. Montenegro:
/************************************************** *******
By Alexis C. Montenegro for eSignal © December 2004
Use and/or modify this code freely. If you redistribute it
please include this and/or any other comment blocks and a
description of any changes you make.
************************************************** ********/
var fpArray = new Array();
function preMain() {
setPriceStudy(false);
setStudyTitle("Stochastic");
setCursorLabelName("%K",0);
setCursorLabelName("%D",1);
setDefaultBarFgColor(Color.blue, 0);
setDefaultBarFgColor(Color.red, 1);
setPlotType(PLOTTYPE_LINE,0);
setPlotType(PLOTTYPE_LINE,1);
setDefaultBarThickness(1,0);
setDefaultBarThickness(1,1);
askForInput();
var x=0;
fpArray[x] = new FunctionParameter("KLength", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("%K");
setLowerLimit(1);
setDefault(14);
}
fpArray[x] = new FunctionParameter("KSmoothing", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("%KSmooth");
setLowerLimit(1);
setDefault(1);
}
fpArray[x] = new FunctionParameter("DLength", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("%D");
setLowerLimit(1);
setDefault(3);
}
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("Upper", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(0);
setDefault(80);
}
fpArray[x] = new FunctionParameter("Lower", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(0);
setDefault(20);
}
fpArray[x] = new FunctionParameter("Params", FunctionParameter.BOOLEAN);
with(fpArray[x++]){
setName("Show Parameters");
setDefault(false);
}
}
var bInit = false;
var xStochK = null;
var xStochD = null;
function main(KLength,KSmoothing,DLength,Symbol,Interval,Up per,Lower,Params) {
if(bInit == false){
if(Symbol == null) Symbol = getSymbol();
if(Interval == null) Interval = getInterval();
var vSymbol = Symbol+","+Interval;
xStochK = stochK(KLength,KSmoothing,DLength,sym(vSymbol));
xStochD = stochD(KLength,KSmoothing,DLength,sym(vSymbol));
addBand( Upper, PS_SOLID, 1, Color.black,"Upper");
addBand( Lower, PS_SOLID, 1, Color.black,"Lower");
setShowTitleParameters(eval(Params));
bInit = true;
}
return new Array (getSeries(xStochK),getSeries(xStochD));
}
I have replaced the line above "setDefault()" for the "Interval" with 2*getInterval() but the efs seems to run in an endless loop.
fpArray[x] = new FunctionParameter("Interval", FunctionParameter.STRING);
with(fpArray[x++]){
setDefault(2*getInterval());
Would someone pls tell me why is it not working or what should I do to get this to work.
Thank you so much in advance for all your inputs.
Ted
ie. Current Chart Interval= 300T
Interval = 2*"Current Chart Interval" = 600T
Below is the Custom Stochastic from the Efs2 Custom Folder Originally written by Alexis C. Montenegro:
/************************************************** *******
By Alexis C. Montenegro for eSignal © December 2004
Use and/or modify this code freely. If you redistribute it
please include this and/or any other comment blocks and a
description of any changes you make.
************************************************** ********/
var fpArray = new Array();
function preMain() {
setPriceStudy(false);
setStudyTitle("Stochastic");
setCursorLabelName("%K",0);
setCursorLabelName("%D",1);
setDefaultBarFgColor(Color.blue, 0);
setDefaultBarFgColor(Color.red, 1);
setPlotType(PLOTTYPE_LINE,0);
setPlotType(PLOTTYPE_LINE,1);
setDefaultBarThickness(1,0);
setDefaultBarThickness(1,1);
askForInput();
var x=0;
fpArray[x] = new FunctionParameter("KLength", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("%K");
setLowerLimit(1);
setDefault(14);
}
fpArray[x] = new FunctionParameter("KSmoothing", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("%KSmooth");
setLowerLimit(1);
setDefault(1);
}
fpArray[x] = new FunctionParameter("DLength", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("%D");
setLowerLimit(1);
setDefault(3);
}
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("Upper", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(0);
setDefault(80);
}
fpArray[x] = new FunctionParameter("Lower", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(0);
setDefault(20);
}
fpArray[x] = new FunctionParameter("Params", FunctionParameter.BOOLEAN);
with(fpArray[x++]){
setName("Show Parameters");
setDefault(false);
}
}
var bInit = false;
var xStochK = null;
var xStochD = null;
function main(KLength,KSmoothing,DLength,Symbol,Interval,Up per,Lower,Params) {
if(bInit == false){
if(Symbol == null) Symbol = getSymbol();
if(Interval == null) Interval = getInterval();
var vSymbol = Symbol+","+Interval;
xStochK = stochK(KLength,KSmoothing,DLength,sym(vSymbol));
xStochD = stochD(KLength,KSmoothing,DLength,sym(vSymbol));
addBand( Upper, PS_SOLID, 1, Color.black,"Upper");
addBand( Lower, PS_SOLID, 1, Color.black,"Lower");
setShowTitleParameters(eval(Params));
bInit = true;
}
return new Array (getSeries(xStochK),getSeries(xStochD));
}
I have replaced the line above "setDefault()" for the "Interval" with 2*getInterval() but the efs seems to run in an endless loop.
fpArray[x] = new FunctionParameter("Interval", FunctionParameter.STRING);
with(fpArray[x++]){
setDefault(2*getInterval());
Would someone pls tell me why is it not working or what should I do to get this to work.
Thank you so much in advance for all your inputs.
Ted
Comment