2002 Jul: Zero-Lag Data Smoothers

ICE Data Services -


AdjustableLagFltr.efs  EFSLibrary - Discussion Board
  

File Name: AdjustableLagFltr.efs


Description:
Zero-Lag Data Smoothers, by John Ehlers


Formula Parameters:
Lag Reduction: 1.5
Line Thickness: 2
Line Color: Green
Display Cursor Labels: True

Notes:
The related article is copyrighted material. If you are not
a subscriber of Stocks & Commodities, please visit www.traders.com.

Download File:
AdjustableLagFltr.efs




EFS Code:





/*********************************Provided By:      eSignal (Copyright c eSignal), a division of Interactive Data     Corporation. 2008. All rights reserved. This sample eSignal     Formula Script (EFS) is for educational purposes only and may be     modified and saved under a new file name.  eSignal is not responsible    for the functionality once modified.  eSignal reserves the right     to modify and overwrite this EFS file with each new release.Description:            Zero-Lag Data Smoothers, by John Ehlers Version:            1.0  12/05/2008Formula Parameters:                     Default:    Lag Reduction                       1.5    Line Thickness                      2    Line Color                          Green    Display Cursor Labels               True    Notes:    The related article is copyrighted material. If you are not    a subscriber of Stocks & Commodities, please visit www.traders.com.**********************************/var fpArray = new Array();var bInit = false;var bVersion = null;function preMain() {    setPriceStudy(true);    setShowCursorLabel(false);    setShowTitleParameters( false );    setStudyTitle("Adjustable Lag Fltr");    setCursorLabelName("ALF", 0);    setDefaultBarFgColor(Color.red, 0);    setPlotType(PLOTTYPE_LINE, 0);     setDefaultBarThickness(2, 0);    askForInput();    var x=0;    fpArray[x] = new FunctionParameter("LineColor", FunctionParameter.COLOR);    with(fpArray[x++]){        setName("Line Color");        setDefault(Color.green);    }        fpArray[x] = new FunctionParameter("ViewValue", FunctionParameter.BOOLEAN);    with(fpArray[x++]){        setName("Display Cursor Labels");        setDefault(true);    }        fpArray[x] = new FunctionParameter("LagReduction", FunctionParameter.NUMBER);	with(fpArray[x++]){        setName("Lag Reduction");        setLowerLimit(0.01);		        setDefault(1.5);    }    fpArray[x] = new FunctionParameter("Thickness", FunctionParameter.NUMBER);	with(fpArray[x++]){        setName("Line Thickness");        setLowerLimit(1);		        setDefault(2);    }}var nDenominator = 0;var aCoeff = new Array(7);function main(LagReduction, Thickness, LineColor, ViewValue) {var nNumerator = 0;var nFilter = 0;    if (bVersion == null) bVersion = verify();    if (bVersion == false) return;       if ( bInit == false ) {         setDefaultBarFgColor(LineColor, 0);        setDefaultBarThickness(Thickness, 0);        setShowCursorLabel(ViewValue);                bInit = true;     }     if (getCurrentBarCount() == 1) {        aCoeff[1] = 1;        aCoeff[2] = 2 + LagReduction;        aCoeff[3] = 3 + LagReduction;        aCoeff[4] = 3;        aCoeff[5] = 2 - LagReduction;        aCoeff[6] = 1 - LagReduction;        aCoeff[7] = 0 - LagReduction;        nDenominator = SummationArray(aCoeff, 7);    }    nNumerator = 0 ;    for (var nValue1 = 1; nValue1 <= 7; nValue1++) {        nNumerator += aCoeff[nValue1] * close(-nValue1 + 1);    }     nFilter = nNumerator / nDenominator ;    return nFilter; }function SummationArray(aArray, nLength){var nRes = 0;    for (var i = 1; i <= nLength; i++) {           nRes += aArray[i];     }     if (nRes == null) nRes = 1;    return nRes;}function verify() {    var b = false;    if (getBuildNumber() < 779) {        drawTextAbsolute(5, 35, "This study requires version 8.0 or later.",             Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,            null, 13, "error");        drawTextAbsolute(5, 20, "Click HERE to upgrade.@URL=http://www.esignal.com/download/default.asp",             Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,            null, 13, "upgrade");        return b;    } else {        b = true;    }    return b;}