This works:
It returns the value to my chart.
But if I change the line:
xStudy = efsExternal( xPathToEFS );
to:
xStudy = efsExternal( xPathToEFS , iEFS01P01 );
then xStudy is null.
What is the reason passing ONE parameter causes this to happen?
It is pass all or none?
Here's the function I am calling:
PHP Code:
var bInit = false;
var iEFSLIB01 = "Z_SCRATCH" ;
var iEFS01 = "_fTDI";
var iEFS01P01 = 12 ;
var iEFS01P02 = "close" ;
function main() {
if(bInit == false) {
xPathToEFS = "/"+ iEFSLIB01 +"/" + iEFS01 +".EFS" ;
xStudy = efsExternal( xPathToEFS );
bInit = true ; }
debugPrint( "xStudy.gv0 : " + xStudy.getValue(0) + "\n" );
debugPrint( "xPathToEFS : " + xPathToEFS + "\n" );
debugPrint( "----------------: " + "\n" );
return ( xStudy.getValue(0) );
}
But if I change the line:
xStudy = efsExternal( xPathToEFS );
to:
xStudy = efsExternal( xPathToEFS , iEFS01P01 );
then xStudy is null.
What is the reason passing ONE parameter causes this to happen?
It is pass all or none?
Here's the function I am calling:
PHP Code:
/********************************
_fTDI.EFS
Description : This Indicator plots the Trend Detection Index
Provided By : TS Support, LLC for eSignal
Modified by : Alexis C. Montenegro 08/04/2006
- converted to efs2 syntax
- added multiple time frame/symbol capability
- added moving average
************************************/
var fpArray = new Array();
function preMain(){
setStudyTitle("Trend Detection Index");
setCursorLabelName("TDI",0);
setCursorLabelName("MAofTDI",1);
setDefaultBarFgColor(Color.blue, 0);
setDefaultBarFgColor(Color.red, 1);
setDefaultBarThickness(1,0);
setDefaultBarThickness(1,1);
askForInput();
var x=0;
fpArray[x] = new FunctionParameter("Length", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(1);
setDefault(12);
}
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("MAType", FunctionParameter.STRING);
with(fpArray[x++]){
addOption("sma");
addOption("ema");
addOption("wma");
setDefault("sma");
}
fpArray[x] = new FunctionParameter("MALength", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(1);
setDefault(3);
}
fpArray[x] = new FunctionParameter("LineColor1", FunctionParameter.COLOR);
with(fpArray[x++]){
setName("Color1");
setDefault(Color.blue);
}
fpArray[x] = new FunctionParameter("LineColor2", FunctionParameter.COLOR);
with(fpArray[x++]){
setName("Color2");
setDefault(Color.red);
}
fpArray[x] = new FunctionParameter("Params", FunctionParameter.BOOLEAN);
with(fpArray[x++]){
setName("Show Parameters");
setDefault(false);
}
}
var bInit = false;
var xTDI = null;
var xMATDI = null;
function main(Length,Source,Symbol,Interval,MAType,MALength,LineColor1,LineColor2,Params){
if(bInit==false){
if(Symbol == null) Symbol = getSymbol();
if(Interval == null) Interval = getInterval();
var vSymbol = Symbol+","+Interval;
xTDI = efsInternal("calcTDI", Length,eval(Source)(vSymbol));
xMATDI = eval(MAType)(MALength,xTDI);
setDefaultBarFgColor(LineColor1,0);
setDefaultBarFgColor(LineColor2,1);
addBand(0,PS_SOLID,1,Color.lightgrey,"0");
setShowTitleParameters(eval(Params));
bInit = true;
}
return (getSeries(xTDI) );
}
xMOM = null;
function calcTDI(period, source){
if (xMOM == null) xMOM = mom(period,source);
var MomSum = 0;
var MomSumAbs = 0;
var MomAbsSum = 0;
var MomAbsSum2 = 0;
for (var i=0; i<period-1; i++){
MomSum += xMOM.getValue(-i);
}
MomSumAbs = Math.abs(MomSum);
for (var i=0; i<period-1; i++){
MomAbsSum += Math.abs(xMOM.getValue(-i));
}
for (var i=0; i<period*2-1; i++){
MomAbsSum2 += Math.abs(xMOM.getValue(-i));
}
var ret = MomSumAbs - (MomAbsSum2 - MomAbsSum);
return ret;
}
Comment