As far as I can see any of Sylvain Vervoort’s studies that include zerolag tema, e.g. Zerolag Tema, HA Zerolag Tema and Zerolag HA Tema Difference can be called using efsExternal() but only in the interval of the calling chart. For example, from a 1000V Volume chart the first code snippet shown below works but the second generates the error message ”ZeroLag_TEMA.efs, line 62: Parameter Number 2 of Function ema is invalid.” Below is also the code for ZeroLag_TEMA.efs. Line 62 is in sub-function calcTema and reads xAvg1 = ema(nLength,xSource); My question is how can the returned values of these studies be called in intervals other than that of the calling chart. Thanks for any help.
Mike
Snippet #1):
function preMain() {
setPriceStudy(false);
setStudyTitle("title1");
addBand(0, PS_SOLID, 2, Color.RGB(0,0,0), "TagName");
}
var bInit1 = null;
var test1 = null;
var Study1 = null;
function main(){
if(bInit1 == false){
Study1 = efsExternal("ZeroLag_TEMA.efs");
Test1 = getSeries(Study1, 0);
bInit1 = true
}
return test1;
}
*********************
Snippet #2):
function preMain() {
setPriceStudy(false);
setStudyTitle("title2");
addBand(0, PS_SOLID, 2, Color.RGB(0,0,0), "TagName");
}
var bInit2 = null;
var test2 = null;
var Study2 = null;
function main(){
if(bInit2 == false){
Study2 = efsExternal("ZeroLag_TEMA.efs", inv(“2000V”));
Test2 = getSeries(Study2, 0);
bInit2 = true
}
return test2;
}
*********************
function preMain() {
setPriceStudy(true);
setStudyTitle("Zero Lag TEMA ");
setCursorLabelName("ZTEMA", 0);
setDefaultBarFgColor(Color.red, 0);
setDefaultBarThickness(2, 0);
var fp1 = new FunctionParameter("nPeriods", FunctionParameter.NUMBER);
fp1.setName("Periods");
fp1.setLowerLimit(1);
fp1.setDefault(55);
var fp2 = new FunctionParameter("sSource", FunctionParameter.STRING);
fp2.setName("Price Source");
fp2.addOption("Close");
fp2.addOption("HL/2");
fp2.addOption("HLC/3");
fp2.addOption("OHLC/4");
fp2.setDefault("HLC/3");
}
var bInit = false;
var xTema1 = null;
var xTema2 = null;
var xSource = null;
function main(nPeriods, sSource) {
if (bInit == false) {
if (sSource == "Close") {
xSource = close();
} else if (sSource == "HL/2") {
xSource = hl2();
} else if (sSource == "HLC/3") {
xSource = hlc3();
} else if (sSource == "OHLC/4") {
xSource = ohlc4();
}
xTema1 = efsInternal("calcTEMA", nPeriods, xSource);
xTema2 = efsInternal("calcTEMA", nPeriods, xTema1);
bInit = true;
}
var nZEma = null;
var nTema1 = xTema1.getValue(0);
var nTema2 = xTema2.getValue(0);
if (nTema1 == null || nTema2 == null) return;
nZTEma = nTema1 + (nTema1 - nTema2);
return nZTEma;
}
var xAvg1 = null;
var xAvg2 = null;
var xAvg3 = null;
var bInit2 = false;
function calcTEMA(nLength,xSource){
if(bInit2 == false){
xAvg1 = ema(nLength,xSource);
xAvg2 = ema(nLength,xAvg1);
xAvg3 = ema(nLength,xAvg2);
bInit2 = true;
}
var nAvg1 = xAvg1.getValue(0);
var nAvg2 = xAvg2.getValue(0);
var nAvg3 = xAvg3.getValue(0);
if (nAvg1 == null || nAvg2 == null || nAvg3 == null) return;
var nTEMA = (3*nAvg1)-(3*nAvg2)+nAvg3;
return nTEMA;
}
Mike
Snippet #1):
function preMain() {
setPriceStudy(false);
setStudyTitle("title1");
addBand(0, PS_SOLID, 2, Color.RGB(0,0,0), "TagName");
}
var bInit1 = null;
var test1 = null;
var Study1 = null;
function main(){
if(bInit1 == false){
Study1 = efsExternal("ZeroLag_TEMA.efs");
Test1 = getSeries(Study1, 0);
bInit1 = true
}
return test1;
}
*********************
Snippet #2):
function preMain() {
setPriceStudy(false);
setStudyTitle("title2");
addBand(0, PS_SOLID, 2, Color.RGB(0,0,0), "TagName");
}
var bInit2 = null;
var test2 = null;
var Study2 = null;
function main(){
if(bInit2 == false){
Study2 = efsExternal("ZeroLag_TEMA.efs", inv(“2000V”));
Test2 = getSeries(Study2, 0);
bInit2 = true
}
return test2;
}
*********************
function preMain() {
setPriceStudy(true);
setStudyTitle("Zero Lag TEMA ");
setCursorLabelName("ZTEMA", 0);
setDefaultBarFgColor(Color.red, 0);
setDefaultBarThickness(2, 0);
var fp1 = new FunctionParameter("nPeriods", FunctionParameter.NUMBER);
fp1.setName("Periods");
fp1.setLowerLimit(1);
fp1.setDefault(55);
var fp2 = new FunctionParameter("sSource", FunctionParameter.STRING);
fp2.setName("Price Source");
fp2.addOption("Close");
fp2.addOption("HL/2");
fp2.addOption("HLC/3");
fp2.addOption("OHLC/4");
fp2.setDefault("HLC/3");
}
var bInit = false;
var xTema1 = null;
var xTema2 = null;
var xSource = null;
function main(nPeriods, sSource) {
if (bInit == false) {
if (sSource == "Close") {
xSource = close();
} else if (sSource == "HL/2") {
xSource = hl2();
} else if (sSource == "HLC/3") {
xSource = hlc3();
} else if (sSource == "OHLC/4") {
xSource = ohlc4();
}
xTema1 = efsInternal("calcTEMA", nPeriods, xSource);
xTema2 = efsInternal("calcTEMA", nPeriods, xTema1);
bInit = true;
}
var nZEma = null;
var nTema1 = xTema1.getValue(0);
var nTema2 = xTema2.getValue(0);
if (nTema1 == null || nTema2 == null) return;
nZTEma = nTema1 + (nTema1 - nTema2);
return nZTEma;
}
var xAvg1 = null;
var xAvg2 = null;
var xAvg3 = null;
var bInit2 = false;
function calcTEMA(nLength,xSource){
if(bInit2 == false){
xAvg1 = ema(nLength,xSource);
xAvg2 = ema(nLength,xAvg1);
xAvg3 = ema(nLength,xAvg2);
bInit2 = true;
}
var nAvg1 = xAvg1.getValue(0);
var nAvg2 = xAvg2.getValue(0);
var nAvg3 = xAvg3.getValue(0);
if (nAvg1 == null || nAvg2 == null || nAvg3 == null) return;
var nTEMA = (3*nAvg1)-(3*nAvg2)+nAvg3;
return nTEMA;
}
Comment