TRADERS’ TIPS

July 2015

Tips Article Thumbnail

For this month’s Traders’ Tips, the focus is mainly Vitali Apirine’s article that appeared in the April 2015 issue of STOCKS & COMMODITIES, “The Slow Relative Strength Index.” Other Traders’ Tips are based on different S&C articles as indicated. Here, we present the July 2015 Traders’ Tips code with possible implementations in various software.

The Traders’ Tips section is provided to help the reader implement a selected technique from an article in this issue or another recent issue. The entries here are contributed by software developers or programmers for software that is capable of customization.


logo

TRADESTATION: JULY 2015

In “The Slow Relative Strength Index,” which appeared in the April 2015 issue of STOCKS & COMMODITIES, author Vitali Apirine describes a modified version of the well-known relative strength index (RSI). Apirine describes a method of smoothing the price used for the RSI calculation by using an exponential moving average of price.

For convenience, we are providing the code for a TradeStation function (SRSI) based on the author’s ideas. This function can be used in other analysis techniques or strategies. We have also provided a demonstration indicator using the SRSI function. The EasyLanguage code is as follows:

Function: SRSI 

// TASC JUL 2015
// SRSI

inputs: 
	iPrice( numericseries ), 
	Length( numericsimple ),{ this input assumed to be a constant >= 1 }
	SMoothingLength( numericsimple ) ;

variables:
	NetChgAvg( 0 ), 
	TotChgAvg( 0 ), 
	Change( 0 ), 
	SF( 1 / Length ), { smoothing factor }
	ChgRatio( 0 ),
	Price( 0 ) ;

Price = XAverage( iPrice, SMoothingLength ) ;

if CurrentBar = 1 then
	begin
	NetChgAvg = ( Price - Price[Length] ) / Length ;
	TotChgAvg = Average( AbsValue( Price - Price[1] ), Length ) ;
	end
else
	begin
	Change = Price - Price[1] ;
	NetChgAvg = NetChgAvg[1] + SF * ( Change - NetChgAvg[1] ) ;
	TotChgAvg = TotChgAvg[1] + SF * ( AbsValue( Change ) - TotChgAvg[1] ) ;
	end ;

if TotChgAvg <> 0 then
	ChgRatio = NetChgAvg / TotChgAvg 
else
	ChgRatio = 0 ;

SRSI = 50 * ( ChgRatio + 1 ) ;


Indicator: SRSI

// TASC JUL 2015
// SRSI

inputs: 
	iPrice( numericseries ), 
	Length( numericsimple ),{ this input assumed to be a constant >= 1 }
	SMoothingLength( numericsimple ) ;

variables:
	NetChgAvg( 0 ), 
	TotChgAvg( 0 ), 
	Change( 0 ), 
	SF( 1 / Length ), { smoothing factor }
	ChgRatio( 0 ),
	Price( 0 ) ;

Price = XAverage( iPrice, SMoothingLength ) ;

if CurrentBar = 1 then
	begin
	NetChgAvg = ( Price - Price[Length] ) / Length ;
	TotChgAvg = Average( AbsValue( Price - Price[1] ), Length ) ;
	end
else
	begin
	Change = Price - Price[1] ;
	NetChgAvg = NetChgAvg[1] + SF * ( Change - NetChgAvg[1] ) ;
	TotChgAvg = TotChgAvg[1] + SF * ( AbsValue( Change ) - TotChgAvg[1] ) ;
	end ;

if TotChgAvg <> 0 then
	ChgRatio = NetChgAvg / TotChgAvg 
else
	ChgRatio = 0 ;

SRSI = 50 * ( ChgRatio + 1 ) ;

To download the EasyLanguage code, please visit our TradeStation and EasyLanguage support forum. The code from this article can be found at https://www.tradestation.com/TASC-2015. The ELD filename is “TASC_JUL2015.ELD.”

For more information about EasyLanguage in general, please see https://www.tradestation.com/EL-FAQ.

