Announcement

Collapse
No announcement yet.

2015 June: The RSI & Price Trends by Kevin Luo

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

  • 2015 June: The RSI & Price Trends by Kevin Luo

    File Name: StrategyRSI.efs

    Description:
    The RSI & Price Trends by Kevin Luo

    Formula Parameters:

    StrategyRSI.efs
    Length RSI: 14
    Price Change, %: 20
    RSI Upper Bound: 70
    RSI Lower Bound: 50
    Confirmed Long Zone: lime
    Long Trend Color: green
    Short Trend Color: red
    Long Position Color: green
    Short Position Color: red
    Nick Color: grey
    Nick Extension: 3
    Nick Thickness: 3

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

    Download File:
    StrategyRSI.efs

    StrategyRSI.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 RSI & Price Trends by Kevin Luo 

    Formula Parameters:                     Default:
    Length RSI                              14
    Price Change, %                         20
    RSI Upper Bound                         70
    RSI Lower Bound                         50
    Confirmed Long Zone                     lime
    Long Trend Color                        green
    Short Trend Color                       red
    Long Position Color                     green
    Short Position Color                    red
    Nick Color                              grey
    Nick Extension                          3
    Nick Thickness                          3 

    Version:            1.00  04/09/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("StrategyRSI");
        
    setPriceStudy(true);
        
    setColorPriceBars(true);
        
    setComputeOnClose(true);

        var 
    0;

        
    fpArray[x] = new FunctionParameter("fpLength"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){

            
    setName("Length RSI");
            
    setLowerLimit(1); 
            
    setDefault(14);
        };

        
    fpArray[x] = new FunctionParameter("fpChange"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){

            
    setName("Price Change, %");
            
    setLowerLimit(0);
            
    setUpperLimit(100); 
            
    setDefault(20);
        };

        
    fpArray[x] = new FunctionParameter("fpRSIHighBorder"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){

            
    setName("RSI Upper Bound");    
            
    setLowerLimit(0);
            
    setUpperLimit(100); 
            
    setDefault(70);
        };
        
        
    fpArray[x] = new FunctionParameter("fpRSILowBorder"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){

            
    setName("RSI Lower Bound");    
            
    setLowerLimit(0);
            
    setUpperLimit(100); 
            
    setDefault(50);
        };

        
    fpArray[x] = new FunctionParameter("fpZoneColor"FunctionParameter.COLOR);
        
    with(fpArray[x++]){

            
    setName("Confirmed Long Zone");    
            
    setDefault(Color.lime);
        };

        
    fpArray[x] = new FunctionParameter("fpLongTrendColor"FunctionParameter.COLOR);
        
    with(fpArray[x++]){

            
    setName("Long Trend Color");    
            
    setDefault(Color.green);
        };
        
        
    fpArray[x] = new FunctionParameter("fpShortTrendColor"FunctionParameter.COLOR);
        
    with(fpArray[x++]){

            
    setName("Short Trend Color");    
            
    setDefault(Color.red);
        };

        
    fpArray[x] = new FunctionParameter("fpLongPosColor"FunctionParameter.COLOR);
        
    with(fpArray[x++]){

            
    setName("Long Position Color");    
            
    setDefault(Color.green);
        };
        
        
    fpArray[x] = new FunctionParameter("fpShortPosColor"FunctionParameter.COLOR);
        
    with(fpArray[x++]){

            
    setName("Short Position Color");    
            
    setDefault(Color.red);
        };

        
    fpArray[x] = new FunctionParameter("fpNickColor"FunctionParameter.COLOR);
        
    with(fpArray[x++]){

            
    setName("Nick Color");    
            
    setDefault(Color.grey);
        };

        
    fpArray[x] = new FunctionParameter("fpExtNick"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){

            
    setName("Nick Extension");    
            
    setLowerLimit(0); 
            
    setDefault(3);
        };

        
    fpArray[x] = new FunctionParameter("fpThicNick"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){

            
    setName("Nick Thickness");    
            
    setLowerLimit(1);
            
    setUpperLimit(10)
            
    setDefault(3);
        };
    }

    var 
    bInit false;
    var 
    bVersion null;

    var 
    xOpen null;
    var 
    xHigh null;
    var 
    xLow null;

    var 
    xRSI null;

    var 
    nChange null;
    var 
    nHighLim null;
    var 
    nLowLim null;
    var 
    nDefLotSize null;

    var 
    nTagID 0;

    var 
    bIsTrend false;
    var 
    bLongTrend false;
    var 
    bShortTrend false;
    var 
    aHignest = {};
    var 
    aLowest = {};

    function 
    main(fpLengthfpChange,
                  
    fpRSIHighBorderfpRSILowBorder,
                  
    fpLongTrendColorfpShortTrendColor,
                  
    fpZoneColorfpLongPosColorfpShortPosColor,
                  
    fpNickColorfpExtNickfpThicNick){

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

        if (!
    bInit){

            
    xOpen open();
            
    xHigh high();
            
    xLow low();
                 
            
    xRSI rsi(fpLength);
            
            
    nChange fpChange 100;
            
    nHighLim nChange;
            
    nLowLim nChange;
            
            
    nDefLotSize Strategy.getDefaultLotSize();
                   
            
    bInit true
        };

        if (
    getBarState() == BARSTATE_ALLBARS){
            
    nTagID 0;
            
    bIsTrend false;
            
    bLongTrend false;
            
    bShortTrend false;
            
    aHighest = {};
            
    aLowest = {};
        }
        
        var 
    bReverseThisBar false;

        var 
    nNextOpen xOpen.getValue(1);
        var 
    nOpen xOpen.getValue(0);
        var 
    nHigh xHigh.getValue(0);
        var 
    nLow xLow.getValue(0);
        var 
    nPrevHigh xHigh.getValue(-1);
        var 
    nPrevLow xLow.getValue(-1);
        
        var 
    nRSI xRSI.getValue(0);
        
        if (
    nPrevHigh == null || nPrevLow == null)
            return;
        
        var 
    nCurrentBarNumber getCurrentBarCount();
        
        if (
    bShortTrend || !bIsTrend){
            
            if (
    nPrevLow aLowest[0] || aLowest[0] == null){
                
    aLowest[0] = nPrevLow;
                
    aLowest[1] = nCurrentBarNumber 1;
            }
        
            if (
    bIsTrendsetPriceBarColor(fpShortTrendColor);
            
            if (
    nHigh >= nHighLim aLowest[0]){
                
                
    recalculate(nCurrentBarNumber aLowest[1] + 1, function(){
                    
    setPriceBarColor(fpLongTrendColor);
                })
                
                
    drawLineRelative(-fpExtNicknHighLim aLowest[0], fpExtNicknHighLim aLowest[0],
                                 
    nullfpThicNickfpNickColornTagID++);
            
                if (!
    bIsTrendbIsTrend true;
                
    bLongTrend true;
                
    bShortTrend false;
                
    bReverseThisBar true;
                
    aHighest[0] = nHigh;
                
    aHighest[1] = nCurrentBarNumber;
            }
        }

        if (
    bLongTrend || !bIsTrend){
            
            if (
    bIsTrendsetPriceBarColor(fpLongTrendColor);
            
            if ((
    nPrevHigh aHighest[0] || aHighest[0] == null) && !bReverseThisBar ){
                
    aHighest[0] = nPrevHigh;
                
    aHighest[1] = nCurrentBarNumber 1;
            }
               
            if (
    nLow <= nLowLim aHighest[0] && !bReverseThisBar){
                
                
    recalculate(nCurrentBarNumber aHighest[1] + 1, function(){
                    
    setPriceBarColor(fpShortTrendColor);
                })
                
                if (
    bIsTrenddrawLineRelative(-fpExtNicknLowLim aHighest[0], fpExtNicknLowLim aHighest[0],
                              
    nullfpThicNickfpNickColornTagID++);
            
                if (!
    bIsTrendbIsTrend true;
                
    bLongTrend false;
                
    bShortTrend true;
                
    aLowest[0] = nLow;
                
    aLowest[1] = nCurrentBarNumber;
                
                var 
    nExitPrice Math.min(nOpennLowLim aHighest[0]);
            
                if (
    Strategy.isLong()){
                    
    Strategy.doSell("Exit Long"Strategy.LIMITStrategy.THISBARStrategy.DEFAULT, nExitPrice);
                    
    drawShapeRelative(0AboveBar1Shape.DOWNTRIANGLEnullfpShortPosColor,
                    
    Text.PRESETnTagID++);
                    
    drawTextRelative(0AboveBar2"Exit Long"fpShortPosColornull,
                    
    Text.PRESET|Text.CENTER|Text.BOLDnullnullnTagID++);
                    
    drawTextRelative(0AboveBar3nDefLotSize " @ " formatPriceNumber(nExitPrice), fpShortPosColornull,
                    
    Text.PRESET|Text.CENTER|Text.BOLDnullnullnTagID++);
                }
            }
            else if (
    bIsTrend){
                
                
    setBarBgColor(fpZoneColor);
                
                if (
    nRSI == null)
                    return;
                
                if (
    nRSI fpRSILowBorder && !Strategy.isLong()){
                    
    Strategy.doLong("Long"Strategy.MARKETStrategy.NEXTBARStrategy.DEFAULT);
                    
    drawShapeRelative(1BelowBar1Shape.UPTRIANGLEnullfpLongPosColor,
                    
    Text.PRESETnTagID++);
                    
    drawTextRelative(1BelowBar2"Long"fpLongPosColornull,
                    
    Text.PRESET|Text.CENTER|Text.BOLDnullnullnTagID++);
                    
    drawTextRelative(1BelowBar3nDefLotSize " @ " formatPriceNumber(nNextOpen), fpLongPosColornull,
                    
    Text.PRESET|Text.CENTER|Text.BOLDnullnullnTagID++);
                }
                
                if (
    nRSI fpRSIHighBorder && Strategy.isLong()){
                    
    Strategy.doSell("Exit Long"Strategy.MARKETStrategy.NEXTBARStrategy.DEFAULT);
                    
    drawShapeRelative(1AboveBar1Shape.DOWNTRIANGLEnullfpShortPosColor,
                    
    Text.PRESETnTagID++);
                    
    drawTextRelative(1AboveBar2"Exit Long"fpShortPosColornull,
                    
    Text.PRESET|Text.CENTER|Text.BOLDnullnullnTagID++);
                    
    drawTextRelative(1AboveBar3nDefLotSize " @ " formatPriceNumber(nNextOpen), fpShortPosColornull,
                    
    Text.PRESET|Text.CENTER|Text.BOLDnullnullnTagID++); 
                }
            }
        }
    }

    function 
    verify(){
        
        var 
    false;
        if (
    getBuildNumber() < 3435){
            
            
    drawTextAbsolute(535"This study requires version 11.8 or later."
                
    Color.whiteColor.blueText.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,
                
    null13"error");
            
    drawTextAbsolute(520"Click HERE to [email protected]=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