Modified Donchian Channels

ICE Data Services -


ModifiedDonchianChannels.efs  EFSLibrary - Discussion Board
  

File Name: ModifiedDonchianChannels.efs


Description:
Modified Donchian Channels


Formula Parameters:
Length : 24
Extremes : 3
Margins : 0

Notes:

Download File:
ModifiedDonchianChannels.efs




EFS Code:


/*********************************Provided By:      eSignal (Copyright c eSignal), a division of Interactive Data     Corporation. 2009. 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:            Modified Donchian Channels    Version:            1.0  10/29/2009 Formula Parameters:                     Default:    Length                              24    Extremes                            3    Margins                             0    Notes:    **********************************/var fpArray = new Array();var bInit = false;function preMain(){    setPriceStudy(true);    setShowCursorLabel(true);    setShowTitleParameters(false);    setStudyTitle("Modified Donchian Channels");    setCursorLabelName("Up Band", 0);    setPlotType(PLOTTYPE_LINE, 0);    setDefaultBarFgColor(Color.red, 0);    setCursorLabelName("Dn Band", 1);        setPlotType(PLOTTYPE_LINE, 1);    setDefaultBarFgColor(Color.red, 1);    var x = 0;    fpArray[x] = new FunctionParameter("Length", FunctionParameter.NUMBER);    with(fpArray[x++]) {        setLowerLimit(1);        setDefault(24);    }        fpArray[x] = new FunctionParameter("Margins", FunctionParameter.NUMBER);    with(fpArray[x++]) {        setLowerLimit(0);        setDefault(0);    }            fpArray[x] = new FunctionParameter("Extremes", FunctionParameter.NUMBER);	with(fpArray[x++]){        addOption(1);         addOption(2);        addOption(3);        setDefault(3);     }    }var xDonchUp = null;var xDonchDn = null;var xDonchOpenUp = null;var xDonchOpenDn = null;function main(Length, Extremes, Margins) {var nBarState = getBarState();var nDonchUp = 0;var nDonchDn = 0;var nDonchOpenUp = 0;var nDonchOpenDn = 0;var nSsMax = 0;var nSsMin = 0;var nmin = 0;var nmax = 0;    if (nBarState == BARSTATE_ALLBARS) {        if(Length == null) Length = 24;        if(Extremes == null) Extremes = 3;        if(Margins == null) Margins = 0;	}	if (bInit == false) {        xDonchUp = upperDonchian(Length, high());        xDonchDn = lowerDonchian(Length, low());        xDonchOpenUp = upperDonchian(Length, open());        xDonchOpenDn = lowerDonchian(Length, open());        bInit = true;	}    nDonchUp = xDonchUp.getValue(0);    nDonchDn = xDonchDn.getValue(0)    nDonchOpenUp = xDonchOpenUp.getValue(0);    nDonchOpenDn = xDonchOpenDn.getValue(0);    if (nDonchUp == null) return;    if (Extremes ==1) {        nSsMax = nDonchUp;        nSsMin = nDonchDn;    } else {        if (Extremes == 3) {            nSsMax = (nDonchOpenUp + nDonchUp) / 2;            nSsMin = (nDonchOpenDn + nDonchDn) / 2;        } else {            nSsMax = nDonchOpenUp;            nSsMin = nDonchOpenDn;        }    }        nmin = nSsMin + (nSsMax - nSsMin) * Margins / 100;    nmax = nSsMax - (nSsMax - nSsMin) * Margins / 100;    return new Array(nmax, nmin);}