A sample chart is shown in Figure 1.

Sample Chart

FIGURE 1: TRADESTATION. This shows the SRSI indicator along with the standard RSI indicator for comparison, applied to the daily S&P 500 index.

This article is for informational purposes. No type of trading or investment recommendation, advice, or strategy is being made, given, or in any manner provided by TradeStation Securities or its affiliates.

—Doug McCrary
TradeStation Securities, Inc.
www.TradeStation.com

BACK TO LIST

logo

eSIGNAL: JULY 2015

For this month’s Traders’ Tip, we’re providing the study SRSI.efs based on Vitali Apirine’s article in the April 2015 issue of STOCKS & COMMODITIES, “The Slow Relative Strength Index.” In it, Apirine applies an exponential moving average to smooth J. Welles Wilder’s classic relative strength index (RSI).

The study requires eSignal 12.1 or higher and contains formula parameters that may be configured through the edit chart window (right-click on the chart and select “edit chart”). A sample chart implementing the study is shown in Figure 2.

Sample Chart

FIGURE 2: eSIGNAL. Here is an example of the study plotted on a chart of the S&P 500 emini (ES).

To download this study or a copy of the EFS code, please visit our EFS library. To discuss this formula, please visit the EFS studies forum.

The code is also shown here:

/*********************************
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.grey, 0);
    setDefaultBarFgColor(Color.grey, 1);
    setDefaultBarFgColor(Color.grey, 2);
        
    setShowCursorLabel(false, 0);
    setShowCursorLabel(false, 1);
    setShowCursorLabel(false, 2);
    setShowCursorLabel(true, 3);
    
    setDefaultBarStyle(PS_SOLID, 0);
    setDefaultBarStyle(PS_SOLID, 1);
    setDefaultBarStyle(PS_DASHDOT, 2);
    setDefaultBarStyle(PS_SOLID, 3);

    var x = 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(fpLengthEMA, fpLengthAvgDiff, fpSRSIHighBorder, fpSRSILowBorder){

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

    if (!bInit){

        xDifferences = efsInternal('Calc_Differences', fpLengthEMA);
        xPositiveDiff = getSeries(xDifferences, 0);
        xNegativeDiff = getSeries(xDifferences, 1);
        
        xPositiveDiffAvg = smma(fpLengthAvgDiff, xPositiveDiff);
        xNegativeDiffAvg = smma(fpLengthAvgDiff, xNegativeDiff);
                      
        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 / (1 + (nPositiveDiffAvg / nNegativeDiffAvg)));
    
    return [fpSRSIHighBorder, fpSRSILowBorder, 50, nSRSI];
}

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 [nPositiveDiff, nNegativeDiff];
}

function verify(){
    var b = false;
    if (getBuildNumber() < 3742){
        
        drawTextAbsolute(5, 35, "This study requires version 12.1 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=https://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;
}

—Eric Lippert
eSignal, an Interactive Data company
800 779-6555, www.eSignal.com

BACK TO LIST

logo

THINKORSWIM: JULY 2015

In “The Slow Relative Strength Index,” which appeared in the April 2015 issue of STOCKS & COMMODITIES, author Vitali Apirine provided a new look to a topical, old technical analysis tool, the relative strength index (RSI). He uses the analogy “slow and steady wins the race” to explain how to build a new RSI, which has a slowing or smoothing mechanism.

We have recreated his slow relative strength index (SRSI) in a SlowRSI study using our proprietary scripting language, thinkscript. We have made the loading process extremely easy. Simply click on the link https://tos.mx/Wu94qa and choose save script to thinkorswim, then choose to rename your study to “SlowRSI.” You can adjust the parameters of these within the edit studies window to fine-tune your variables.

In the example shown in Figure 3, you see the slow RSI plotted on a chart of the S&P 500 index over the past year. It is easy to see that the SRSI is much smoother than the traditional RSI. For more details about the SRSI, see Apirine’s article in the April 2015 issue, available at Traders.com.

Sample Chart

FIGURE 3: THINKORSWIM. Here is an example of the slow RSI (SRSI) plotted on a chart of the S&P 500 index over the past year. It is easy to see that the SRSI is much smoother than the traditional RSI.

—thinkorswim
A division of TD Ameritrade, Inc.
www.thinkorswim.com

BACK TO LIST

logo

THINKORSWIM: JUNE 2015

In “RSI & Price Trends,” which appeared in the June 2015 issue of STOCKS & COMMODITIES, author Kevin Luo attempts to build a winning strategy around an old technical analysis tool, the RSI. We have recreated his RSITrend strategy using our proprietary scripting language, thinkscript.

We have made the loading process extremely easy. Simply click on the link https://tos.mx/PKDtbn and choose backtest in thinkorswim, then choose to rename your strategy to “RSITrend.” You can adjust the parameters within the edit studies window to fine-tune your variables.

In the example chart shown in Figure 4, we see entry & exit points based on the logic, which the article defined. This example is for symbol SPY. The green histogram below the volume displays the profit based on this strategy. For a more detailed description of the strategy, see Luo’s article in the June 2015 issue of S&C or at the Traders.com website.

Sample Chart

FIGURE 4: THINKORSWIM. Here are sample entry & exit points on the SPY based on the logic behind Luo’s RSITrend strategy as described in his June 2015 article. The green histogram below the volume displays the profit based on this strategy.

—thinkorswim
A division of TD Ameritrade, Inc.
www.thinkorswim.com

BACK TO LIST

logo

WEALTH-LAB: JULY 2015

The slow relative strength index (SRSI) presented by Vitali Apirine in his April 2015 STOCKS & COMMODITIES article, “The Slow Relative Strength Index,” is a momentum price oscillator similar to J. Welles Wilder’s classic relative strength index (RSI) in its application and interpretation. Oscillating between zero and 100, it becomes overbought after reaching 80 and oversold after dropping below 20. Signals can also be generated by looking for centerline crossovers and divergences. The latter trait is what our example trading system will zero in on.

There are several approaches that help identify divergences between price and oscillator. The one we’re going to use is straightforward, detecting a divergence when the SRSI indicator fails to confirm a price extreme, that is, the highest high of 20 days for short trades or the 20-day lowest low for long trades. If we were to rely on finding retracements from a recent peak or trough, divergence detection would introduce a little delay compared to this technique.

As the author suggests, bullish/bearish divergences generated by SRSI are not as effective during strong trends. To avoid fading an established trend, the system is used in conjunction with the average directional movement index (ADX) as trend-confirmation tool. If the ADX is below its threshold for a trending market, the system would enter the trade (Figure 5).

Sample Chart

FIGURE 5: WEALTH-LAB. A bearish divergence that formed in January 2014 between the SRSI and price triggered a short trade in KO (Coca-Cola).

After updating the TASCIndicators library to v2015.06 or later in Wealth-Lab, the SRSI indicator can be found under the “TASC Magazine Indicators” group. You can plot SRSI on a chart or use it as an entry or exit condition in a rule-based strategy without having to program any code yourself.

WEALTH-LAB CODE:

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
using TASCIndicators;

namespace WealthLab.Strategies
{
	/*
		SRSI divergence:
		Price sets a lowest low but the indicator fails to confirm the new low and turns up
	*/
	
	public class SRSI_Divergence : WealthScript
	{
		private StrategyParameter paramHighest;
		private StrategyParameter paramPeriod;
		private StrategyParameter paramPeriodWMA;
		private StrategyParameter paramThresholdForTrend;
		private StrategyParameter paramExitDays;
		
		public SRSI_Divergence()
		{
			paramPeriod = CreateParameter("SRSI period", 6, 1, 100, 1);
			paramPeriodWMA = CreateParameter("WilderMA period", 14, 1, 100, 1);
			paramThresholdForTrend = CreateParameter("ADX Threshold", 30, 10, 50, 10);
			paramHighest = CreateParameter("Highest high of", 20, 5, 50, 1);
			paramExitDays = CreateParameter("Exit after", 20, 1, 50, 1);
		}
		
		protected override void Execute()
		{
			bool peak = false; int peakBar = -1;
			int high = paramHighest.ValueInt;
			bool trough = false; int troughBar = -1;
			int low = paramHighest.ValueInt;
			int period = paramPeriod.ValueInt;
			int periodWMA = paramPeriodWMA.ValueInt;
			int days = paramExitDays.ValueInt;
			int thresholdForTrend = paramThresholdForTrend.ValueInt;
			
			ADX adx = ADX.Series(Bars,periodWMA);			
			SRSI srsi = SRSI.Series( Close, period, periodWMA );
			Lowest indicatorLowest = Lowest.Series( srsi, low );
			Lowest hLow = Lowest.Series( Low, low );
			
			HideVolume(); LineStyle solid = LineStyle.Solid;
			ChartPane srsiPane = CreatePane( 50, false, true );
			PlotSeries( srsiPane, srsi, Color.Green, solid, 2 );
			ChartPane adxPane = CreatePane( 25, true, true );
			PlotSeries( adxPane, adx, Color.Red, solid, 2 );
			DrawHorzLine(adxPane,thresholdForTrend,Color.Blue,LineStyle.Dashed,1);

			for(int bar = GetTradingLoopStartBar(period); bar < Bars.Count; bar++)
			{
				if (!IsLastPositionActive)
				{
					/* 1st peak: both price and indicator */
					
					if( peak == false )
					{
						if( ( High[bar-1] == Highest.Series( High, high )[bar-1] )
							& ( srsi[bar-1] == Highest.Series( srsi, high )[bar-1] )
							& TurnDown( bar, High ) & TurnDown( bar, srsi ) )							
						{
							peak = true; peakBar = bar-1;
						}
					}
					
					if( peak == true )
					{
						if( ( High[bar] != Highest.Series( High, high )[bar] )
							& ( srsi[bar] == Highest.Series( srsi, high )[bar] ) )
							peak = false;
                     }

					/* 2nd peak: price high not confirmed by the indicator */

					if( peak == true )
					{
						if( ( High[bar-1] == Highest.Series( High, high )[bar-1] )
							& ( High[bar-1] >= High[peakBar] )
							& ( srsi[bar-1] != Highest.Series( srsi, high )[bar-1] )
							& ( srsi[bar-1] < srsi[peakBar] ) &
							TurnDown( bar, High ) & TurnDown( bar, srsi ) )
						{
							peak = false;
							
							/* Don't fade a strong trend */
							
							if( adx[bar] < thresholdForTrend )
								ShortAtMarket( bar+1 );
						
							/* Highlight divergence */
						
							for (int b = peakBar; b <= bar; b++)
								SetPaneBackgroundColor( srsiPane, b, Color.FromArgb( 30, Color.LightCoral ) );
							
							DrawLine( PricePane, peakBar, High[peakBar], bar-1, High[bar-1], Color.Red, solid, 2 );
							DrawLine( srsiPane, peakBar, srsi[peakBar], bar-1, srsi[bar-1], Color.Blue, solid, 2 );
						}
					}

					/* 1st trough: both price and indicator */
					
					if( trough == false )
					{
						if( ( Low[bar-1] == Lowest.Series( Low, low )[bar-1] )
							& ( srsi[bar-1] == Lowest.Series( srsi, low )[bar-1] )
							& TurnUp( bar, Low ) & TurnUp( bar, srsi ) )							
						{
							trough = true; troughBar = bar-1;
						}
					}
					
					if( trough == true )
					{
						if( ( Low[bar] != Lowest.Series( Low, low )[bar] )
							& ( srsi[bar] == Lowest.Series( srsi, low )[bar] ) )
							trough = false;
                    }

					/* 2nd trough: price low not confirmed by the indicator */

					if( trough == true )
					{
						if( ( Low[bar-1] == Lowest.Series( Low, low )[bar-1] )
							& ( Low[bar-1] <= Low[troughBar] )
							& ( srsi[bar-1] != Lowest.Series( srsi, low )[bar-1] )
							& ( srsi[bar-1] > srsi[troughBar] ) &
							TurnUp( bar, Low ) & TurnUp( bar, srsi ) )
						{
							trough = false;
                            
                            /* Don't fade a strong trend */
							
							if( adx[bar] < thresholdForTrend )
								BuyAtMarket( bar+1 );
						
							/* Highlight divergence */
						
							for (int b = troughBar; b <= bar; b++)
								SetPaneBackgroundColor( srsiPane, b,
									Color.FromArgb( 30, Color.LightGreen ) );
							
							DrawLine( PricePane, troughBar, Low[troughBar],
								bar-1, Low[bar-1], Color.Blue, solid, 2 );
							DrawLine( srsiPane, troughBar, srsi[troughBar],
								bar-1, srsi[bar-1], Color.Red, solid, 2 );
						}
					}
				} else
				{
					/* Exit after N days */
					
					Position p = LastPosition;
					if ( bar+1 - p.EntryBar >= days )
						ExitAtMarket( bar+1, p, "Timed" );
				}
			}
		}
	}
}

