Announcement

Collapse
No announcement yet.

BB RSI Avg Indicator

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • BB RSI Avg Indicator

    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:
    PHP 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.green0);
        
    setDefaultBarFgColor(Color.red1);
        
    setDefaultBarFgColor(Color.red2);
        
    setDefaultBarFgColor(Color.blue3);
        
    setDefaultBarFgColor(Color.blue4);
        
    addBand(70PS_SOLID1Color.black);
        
    addBand(30PS_SOLID1Color.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(MALenRSILenBBLenNumDevs) {
    var 
    nBarState getBarState();
        if (
    nBarState == BARSTATE_ALLBARS) {
            if(
    MALen == nullMALen 3;
            if(
    BBLen == nullBBLen 20;
            if(
    NumDevs == nullNumDevs 3;
            if(
    RSILen == nullRSILen 14;
        }

        if (
    bInit == false){
            
    xRSI     efsInternal("Calc_UpperBB"MALenRSILenBBLenNumDevs);
            
    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(MALenRSILenBBLenNumDevs) {
    var 
    nResH 0;
    var 
    nResL 0;
    var 
    0;
    var 
    nTmp 0;
    var 
    StandardDev 0;
    var 
    SumSqr 0;

        if(
    yInit == false){
            
    yRSI   rsi(RSILen);
            
    yRSIMA sma(MALenyRSI);
            
    yEMA   ema(BBLenyRSIMA);
            
    yInit  true;
        }

        var 
    nEMA yEMA.getValue(0);
        if (
    nEMA == null) return;
        for(
    0BBLeni++) {
            
    nTmp += yRSI.getValue(-i);
            
    SumSqr += (nTmp / (1) - nEMA) * (nTmp / (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), nResHnResL);

    Last edited by eSignal; 03-26-2009, 05:36 AM.
Working...
X