StepSto

ICE Data Services -


StepSto.efs  EFSLibrary - Discussion Board
  

File Name: StepSto.efs


Description:
StepSto


Formula Parameters:
Length ATR : 10
K Slow : 1
K Fast : 1
TopBand : 70
LowBand : 30

Notes:

Download File:
StepSto.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:            StepStoVersion:            1.0  09/17/2009 Formula Parameters:                     Default:    Length ATR                          10    K Slow                              1    K Fast                              1    TopBand                             70    LowBand                             30    Notes:    **********************************/var fpArray = new Array();var bInit = false;function preMain(){    setPriceStudy(false);    setShowCursorLabel(true);    setShowTitleParameters(false);    setStudyTitle("StepSto");    setCursorLabelName("StepSto Slow", 0);    setPlotType(PLOTTYPE_LINE, 0);    setDefaultBarFgColor(Color.red, 0);    setCursorLabelName("StepSto Fast", 1);    setPlotType(PLOTTYPE_LINE, 1);    setDefaultBarFgColor(Color.green, 1);    setStudyMax(101);    setStudyMin(-1);    var x = 0;    fpArray[x] = new FunctionParameter("Kfast", FunctionParameter.NUMBER);    with(fpArray[x++]) {        setName("K Fast");        setLowerLimit(1);        setDefault(1);    }        fpArray[x] = new FunctionParameter("Kslow", FunctionParameter.NUMBER);    with(fpArray[x++]) {        setName("K Slow");        setLowerLimit(1);        setDefault(1);    }        fpArray[x] = new FunctionParameter("LengthATR", FunctionParameter.NUMBER);    with(fpArray[x++]) {        setName("Length ATR");        setLowerLimit(1);        setDefault(10);    }            fpArray[x] = new FunctionParameter("TopBand", FunctionParameter.NUMBER);	with(fpArray[x++]){        setLowerLimit(1);		        setDefault(70);    }    fpArray[x] = new FunctionParameter("LowBand", FunctionParameter.NUMBER);	with(fpArray[x++]){        setLowerLimit(0);		        setDefault(30);    }}var xATR = null;var xClose = null;var nATRmax = 0;var nATRmin = 110;var SminMin1 = 99999;var SmaxMin1 = 99999;var SminMax1 = 0;var SmaxMax1 = 0;var SminMid1 = 0;var SmaxMid1 = 0;var SminMin0 = 99999;var SmaxMin0 = 99999;var SminMax0 = 0;var SmaxMax0 = 0;var SminMid0 = 0;var SmaxMid0 = 0;function main(LengthATR, Kfast, Kslow, TopBand, LowBand) {var nBarState = getBarState();var nATR = 0;var linemin = 0;var linemax = 0;var linemid = 0;var Sto1 = 0;var Sto2 = 0;var bsmin = 0;var bsmax = 0;var StepSizeMin = 0;var StepSizeMax = 0;var StepSizeMid = 0; var nClose = 0;    if (nBarState == BARSTATE_ALLBARS) {        if(LengthATR == null) LengthATR = 10;        if(Kslow == null) Kslow = 1;        if(Kfast == null) Kfast = 1;        if(TopBand == null) TopBand = 70;        if(LowBand == null) LowBand = 30;        nATRmax = 0;        nATRmin = 99999;	}	if (bInit == false) {        addBand(TopBand, PS_SOLID, 1, Color.grey, "TopBand");        addBand(LowBand, PS_SOLID, 1, Color.grey, "LowBand");                xClose = close();        xATR = atr(LengthATR);        bInit = true;	}	nATR = xATR.getValue(-1);	if (nATR == null) return;	if (nBarState == BARSTATE_NEWBAR) {        SminMin1 = SminMin0;        SmaxMin1 = SmaxMin0;        SminMax1 = SminMax0;        SmaxMax1 = SmaxMax0;        SminMid1 = SminMid0;        SmaxMid1 = SmaxMid0;	}	nClose = xClose.getValue(-1);	nATRmax = Math.max(nATR, nATRmax);    nATRmin = Math.min(nATR, nATRmin);    StepSizeMin = (Kfast * nATRmin);    StepSizeMax = (Kfast * nATRmax);    StepSizeMid = (Kfast * 0.5 * Kslow * (nATRmax + nATRmin));    SmaxMin0 = nClose + 2 * StepSizeMin;    SminMin0 = nClose - 2 * StepSizeMin;    SmaxMax0 = nClose + 2 * StepSizeMax;    SminMax0 = nClose - 2 * StepSizeMax;    SmaxMid0 = nClose + 2 * StepSizeMid;    SminMid0 = nClose - 2 * StepSizeMid;    if (nClose > SmaxMin1) TrendMin = 1;    if (nClose < SminMin1) TrendMin = -1;    if (nClose > SmaxMax1) TrendMax = 1;    if (nClose < SminMax1) TrendMax = -1;    if (nClose > SmaxMid1) TrendMid = 1;    if (nClose < SminMid1) TrendMid = -1;    if (TrendMin > 0 && SminMin0 < SminMin1) SminMin0 = SminMin1;    if (TrendMin < 0 && SmaxMin0 > SmaxMin1) SmaxMin0 = SmaxMin1;    if (TrendMax > 0 && SminMax0 < SminMax1) SminMax0 = SminMax1;    if (TrendMax < 0 && SmaxMax0 > SmaxMax1) SmaxMax0 = SmaxMax1;    if (TrendMid > 0 && SminMid0 < SminMid1) SminMid0 = SminMid1;    if (TrendMid < 0 && SmaxMid0 > SmaxMid1) SmaxMid0 = SmaxMid1;    if (TrendMin > 0) linemin = SminMin0 + StepSizeMin;    if (TrendMin < 0) linemin = SmaxMin0 - StepSizeMin;    if (TrendMax > 0) linemax = SminMax0 + StepSizeMax;    if (TrendMax < 0) linemax = SmaxMax0 - StepSizeMax;    if (TrendMid > 0) linemid = SminMid0 + StepSizeMid;    if (TrendMid < 0) linemid = SmaxMid0 - StepSizeMid;    bsmin = linemax - StepSizeMax;    bsmax = linemax + StepSizeMax;    Sto1 = ((linemin - bsmin) / (bsmax - bsmin)) * 100;    Sto2 = ((linemid - bsmin) / (bsmax - bsmin)) * 100;    return new Array(Sto1, Sto2);}