—Eugene, Wealth-Lab team
MS123, LLC
www.wealth-lab.com

BACK TO LIST

logo

AMIBROKER: JULY 2015

In “The Slow Relative Strength Index” in the April 2015 issue of S&C, author Vitali Apirine presents a “slow” version of the classic RSI indicator. A ready-to-use AmiBroker formula is shown here. To use it, enter the code in the formula editor and press apply indicator. You can adjust the exponential average period and the RSI smoothing period using the parameters window.

A sample chart is shown in Figure 6.

Sample Chart

FIGURE 6: AMIBROKER. Here is the daily slow RSI (6,14) of the S&P 500 (upper pane) with a daily price chart of the S&P 500 during 2011 with breakouts and divergences.

AmiBroker code:
// Slow RSI 

periods = Param( "Period", 6, 1, 100 ); 
smooth =  Param( "Smoothing", 14, 1, 100 ); 

// use current symbol close 
price = Close; 

// but can use other security data too 
// price =  Foreign( "∧SPX", "C" ); 

R1 = EMA( price, periods ); 
R2 = IIf( price > r1, price - R1, 0 ); 
R3 = iIf( price < r1, r1 - price, 0 ); 
R4 = Wilders( R2, smooth ); 
R5 = Wilders( R3, smooth ); 
RR = IIf( R5 == 0, 100, 100 - ( 100 / ( 1 + ( R4 / R5 ) ) ) ); 

