can some help to fix below efs?
function preMain() {
setPriceStudy(false);
setStudyTitle("Zero Lag EMA ");
setCursorLabelName("sEMA", 0);
setDefaultBarFgColor(Color.red, 0);
setDefaultBarThickness(1, 0);
setCursorLabelName("fEMA", 1);
setDefaultBarFgColor(Color.green, 1);
setDefaultBarThickness(1, 1);
var fp1 = new FunctionParameter("sPeriods", FunctionParameter.NUMBER);
fp1.setName("Periods");
fp1.setLowerLimit(1);
fp1.setDefault(7);
var fp2 = new FunctionParameter("fPeriods", FunctionParameter.NUMBER);
fp2.setName("Periods");
fp2.setLowerLimit(1);
fp2.setDefault(21);
}
// Global Variables
var bVersion = null; // Version flag
var bInit = false; // Initialization flag
var xEma1 = null;
var xEma2 = null;
var fEMA1 = null;
var fEMA2 = null;
function main(sPeriods, fPeriods) {
var nState = getBarState();
var nIndex = getCurrentBarIndex();
if (bInit == false) {
xEma1 = ema(sPeriods);
xEma2 = ema(sPeriods, xEma1);
fEma1 = ema(fPeriods);
fEma2 = ema(fPeriods, fEma1);
bInit = true;
}
var nZEma = null;
var nEma1 = xEma1.getValue(0);
var nEma2 = xEma2.getValue(0);
if (nEma1 == null || nEma2 == null) return;
nZEma = nEma1 + (nEma1 - nEma2);
var fZEma = null;
var fEma1 = fEma1.getValue(0);
var fEma2 = fEma2.getValue(0);
if (fEma1 == null || fEma2 == null) return;
fZEma = fEma1 + (fEma1 - fEma2);
return (nZEma, fZEma);
}
function preMain() {
setPriceStudy(false);
setStudyTitle("Zero Lag EMA ");
setCursorLabelName("sEMA", 0);
setDefaultBarFgColor(Color.red, 0);
setDefaultBarThickness(1, 0);
setCursorLabelName("fEMA", 1);
setDefaultBarFgColor(Color.green, 1);
setDefaultBarThickness(1, 1);
var fp1 = new FunctionParameter("sPeriods", FunctionParameter.NUMBER);
fp1.setName("Periods");
fp1.setLowerLimit(1);
fp1.setDefault(7);
var fp2 = new FunctionParameter("fPeriods", FunctionParameter.NUMBER);
fp2.setName("Periods");
fp2.setLowerLimit(1);
fp2.setDefault(21);
}
// Global Variables
var bVersion = null; // Version flag
var bInit = false; // Initialization flag
var xEma1 = null;
var xEma2 = null;
var fEMA1 = null;
var fEMA2 = null;
function main(sPeriods, fPeriods) {
var nState = getBarState();
var nIndex = getCurrentBarIndex();
if (bInit == false) {
xEma1 = ema(sPeriods);
xEma2 = ema(sPeriods, xEma1);
fEma1 = ema(fPeriods);
fEma2 = ema(fPeriods, fEma1);
bInit = true;
}
var nZEma = null;
var nEma1 = xEma1.getValue(0);
var nEma2 = xEma2.getValue(0);
if (nEma1 == null || nEma2 == null) return;
nZEma = nEma1 + (nEma1 - nEma2);
var fZEma = null;
var fEma1 = fEma1.getValue(0);
var fEma2 = fEma2.getValue(0);
if (fEma1 == null || fEma2 == null) return;
fZEma = fEma1 + (fEma1 - fEma2);
return (nZEma, fZEma);
}
Comment