BB_RSIAverage.efs EFSLibrary - Discussion Board
File Name: BB_RSIAverage.efs
Description:
BB RSI Avg Indicator
Formula Parameters:
MALen : 3
BBLen : 20
NumDevs : 3
RSILen : 14
Notes:
This is a powerful technique which combines Bollinger bands, RSI and
Moving averages indicators.
Download File:
BB_RSIAverage.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: BB RSI Avg Indicator Version: 1.0 03/24/2009 Formula Parameters: Default: MALen 3 BBLen 20 NumDevs 3 RSILen 14 Notes: This is a powerful technique which combines Bollinger bands, RSI and Moving averages indicators. **********************************/ var fpArray = new Array(); var bInit = false; function preMain() { setPriceStudy(false); setStudyTitle("RSI BB"); setCursorLabelName("RSI", 0); setCursorLabelName("RSI MA", 1); setCursorLabelName("MA MA", 2); setCursorLabelName("BB Top", 3); setCursorLabelName("BB Bottom", 4); setDefaultBarFgColor(Color.green, 0); setDefaultBarFgColor(Color.red, 1); setDefaultBarFgColor(Color.red, 2); setDefaultBarFgColor(Color.blue, 3); setDefaultBarFgColor(Color.blue, 4); addBand(70, PS_SOLID, 1, Color.black); addBand(30, PS_SOLID, 1, Color.black); var x=0; fpArray[x] = new FunctionParameter("MALen", FunctionParameter.NUMBER); with(fpArray[x++]) { setLowerLimit(1); setDefault(3); } fpArray[x] = new FunctionParameter("BBLen", FunctionParameter.NUMBER); with(fpArray[x++]) { setLowerLimit(1); setDefault(20); } fpArray[x] = new FunctionParameter("NumDevs", FunctionParameter.NUMBER); with(fpArray[x++]) { setLowerLimit(1); setDefault(3); } fpArray[x] = new FunctionParameter("RSILen", FunctionParameter.NUMBER); with(fpArray[x++]) { setLowerLimit(1); setDefault(14); } } var xRSI = null; var xRSIMA = null; var xEMA = null; var xUpperBB = null; var xLowerBB = null; function main(MALen, RSILen, BBLen, NumDevs) { var nBarState = getBarState(); if (nBarState == BARSTATE_ALLBARS) { if(MALen == null) MALen = 3; if(BBLen == null) BBLen = 20; if(NumDevs == null) NumDevs = 3; if(RSILen == null) RSILen = 14; } if (bInit == false){ xRSI = efsInternal("Calc_UpperBB", MALen, RSILen, BBLen, NumDevs); xRSIMA = getSeries(xRSI,1) xEMA = getSeries(xRSI,2) xUpperBB = getSeries(xRSI,3) xLowerBB = getSeries(xRSI,4) bInit = true; } if (xEMA.getValue(0) == null) return; return new Array(xRSI.getValue(0), xRSIMA.getValue(0), xEMA.getValue(0), xUpperBB.getValue(0), xLowerBB.getValue(0)) } var yInit = false; var yRSI = null; var yRSIMA = null; var yEMA = null; function Calc_UpperBB(MALen, RSILen, BBLen, NumDevs) { var nResH = 0; var nResL = 0; var i = 0; var nTmp = 0; var StandardDev = 0; var SumSqr = 0; if(yInit == false){ yRSI = rsi(RSILen); yRSIMA = sma(MALen, yRSI); yEMA = ema(BBLen, yRSIMA); yInit = true } var nEMA = yEMA.getValue(0); if (nEMA == null) return; for(i = 0; i < BBLen; i++) { nTmp += yRSI.getValue(-i); SumSqr += (nTmp / (i + 1) - nEMA) * (nTmp / (i + 1) - nEMA); } StandardDev = Math.sqrt(SumSqr / BBLen); nResH = nEMA + NumDevs * StandardDev; nResL = nEMA - NumDevs * StandardDev; return new Array (yRSI.getValue(0), yRSIMA.getValue(0), yEMA.getValue(0), nResH, nResL); }