Plot( RR, "SlowRSI" + _PARAM_VALUES(), colorRed );

—Tomasz Janeczko, AmiBroker.com
www.amibroker.com

BACK TO LIST

logo

AIQ: JULY 2015

The AIQ code based on Vitali Apirine’s article in the April 2015 issue of STOCKS & COMMODITIES, “The Slow Relative Strength Index,” is shown here. This code for the slow RSI (SRSI) is for use as an indicator. A sample chart illustrating the SRSI is shown in Figure 7.

Sample Chart

FIGURE 7: AIQ. This example chart shows the slow RSI (6,14) compared to the classic RSI (14).

!THE SLOW RELATIVE STRENGTH INDEX
!Author: Vitali Aprine, TASC April 2015
!Coded by: Richard Denning 5/3/2015
!www.TradersEdgeSystems.com

!INPUTS FOR INDICATOR:
emaLen is 6.
wilderLen is 14.

!INDICATOR FORMULAS:
ema is expavg([close],emaLen).
pDif is iff([close] - ema > 0,[close] - ema,0).
nDif is iff([close] - ema < 0,ema - [close],0).

rsiLen	is 2 * wilderLen - 1.
AvgU 	is expavg(pDif,rsiLen).
AvgD 	is expavg(nDif,rsiLen).
srsi	is 100-(100/(1+(AvgU/AvgD))). !PLOT

