Announcement

Collapse
No announcement yet.

2015 July (Apr): The Slow Relative Strength Index by Vitali Apirine

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 2015 July (Apr): The Slow Relative Strength Index by Vitali Apirine

    File Name: SRSI.efs

    Description:
    The Slow Relative Strength Index by Vitali Apirine

    Formula Parameters:

    SRSI.efs
    Length EMA: 6
    Length Average Differences: 14
    Upper Bound: 80
    Lower Bound: 20

    Notes:
    The related article is copyrighted material. If you are not a subscriber
    of Stocks & Commodities, please visit www.traders.com.

    Download File:
    SRSI.efs

    SRSI.efs


    EFS Code:
    PHP Code:

    /*********************************
    Provided By:  
        Interactive Data Corporation (Copyright В© 2015) 
        All rights reserved. This sample eSignal Formula Script (EFS)
        is for educational purposes only. Interactive Data Corporation
        reserves the right to modify and overwrite this EFS file with 
        each new release. 

    Description:        
        The Slow Relative Strength Index by Vitali Apirine

    Formula Parameters:                     Default:
    Length EMA                              6
    Length Average Differences              14 
    Upper Bound                             80
    Lower Bound                             20

    Version:            1.00  05/05/2015

    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(){

        
    setStudyTitle("SRSI");
        
        
    setCursorLabelName("Upper Bound"0);
        
    setCursorLabelName("Lower Bound"1);
        
    setCursorLabelName("Center Line"2);
        
    setCursorLabelName("SRSI"3);
        
        
    setDefaultBarFgColor(Color.grey0);
        
    setDefaultBarFgColor(Color.grey1);
        
    setDefaultBarFgColor(Color.grey2);
            
        
    setShowCursorLabel(false0);
        
    setShowCursorLabel(false1);
        
    setShowCursorLabel(false2);
        
    setShowCursorLabel(true3);
        
        
    setDefaultBarStyle(PS_SOLID0);
        
    setDefaultBarStyle(PS_SOLID1);
        
    setDefaultBarStyle(PS_DASHDOT2);
        
    setDefaultBarStyle(PS_SOLID3);

        var 
    0;

        
    fpArray[x] = new FunctionParameter("fpLengthEMA"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setName("Length EMA");
            
    setLowerLimit(1); 
            
    setDefault(6);
        };

        
    fpArray[x] = new FunctionParameter("fpLengthAvgDiff"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setName("Length Average Differences");
            
    setLowerLimit(1);
            
    setDefault(14);
        };

        
    fpArray[x] = new FunctionParameter("fpSRSIHighBorder"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setName("Upper Bound");    
            
    setLowerLimit(0);
            
    setUpperLimit(100); 
            
    setDefault(80);
        };
        
        
    fpArray[x] = new FunctionParameter("fpSRSILowBorder"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setName("Lower Bound");    
            
    setLowerLimit(0);
            
    setUpperLimit(100); 
            
    setDefault(20);
        };
    }

    var 
    bInit false;
    var 
    bVersion null;

    var 
    xDifferences null;
    var 
    xPositiveDiff null;
    var 
    xNegativeDiff null;
    var 
    xPositiveDiffAvg null;
    var 
    xNegativeDiffAvg null;

    function 
    main(fpLengthEMAfpLengthAvgDifffpSRSIHighBorderfpSRSILowBorder){

        if (
    bVersion == nullbVersion verify();
        if (
    bVersion == false) return;

        if (!
    bInit){

            
    xDifferences efsInternal('Calc_Differences'fpLengthEMA);
            
    xPositiveDiff getSeries(xDifferences0);
            
    xNegativeDiff getSeries(xDifferences1);
            
            
    xPositiveDiffAvg smma(fpLengthAvgDiffxPositiveDiff);
            
    xNegativeDiffAvg smma(fpLengthAvgDiffxNegativeDiff);
                          
            
    bInit true
        };

        var 
    nPositiveDiffAvg xPositiveDiffAvg.getValue(0);
        var 
    nNegativeDiffAvg xNegativeDiffAvg.getValue(0);

        if (
    nPositiveDiffAvg == null || nNegativeDiffAvg == null)
            return;
        
        var 
    nSRSI = (nNegativeDiffAvg == 0) ? 100 100 - (100 / (+ (nPositiveDiffAvg nNegativeDiffAvg)));
        
        return [
    fpSRSIHighBorderfpSRSILowBorder50nSRSI];
    }

    var 
    xClose null;
    var 
    xEMA null;

    function 
    Calc_Differences(nLength){
        
        if (
    getBarState() == BARSTATE_ALLBARS){
            
    xClose close();
            
    xEMA ema(nLength);
        }
        
        var 
    nClose xClose.getValue(0);
        var 
    nEMA xEMA.getValue(0);
        
        if (
    nClose == null || nEMA == null)
            return;
        
        var 
    nPositiveDiff nClose nEMA nClose nEMA 0;
        var 
    nNegativeDiff nClose nEMA nEMA nClose 0;
        
        return [
    nPositiveDiffnNegativeDiff];
    }

    function 
    verify(){
        var 
    false;
        if (
    getBuildNumber() < 3742){
            
            
    drawTextAbsolute(535"This study requires version 12.1 or later."
                
    Color.whiteColor.blueText.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,
                
    null13"error");
            
    drawTextAbsolute(520"Click HERE to upgrade.@URL=http://www.esignal.com/download/default.asp"
                
    Color.whiteColor.blueText.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,
                
    null13"upgrade");
            return 
    b;
        } 
        else
            
    true;
        
        return 
    b;

Working...
X