Hi All,
I try to make the following script to run but...
What I want to do is to (include) efsInternal but bring the Internal call and not the main? ANy Ideas?
This Is the code.
.............
/************************************************** *******
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("----------");
setCursorLabelName("percentK", 0);
setCursorLabelName("percentD", 1);
setCursorLabelName("Osc",2);
setDefaultBarFgColor(Color.grey, 0);
setDefaultBarFgColor(Color.yellow, 1);
setDefaultBarFgColor(Color.blue,2);
setPlotType(PLOTTYPE_HISTOGRAM,2);
setDefaultBarThickness(2,0);
setDefaultBarThickness(2,1);
setDefaultBarThickness(2,2);
askForInput();
}
addBand(80, PS_SOLID, 3, Color.grey, "Upper");
addBand(20, PS_SOLID, 3, Color.black, "Lower");
var MAVt = null;
var MAVt1 = null;
var MAVt_1 = 0;
var MAVt1_1 = 0;
var x=0;
fpArray[x] = new FunctionParameter("Short", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(1);
setDefault(10);
}
fpArray[x] = new FunctionParameter("Long", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(1);
setDefault(21);
}
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.STRING);
with(fpArray[x++]){
setDefault();
}
fpArray[x] = new FunctionParameter("Type", FunctionParameter.BOOLEAN);
with(fpArray[x++]){
setName("Exponential");
setDefault(false);
}
fpArray[x] = new FunctionParameter("Params", FunctionParameter.BOOLEAN);
with(fpArray[x++]){
setName("Show Parameters");
setDefault(false);
}
var bInit = false;
var xOsc = null;
function main(Short,Long,Source,Symbol,Interval,Type,Params ) {
var HP = efsInternal("range");
if(bInit == false){
if(Symbol == null) Symbol = getSymbol();
if(Interval == null) Interval = getInterval();
var vSymbol = Symbol+","+Interval;
xOsc = osc(Short,Long,eval(Type),eval(Source)(sym(vSymbol )));
setShowTitleParameters(eval(Params));
bInit = true;
}
return getSeries(xOsc),range();
function range(nLength, nSmoothing, nSmoothings) {
if(nLength == null)
nLength = 8;
if(nSmoothing == null)
nSmoothing = 3;
if(nSmoothings == null)
nSmoothings = 3;
var percentK;
var ll = 0, hh = 0;
var sum = 0;
var vHigh = getValue("High", 0, -nLength);
var vLow = getValue("Low", 0, -nLength);
var temp = 0;
if(vHigh == null || vLow == null)
return;
for(j = 0; j < nLength; j++) {
if(j == 0) {
ll = vLow[j];
hh = vHigh[j];
} else {
hh = Math.max(hh, vHigh[j]);
ll = Math.min(ll, vLow[j]);
}
}
percentK = ((close() - ll) / (hh - ll)) * 100;
if (isNaN(percentK) == false) MAVt = MAVt_1 + (percentK - MAVt_1) / nSmoothing;
if (getBarState() == BARSTATE_NEWBAR) MAVt_1 = MAVt;
if (isNaN(percentK) == false) MAVt1 = MAVt1_1 + (MAVt - MAVt1_1) / nSmoothings;
if (getBarState() == BARSTATE_NEWBAR) MAVt1_1 = MAVt1;
return new Array(MAVt,MAVt1);
}
}
I try to make the following script to run but...
What I want to do is to (include) efsInternal but bring the Internal call and not the main? ANy Ideas?
This Is the code.
.............
/************************************************** *******
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("----------");
setCursorLabelName("percentK", 0);
setCursorLabelName("percentD", 1);
setCursorLabelName("Osc",2);
setDefaultBarFgColor(Color.grey, 0);
setDefaultBarFgColor(Color.yellow, 1);
setDefaultBarFgColor(Color.blue,2);
setPlotType(PLOTTYPE_HISTOGRAM,2);
setDefaultBarThickness(2,0);
setDefaultBarThickness(2,1);
setDefaultBarThickness(2,2);
askForInput();
}
addBand(80, PS_SOLID, 3, Color.grey, "Upper");
addBand(20, PS_SOLID, 3, Color.black, "Lower");
var MAVt = null;
var MAVt1 = null;
var MAVt_1 = 0;
var MAVt1_1 = 0;
var x=0;
fpArray[x] = new FunctionParameter("Short", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(1);
setDefault(10);
}
fpArray[x] = new FunctionParameter("Long", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(1);
setDefault(21);
}
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.STRING);
with(fpArray[x++]){
setDefault();
}
fpArray[x] = new FunctionParameter("Type", FunctionParameter.BOOLEAN);
with(fpArray[x++]){
setName("Exponential");
setDefault(false);
}
fpArray[x] = new FunctionParameter("Params", FunctionParameter.BOOLEAN);
with(fpArray[x++]){
setName("Show Parameters");
setDefault(false);
}
var bInit = false;
var xOsc = null;
function main(Short,Long,Source,Symbol,Interval,Type,Params ) {
var HP = efsInternal("range");
if(bInit == false){
if(Symbol == null) Symbol = getSymbol();
if(Interval == null) Interval = getInterval();
var vSymbol = Symbol+","+Interval;
xOsc = osc(Short,Long,eval(Type),eval(Source)(sym(vSymbol )));
setShowTitleParameters(eval(Params));
bInit = true;
}
return getSeries(xOsc),range();
function range(nLength, nSmoothing, nSmoothings) {
if(nLength == null)
nLength = 8;
if(nSmoothing == null)
nSmoothing = 3;
if(nSmoothings == null)
nSmoothings = 3;
var percentK;
var ll = 0, hh = 0;
var sum = 0;
var vHigh = getValue("High", 0, -nLength);
var vLow = getValue("Low", 0, -nLength);
var temp = 0;
if(vHigh == null || vLow == null)
return;
for(j = 0; j < nLength; j++) {
if(j == 0) {
ll = vLow[j];
hh = vHigh[j];
} else {
hh = Math.max(hh, vHigh[j]);
ll = Math.min(ll, vLow[j]);
}
}
percentK = ((close() - ll) / (hh - ll)) * 100;
if (isNaN(percentK) == false) MAVt = MAVt_1 + (percentK - MAVt_1) / nSmoothing;
if (getBarState() == BARSTATE_NEWBAR) MAVt_1 = MAVt;
if (isNaN(percentK) == false) MAVt1 = MAVt1_1 + (MAVt - MAVt1_1) / nSmoothings;
if (getBarState() == BARSTATE_NEWBAR) MAVt1_1 = MAVt1;
return new Array(MAVt,MAVt1);
}
}
Comment