The code and EDS file can be downloaded from www.TradersEdgeSystems.com/traderstips.htm.

—Richard Denning
info@TradersEdgeSystems.com
for AIQ Systems

BACK TO LIST

logo

TRADERSSTUDIO: JULY 2015

The TradersStudio code based on Vitali Apirine’s article that appeared the April 2015 issue of STOCKS & COMMODITIES, “The Slow Relative Strength Index,” is provided at the following two websites:

The following code files are provided in the download:

The code is also shown here:

'THE SLOW RELATIVE STRENGTH INDEX
'Author: Vitali Aprine, TASC April 2015
'Coded by: Richard Denning 5/3/2015
'www.TradersEdgeSystems.com

function SlowRSI(emaLen, wilderLen)
'emaLen = 6, wilderLen = 14

'INDICATOR FORMULAS:
Dim ema,pDif,nDif,rsiLen,AvgU,AvgD
Dim sRSI As BarArray
ema = xaverage(C,emaLen)
pDif = IIF(C - ema > 0,C - ema,0)
nDif = IIF(C - ema < 0,ema - C,0)

rsiLen  = 2 * wilderLen - 1
AvgU    = xaverage(pDif,rsiLen)
AvgD    = xaverage(nDif,rsiLen)
if avgd <> 0 then sRSI    = 100-(100/(1+(AvgU/AvgD)))
SlowRSI = sRSI
End Function
'----------------------------------------
'INDICATOR PLOT CODE:
sub SlowRSI_IND(emaLen, rsiLen)
plot1(slowRSI(emaLen, rsiLen))
plot2(70)
plot3(30)
End Sub
'----------------------------------------

