2017 Feb: Exponential Standard Deviation Bandsby Vitali Apirine
ESDB.efs
File Name: ESDB.efs
Description:
Exponential Standard Deviation Bands by Vitali Apirine
Formula Parameters:
ESDB.efs
- Length: 20
- # of EStdDev: 2
Notes:
The related article is copyrighted material. If you are not a subscriber of Stocks & Commodities, please visit www.traders.com.
Download File:
ESDB.efs
ESDB.efs
EFS Code:
/********************************* Provided By: eSignal (Copyright c eSignal), a division of Interactive Data Corporation. 2016. 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: Exponential Standard Deviation Bands by Vitali Apirine Version: 1.00 12/07/2016 Formula Parameters: Default: Length 20 # of EStdDev 2 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(); function preMain(){ setPriceStudy(true); setCursorLabelName("Upper", 0); setCursorLabelName("Middle", 1); setCursorLabelName("Lower", 2); setDefaultBarFgColor(Color.RGB(255,106,0),1); var x = 0; fpArray[x] = new FunctionParameter("Length", FunctionParameter.INTEGER) with(fpArray[x++]){ setLowerLimit(1); setDefault(20); setName("Length"); } fpArray[x] = new FunctionParameter("MFactor", FunctionParameter.NUMBER) with(fpArray[x++]){ setLowerLimit(1); setDefault(2); setName("# of EStdDev"); } } var bInit = false; var bVersion = null; var xClose = null; var xEMA = null; var xStdDev = null; var xUpBand = null; var xLwBand = null; var bUpFlag = false; var bLwFlag = true; function main(Length, MFactor){ if (bVersion == null) bVersion = verify(); if (bVersion == false) return; if (getBarState() == BARSTATE_ALLBARS) bInit = false; if (!bInit){ xClose = close(); xEMA = ema(Length, xClose); xStdDev = efsInternal("ExpStdDev", xClose, xEMA, Length); xUpBand = efsInternal("UpperLower", xEMA, xStdDev, MFactor, bUpFlag); xLwBand = efsInternal("UpperLower", xEMA, xStdDev, MFactor, bLwFlag); bInit = true; } nUpBand = xUpBand.getValue(0); nMidBand = xEMA.getValue(0); nLwBand = xLwBand.getValue(0); if ((!isNull(nUpBand)) && (!isNull(nMidBand)) && (!isNull(nLwBand))) return [nUpBand, nMidBand, nLwBand]; } function ExpStdDev(xClose, xEMA, len){ var nSum = 0; var nEMA = xEMA.getValue(0); for (var i = 0; i < len; i++){ var nClose = xClose.getValue(-i); if (!isNull(nClose) && !isNull(nEMA)){ nSum += Math.pow((nClose - nEMA), 2); } } return (Math.sqrt(nSum/len)); } function UpperLower(xEMA, xStdDev, MFactor, bFlag){ var nEMA = xEMA.getValue(0); var nStdDev = xStdDev.getValue(0); nStdDev *= MFactor; if (bFlag == bLwFlag) nStdDev = -nStdDev; return (nEMA + nStdDev); } function verify(){ var b = false; if (getBuildNumber() < 779){ drawTextAbsolute(5, 35, "This study requires version 10.6 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; }