—Richard Denning
info@TradersEdgeSystems.com
for TradersStudio

BACK TO LIST

logo

TRADERSSTUDIO: JUNE 2015

The TradersStudio code based on Kevin Luo’s article in the June 2015 issue of STOCKS & COMMODITIES, “RSI & Price Trends,” is provided at the following websites:

The following code file is provided in the download:

Using the NASDAQ 100 list of stocks, I ran the EQUALDOLLAR tradeplan that comes with the product. Figure 8 shows the log chart of the equity curve for the years 1991 through 2014. The associated underwater equity curve is shown in the same figure. The system returned about 9% compounded over the period with two of the largest drawdowns occurring during the 2000–2003 (29%) and the 2007–2009 (25%) bear market. Otherwise, the drawdowns run around 5–10%.

Sample Chart

FIGURE 8: TRADERSSTUDIO. Here is the log equity curve and underwater equity curve for the RSITREND system run on the EQUALDOLLAR tradeplan using the NASDAQ 100 list of stocks for the years 1991–2014.

TradersStudio code:

'RSI & PRICE TRENDS

'Author: Kevin Luo, TASC June 2015

'Coded by: Richard Denning 4/22/2015

'www.TradersEdgeSystems.com



Sub RSITREND(rsiLen,buyLvl,LLlen1,LLlen2,minPctUp1,minPctUp2,exitLvl)

'rsiLen=14,buyLvl=50,LLlen1=250,LLlen2=20,minPctUp1=20,minPctUp2=5,exitLvl=70

Dim theRSI As BarArray

theRSI = rsi(C,rsiLen,0)

'Dim LL1 As BarArray

'Dim LL2 As BarArray

Dim LL1, LL2, barsSinceLL1, barsSinceLL2,  HHsinceLL1, HHsinceLL2, RoC1, RoC2

Dim trendUpLT As BarArray

Dim trendUpST As BarArray

LL1 = Lowest(L,LLlen1,0)

LL2 = Lowest(L,LLlen2,0)

barsSinceLL1 = MRO(L = LL1,LLlen1,1)

barsSinceLL2 = MRO(L = LL2,LLlen2,1)

HHsinceLL1 = Highest(H,barsSinceLL1,0)

HHsinceLL2 = Highest(H,barsSinceLL2,0)

RoC1 = (HHsinceLL1 / LL1 - 1) * 100

RoC2 = (HHsinceLL2 / LL2 - 1) * 100

trendUpLT = RoC1 >= minPctUp1

trendUpST = RoC2 >= minPctUp2

If trendUpLT And trendUpST And theRSI>buyLvl And theRSI[1]<= buyLvl Then

    Buy("LE",1,0,Market,Day)

End If

If RoC1 < minPctUp1 Then ExitLong("LX_trend","",1,0,Market,Day)

If theRSI<exitLvl And theRSI[1]>=exitLvl Then ExitLong("LX_rsi","",1,0,Market,Day)

End Sub

—Richard Denning
info@TradersEdgeSystems.com
for TradersStudio

BACK TO LIST

logo

NEUROSHELL TRADER: JULY 2015

The SRSI, described by Vitali Apirine in his April 2015 article in S&C, “The Slow Relative Strength Index,” can be easily implemented with a few of NeuroShell Trader’s 800+ indicators. Simply select new indicator from the insert menu and use the indicator wizard to create the following indicators:

R1: ExpAvg(Close,6)
R4: ExpAvg(IfThenElse(A>B(Close,R1),Sub(Close,R1),0),14)
R5: ExpAvg(IfThenElse(A<B(Close,R1),Sub(R1,Close),0),14)
RR: IfThenElse(A=B(R5,0),100,Sub(100,Divide(100,Add2(1,Divide(R4,R5)))))

Users of NeuroShell Trader can go to the STOCKS & COMMODITIES section of the NeuroShell Trader free technical support website to download a copy of this or any previous Traders’ Tips.

A sample chart is shown in Figure 9.

Sample Chart

FIGURE 9: NEUROSHELL TRADER. This NeuroShell Trader chart displays the RSI and the SRSI on the S&P 500 index.

—Marge Sherald, Ward Systems Group, Inc.
301 662-7950, sales@wardsystems.com
www.neuroshell.com

BACK TO LIST

logo

NINJATRADER: JULY 2015

The SRSI or slow relative strength index, as discussed by Vitali Apirine in his April 2015 article in S&C, “The Slow Relative Strength Index,” is available for download at www.ninjatrader.com/SC/July2015SC.zip.

Once it has been downloaded, from within the NinjaTrader Control Center window, select the menu File→Utilities→Import NinjaScript and select the downloaded file. This file is for NinjaTrader version 7 or greater.

You can review the indicator source code by selecting the menu Tools→Edit NinjaScript→Indicator from within the NinjaTrader Control Center window and selecting the “SRSI” file.

A sample chart implementing the indicator is shown in Figure 10.

Sample Chart

FIGURE 10: NINJATRADER. This screenshot shows the SRSI applied to the S&P 500 index (SPX) in NinjaTrader from August 4, 2000 to October 2, 2000.

—Raymond Deux & Patrick Hodges
NinjaTrader, LLC
www.ninjatrader.com

BACK TO LIST

logo

UPDATA: JULY 2015

This month’s Traders’ Tip is based on “The Slow Relative Strength Index” by Vitali Apirine, which appeared in the April 2015 issue of S&C.

The author delivers a variation on J. Welles Wilder’s classic relative strength index (RSI) by substituting the close-to-close differences input, with the difference between the close to a moving average. This produces a smoother indicator (see Figure 11), and one the author suggests clarifies momentum changes and price–indicator divergences.

Sample Chart

FIGURE 11: UPDATA. This chart shows the daily S&P 500 Index with the SRSI [14] shown with the standard RSI [14] for comparison.

The Updata code for this indicator is in the Updata library and may be downloaded by clicking the custom menu and then indicator library. The code can also be pasted into the Updata custom editor.

PARAMETER "Avg.Period" #PERIOD=6
PARAMETER "RSI Period" #RSIPeriod=14 
NAME "SRSI [" #RSIPeriod "]" ""
@AVG=0
@POSITIVEDIFF=0
@NEGATIVEDIFF=0   
@AVGPOSITIVEDIFF=0
@AVGNEGATIVEDIFF=0  
@SRS=0 
@SRSI=0
FOR #CURDATE=#PERIOD TO #LASTDATE
   @AVG=EAVE(#PERIOD)
   @POSITIVEDIFF=MAX(CLOSE-@AVG,0)
   @NEGATIVEDIFF=MAX(@AVG-CLOSE,0) 
   IF #CURDATE=#PERIOD-1  
      @AVGPOSITIVEDIFF=SGNL(@POSITIVEDIFF,#RSIPeriod,M)
      @AVGNEGATIVEDIFF=SGNL(@NEGATIVEDIFF,#RSIPeriod,M) 
   ELSEIF #CURDATE>#PERIOD-1  
      @AVGPOSITIVEDIFF=((#RSIPeriod-1)*@AVGPOSITIVEDIFF+@POSITIVEDIFF)/#RSIPeriod
      @AVGNEGATIVEDIFF=((#RSIPeriod-1)*@AVGNEGATIVEDIFF+@NEGATIVEDIFF)/#RSIPeriod
   ENDIF
   @SRS=@AVGPOSITIVEDIFF/@AVGNEGATIVEDIFF
   @SRSI=100-(100/(1+@SRS)) 
   @PLOT=@SRSI  
NEXT
 

—Updata support team
support@updata.co.uk, www.updata.co.uk

BACK TO LIST

MICROSOFT EXCEL: JULY 2015

“The Slow Relative Strength Index” by Vitali Apirine, which appeared in the April 2015 issue of S&C, discusses an indicator that is a variation of the relative strength index (RSI). The author uses the difference between the close and a moving average as the input. The slow relative strength index (SRSI) can be calculated using an Excel spreadsheet, as presented here.

Sample Chart

FIGURE 12: MICROSOFT Excel. This sample chart shows the SPX, a six-period EMA of the SPX, and the SRSI (6,14) in the subplot. The SRSI calculation begins after 14 days of data have been recorded.

The spreadsheet contains calculations for the SRSI (6,14), SRSI (8,14) and SRSI (8,17). A sample chart plotted from the calculations is shown in Figure 12. Following are the Excel spreadsheet formulas for the SRSI (6,14):

Column A: Date

Column B: SPX close (closing price of SPX).

Column C: 6-period exponential moving average (EMA) starting on row 7 
=AVERAGE(B2:B7) and copy this down to all cells in column.

Column D: Positive difference starting on row 7 
=IF(B7>C7,B7-C7,0) and copy this down to all cells in column.

Column E: Negative difference starting on row 7
=IF (B7<C7,C7-B7,0) and copy this down to all cells in column.

Column F: Average positive difference starting on row 20
=SUM(D7:D20)/14 and copy this down to all cells in column.

Column G: Average negative difference starting on row 20
=SUM(E7:E20)/14 and copy this down to all cells in column.

Column H: Slow relative strength (SRS) starting on row 20
=IF(G20=0,100,F20/G20) and copy this down to all cells in column.

Column I: 14-day slow relative strength index (SRSI) starting on row 20
=IF(H20=100,100,100-(100(1+H20)))

The calculations for SRSI (8,14) and SRSI (8,17) are similar except the eight-period EMA will be calculated after the eighth closing price and the SRSI calculations will start after 14 days of data have been recorded for SRSI (8,14) and after 17 days of data have been recorded for SRSI (8,17).

The spreadsheet file for this Traders’ Tip can be downloaded here. To successfully download it, follow these steps:

—Editor

BACK TO LIST

Originally published in the July 2015 issue of
Technical Analysis of STOCKS & COMMODITIES magazine.
All rights reserved. © Copyright 2015, Technical Analysis, Inc.