TRADERS’ TIPS

January 2011

Here is this month’s selection of Traders’ Tips, contributed by various developers of technical analysis software to help readers more easily implement some of the strategies presented in this and other issues.

Other code appearing in articles in this issue is posted in the Subscriber Area of our website at https://technical.traders.com/sub/sublogin.asp. Login requires your last name and subscription number (from mailing label). Once logged in, scroll down to beneath the “Optimized trading systems” area until you see “Code from articles.” From there, code can be copied and pasted into the appropriate technical analysis program so that no retyping of code is required for subscribers.

You can copy these formulas and programs for easy use in your spreadsheet or analysis software. Simply “select” the desired text by highlighting as you would in any word processing program, then use your standard key command for copy or choose “copy” from the browser menu. The copied text can then be “pasted” into any open spreadsheet or other software by selecting an insertion point and executing a paste command. By toggling back and forth between an application window and the open web page, data can be transferred with ease.

This month’s tips include formulas and programs for:


Return to Contents


TRADESTATION: COMBINING RSI WITH RSI

In “Combining Rsi With Rsi” in this issue, author Peter Konner describes the use of two different Rsi calculations using different lengths to allow trading of retracements as well as longer-term positions. The five-week and 17-week Rsi values are used for entry and exits while the 17-week Rsi is used for trend direction as an entry filter in the retracement entries.

We have developed EasyLanguage code for an Rsi indicator (“_Rsi”) and a strategy (“_Rsi_With_Rsi”). The “_Rsi” indicator colors the plot to represent the trend direction as determined by the 17-bar Rsi. Entry and exit conditions for the strategy can be found in the code comments in the strategy.

To download the EasyLanguage code for the indicator and strategy, go to the TradeStation and EasyLanguage Support Forum (https://www.tradestation.com/Discussions/forum.aspx?Forum_ID=213) and search for the file “Combining_Rsi_With_Rsi.eld.” The code is also shown below.

_RSI (Indicator)

inputs:
	Price( Close ),
	Length( 17 ),
	OverSold( 40 ),
	OverBought( 60 ),
	UpColor( Cyan ), 
	DownColor( Red ) ;

variables:  
	RSITrendDir( 0 ),
	MyRSI( 0 ) ;

MyRSI = RSI( Price, Length ) ;
 
Plot1( MyRSI, "RSI" ) ;
Plot2( OverBought, "OverBot" ) ;
Plot3( OverSold, "OverSld" ) ;

if MyRSI crosses above OverBought then
	RSITrendDir = 1
else if MyRSI crosses below OverSold then
	RSITrendDir = -1 ;
	
{ Color criteria }
if RSITrendDir = 1 then 
	SetPlotColor( 1, UpColor ) 
else if RSITrendDir = -1 then 
	SetPlotColor( 1, DownColor ) ;



_RSI_With_RSI (Strategy)

{
This strategy is based on the TASC Article in the 
January 2011 issue titled "Combining RSI With RSI"
by Peter Konner.  This strategy takes long positions
only based on the RSI and a Simple Moving Average.
This strategy is coded for end of bar only (IOG set
to false).

Buy Conditions:
1.  Slow RSI crosses above 60 and the Close is greater
    than the Slow Moving Average.
   OR
2.  Quick RSI crosses above 60, the Close is greater
	than the Quick Moving Average and the Slow RSI
	is indicating a down trend.
	
Exit Conditions:
1.  The Slow RSI entry is exited if the Slow RSI 
	crosses below 40 OR the Close is less than the
	Slow Moving Average.
2.  The Quick RSI entry is exited if the Quick RSI
	crosses below 40 OR the Close is less than the
	Quick Moving Average.
}

[IntrabarOrderGeneration = False ]

inputs:
	SlowRSILen( 17 ),
	QuickRSILen( 5 ),
	SlowMALen( 40 ),
	QuickMALen( 10 ),
	RSIBuyLevel( 60 ),
	RSISellLevel( 40 ) ;

variables:
	OkToTrade( false ),
	SlowRSI( 0 ),
	QuickRSI( 0 ),
	SlowMA( 0 ),
	QuickMA( 0 ),
	SlowRSITrendDir( 0 ) ;
	
SlowRSI = RSI( C, SlowRSILen ) ;
QuickRSI = RSI( C, QuickRSILen ) ;
SlowMA = Average( C, SlowMALen ) ;
QuickMA = Average( C, QuickMALen ) ;

{ Determine Trend Direction }
if SlowRSI crosses above RSIBuyLevel then
	SlowRSITrendDir = 1
else if SlowRSI crosses below RSISellLevel then
	SlowRSITrendDir = -1 ;

{ Trading not allowed until stabilization of RSI 
  Values}
once ( CurrentBar = 10 * SlowRSILen )
	OkToTrade = true ;

if OkToTrade then
	begin
	
	{ Entries }
	if SlowRSI crosses above RSIBuyLevel 
 		and C > SlowMA 
 	then
		Buy ( "sRSI LE" ) next bar market ;
	
	if QuickRSI crosses above RSIBuyLevel 
		and C > QuickMA 
		and SlowRSITrendDir = -1 
	then
		Buy( "qRSI LE" ) next bar market ;
	
	{ Exits }
	if SlowRSI crosses below RSISellLevel 
		or C < SlowMA 
	then
		Sell ( "sRSI LX" ) from entry ( "sRSI LE" ) 
	 	 next bar market ;
	
	if QuickRSI crosses below RSISellLevel 
 		or C < QuickMA 
 	then
		Sell ( "qRSI LX" ) from entry ( "qRSI LE" ) 
	 	 next bar market ;
	 	 
	end ;

A sample chart is shown in Figure 1.

FIGURE 1: TRADESTATION, RSI WITH RSI. Here is a weekly bar chart of Google displaying the built-in indicator “Mov Avg 2 Lines” (the magenta plot is a 40-bar simple moving average of the close and the cyan plot is a 10-bar simple moving average of the close) using the “_RSI_With_RSI” strategy code. In the subgraphs, the “_RSI” indicator is plotted, with the top graph a five-bar RSI and the bottom graph a 17-bar RSI.

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.

—Chris Imhof, TradeStation Securities, Inc.
A subsidiary of TradeStation Group, Inc.
www.TradeStation.com

BACK TO LIST


METASTOCK: COMBINING RSI WITH RSI

Peter Konner’s article in the January 2011 issue, “Combining Rsi With Rsi,” describes a long-term system intended to be used with weekly data. The steps to create an expert advisor for MetaStock based on this system are shown below.

  1. Select ToolsExpert Advisor.
  2. Click New to open the Expert Editor.
  3. Type in a name for your expert.
  4. Select the Symbols tab.
  5. Click New to create a new symbol.
  6. Type in the name “Uptrend Buy”.
  7. Click in the condition window and type in the formula.
    bc1:= Cross( RSI(17) > 60 AND C > Mov( C, 40, S), 0.5);
    bc2:= Cross( RSI(5) > 60 AND C > Mov( C, 10, S), 0.5);
    sc1:=  Cross( RSI(17) < 40 AND C < Mov( C, 40, S), 0.5);
    sc2:= Cross( RSI(5) < 40 AND C < Mov( C, 10, S), 0.5);
    trade1:= If(bc1, 1, If(sc1, 0, PREV));
    trade2:= If(bc2, 1, If(sc2, 0, PREV));
    Cross(trade1=1, 0.5) OR (trade1=0 AND Cross(trade2=1, 0.5))
    
  8. Select the Graphics tab
  9. Set the symbol to the Up Arrow
  10. Set the color to Green
  11. in the Label window, type “Buy”
  12. set the symbol position to “Below Price Plot
  13. set the label position to “Below Symbol
  14. Click OK
  15. Click New to create a new symbol.
  16. Type in the name “Uptrend Sell”.
  17. Click in the condition window and type in the formula.
    bc1:= Cross( RSI(17) > 60 AND C > Mov( C, 40, S), 0.5);
    bc2:= Cross( RSI(5) > 60 AND C > Mov( C, 10, S), 0.5);
    sc1:=  Cross( RSI(17) < 40 AND C < Mov( C, 40, S), 0.5);
    sc2:= Cross( RSI(5) < 40 AND C < Mov( C, 10, S), 0.5);
    trade1:= If(bc1, 1, If(sc1, 0, PREV));
    trade2:= If(bc2, 1, If(sc2, 0, PREV));
    Cross(trade1=0, 0.5) OR (trade1=0 AND Cross(trade2=0, 0.5))
    
  18. Select the Graphics tab
  19. Set the symbol to the Down Arrow
  20. Set the color to Red
  21. in the Label window, type “Sell”
  22. set the symbol position to “Above Price Plot
  23. set the label position to “Above Symbol
  24. Click OK
  25. Click OK to close the Expert Editor.

—William Golson
Equis International
www.MetaStock.com

BACK TO LIST


eSIGNAL: COMBINING RSI WITH RSI

For this month’s Traders’ Tip, we’ve provided the formula “RsiwithRsi.efs” based on the code from Peter Konner’s article in this issue, “Combining Rsi With Rsi.”

The study contains formula parameters to set the values for the slow Rsi, quick Rsi, slow MA, quick MA, slow Rsi buy level, slow Rsi sell level, quick Rsi buy level, and quick Rsi sell level, which may be configured through the Edit Studies window (Advanced Chart menu→Edit Studies).

To discuss this study or download complete copies of the formula code, please visit the Efs Library Discussion Board forum under the Forums link from the Support menu at www.esignal.com or visit our Efs KnowledgeBase at https://www.esignal.com/support/kb/efs/. The eSignal formula script (Efs) is also available for copying and pasting below, or as a download here.

A sample chart is shown in Figure 2.

FIGURE 2: eSIGNAL, COMBINING RSI WITH RSI


/*********************************
Provided By:  
    Interactive Data Corporation (Copyright - © 2010) 
    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:        
    Combining RSI with RSI by Peter Konner
 
Version:            1.0  11/11/2010

Formula Parameters:                     Default:
    Length of Slow RSI:                  17 
    Length of Quick RSI:                 5 
    Length of Slow MA:                   40 
    Length of Quick MA:                  10 
    Slow RSI Buy Level:                  61 
    Slow RSI Sell Level:                 39 
    Quick RSI Buy Level:                 61 
    Quick RSI Sell Level:                39 
     
    
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(); 
var bVersion = null; 
function preMain()
{
    setShowTitleParameters(false); 
    setColorPriceBars(true); 
    setDefaultBarFgColor(Color.green,0); 
    setDefaultBarFgColor(Color.red,1); 
    setShowCursorLabel(false); 
 
    var x=0;
    fpArray[x] = new FunctionParameter("gSlowRSILen", FunctionParameter.NUMBER);
    with(fpArray[x++])
    {
	setName("Length of Slow RSI");
	setLowerLimit(1);
        setDefault(17);
    } 
    fpArray[x] = new FunctionParameter("gQuickRSILen", FunctionParameter.NUMBER);
    with(fpArray[x++])
    {
	setName("Length of Quick RSI");
	setLowerLimit(1);
        setDefault(5);
    } 
    fpArray[x] = new FunctionParameter("gSlowMALen", FunctionParameter.NUMBER);
    with(fpArray[x++])
    {
	setName("Length of Slow MA");
	setLowerLimit(1);
        setDefault(40);
    } 
    fpArray[x] = new FunctionParameter("gQickMALen", FunctionParameter.NUMBER);
    with(fpArray[x++])
    {
	setName("Length of Quick MA");
	setLowerLimit(1);
        setDefault(10);
    } 
    fpArray[x] = new FunctionParameter("gSlowBuyRSI", FunctionParameter.NUMBER);
    with(fpArray[x++])
    {
	setName("Slow RSI Buy Level");
	setLowerLimit(1);
        setDefault(61);
    } 
    fpArray[x] = new FunctionParameter("gSlowSellRSI", FunctionParameter.NUMBER);
    with(fpArray[x++])
    {
	setName("Slow RSI Sell Level");
	setLowerLimit(1);
        setDefault(39);
    }     
    fpArray[x] = new FunctionParameter("gQuickBuyRSI", FunctionParameter.NUMBER);
    with(fpArray[x++])
    {
	setName("Quick RSI Buy Level");
	setLowerLimit(1);
        setDefault(61);
    } 
    fpArray[x] = new FunctionParameter("gQuickSellRSI", FunctionParameter.NUMBER);
    with(fpArray[x++])
    {
	setName("Quick RSI Sell Level");
	setLowerLimit(1);
        setDefault(39);
    }             
}

var xCls = null; 
var xSlowMA = null; 
var xQuickMA = null; 
var xSlowRSI = null; 
var xQuickRSI = null; 
var bInit = false; 
var b1 = false; 
var b2 = false; 
var b3 = false; 
var b4 = false; 
var b5 = false; 
var b6 = false; 
var i=0;
function main( gSlowRSILen, gQuickRSILen, gSlowMALen, gQickMALen, gSlowBuyRSI,
 gSlowSellRSI, gQuickBuyRSI, gQuickSellRSI )  
{
    if (bVersion == null) bVersion = verify(); 
    if (bVersion == false) return;    
 
    if (!bInit) 
    { 
        xCls = close(); 
        xSlowMA = sma(gSlowMALen); 
        xQuickMA = sma(gQickMALen); 
        xSlowRSI = rsi(gSlowRSILen); 
        xQuickRSI = rsi(gQuickRSILen); 
        bInit = true; 
    } 
 
    var vCls = xCls.getValue(0); 
 
    var vSlowRSI1 = xSlowRSI.getValue(-2); 
    var vSlowRSI0 = xSlowRSI.getValue(-1); 
    var vSlowMA = xSlowMA.getValue(-1); 
     
    var vQuickRSI1 = xQuickRSI.getValue(-2); 
    var vQuickRSI0 = xQuickRSI.getValue(-1); 
    var vQuickMA = xQuickMA.getValue(-1); 
     
    var vSlowRSICur = xSlowRSI.getValue(0); 
    var vQuickRSICur = xQuickRSI.getValue(0); 
     
    b1 = (vSlowRSI1<=gSlowBuyRSI && vSlowRSI0>gSlowBuyRSI && vCls>vSlowMA); 
    b2 = ((vSlowRSI1>=gSlowSellRSI && vSlowRSI0<gSlowSellRSI )|| vCls<vSlowMA); 
     
    if (!b1 && b2) {b3=false; b4=true} 
    else if (b1 && !b2) {b3=true; b4=false}; 
 
    b1 = (vQuickRSI1<=gQuickBuyRSI && vQuickRSI0>gQuickBuyRSI && vCls>vQuickMA && b4); 
    b2 = (vQuickRSI1>=gQuickSellRSI && vQuickRSI0<gQuickSellRSI)||(vCls<vQuickMA); 
     
    if (!b1 && b2){b5=false; b6=true} 
    else if (b1 && !b2){b5=true; b6=false} 
     
    b1 = (b3 && b5)||(b3 && b6)||(b4 && b5); 
    b2 = (b4 && b6); 
     
    if (Strategy.isLong()) 
    { 
        if (b2) 
        { 
            drawShapeRelative(0, TopRow2,  Shape.DOWNTRIANGLE, null, Color.red,
 Shape.PRESET, "sell"+(i++));  
            drawTextRelative(0, TopRow1, " Sell ", Color.white, Color.red,
 Text.PRESET | Text.CENTER, "Arial", 10, "sell"+(i++)); 
            setPriceBarColor(Color.red); 
            Strategy.doSell("Long Exit Signal", Strategy.MARKET, Strategy.THISBAR); 
        } 
    } 
    else 
    { 
        if (b1) 
        { 
            drawShapeRelative(0, TopRow1,  Shape.UPTRIANGLE, null, Color.green,
             Shape.PRESET, "buy"+(i++));  
            drawTextRelative(0, TopRow2, " Buy ", Color.white, Color.green,
             Text.PRESET | Text.CENTER, "Arial", 10, "buy"+(i++)); 
            setPriceBarColor(Color.green); 
            Strategy.doLong("Entry Long", Strategy.MARKET, Strategy.THISBAR); 
        } 
 
    } 
    if (Strategy.isLong()) 
    { 
       setBarBgColor(Color.yellow); 
    } 
     
    return new Array (vQuickRSICur, vSlowRSICur, gSlowBuyRSI,gSlowSellRSI,gQuickBuyRSI,gQuickSellRSI); 
} 
 
function verify() { 
    var b = false; 
    if (getBuildNumber() < 779) { 
        drawTextAbsolute(5, 35, "This study requires version 8.0 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; 
}

—Jason Keck
Interactive Data Desktop Solutions
800 815-8256, www.esignalcentral.com

BACK TO LIST


WEALTH-LAB: COMBINING RSI WITH RSI

In the ongoing battle between high-frequency trading and sky-high IQ algorithms, in a scene filled with discretionary charting patterns and advanced indicators doing heavy number crunching under the hood, Peter Konner’s systematic approach described in “Combining Rsi With Rsi” stands out as an isle of clarity and simplicity.

The concept of trading corrections in a downtrend is like having a second system blended together, potentially helping to smooth overall performance. In our test on a portfolio of the Dow 30 stocks over the last 10 years with 5% of portfolio equity allocated to each position, the system was profitable and its returns exceeded net profit from buy & hold. However, trading corrections accounted for slightly more than 6% of all entry signals (six out of 91, see Figure 3).

Figure 3: WEALTH-LAB, RSI WITH RSI. Here is the equity curve of the system applied to a portfolio of the Dow 30 stocks.

The system is designed to trade weekly bars, and the average trade in this portfolio is held for over a year. Time in market is another dimension of risk, and charting the “life” of a trade (Figure 4) shows that the majority of losing trades becomes losers from the start, or hang about the breakeven level for quite a long time. With this knowledge, a potential improvement could be introduced.

Figure 4: WEALTH-LAB, RSI WITH RSI. Here is a sample Wealth-Lab Developer 6.0 chart showing the profit/loss of a single losing trade vs. the time in each trade (in weekly bars).

Considering this, we added a new, optional rule to the system:

• If after 20 (by default) weekly bars in trade, the position is still at its breakeven point or is losing money, close it at the open of the next bar (that is, next Monday).

Ruling out low-probability trades with this simple tweak positively affected the net profit (62% vs. 56%) without increasing risk, and made the system tie up less capital in unproductive trades, reducing the average trade duration by the whole quarter.

To turn this extra rule on or off in Wealth-Lab 6, simply drag the parameter slider “Exit loser?” in the bottom left corner of the main workspace, and rerun the strategy.

C# code:

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

namespace WealthLab.Strategies
{
	public class RSIwithRSI : WealthScript
	{
		private StrategyParameter paramLoser;
		private StrategyParameter paramExit;
		
		public RSIwithRSI()
		{
			paramLoser = CreateParameter("Exit loser?", 0, 0, 1, 1);
			paramExit = CreateParameter("Exit loser after", 20, 2, 50, 2);
		}
		
		protected override void Execute()
		{
			DataSeries rsiSlow = RSI.Series(Close, 17);
			DataSeries maSlow = SMA.Series(Close, 40);
			DataSeries maFast = SMA.Series(Close, 10);
			DataSeries rsiFast = RSI.Series(Close, 5);

			ChartPane paneRSI = CreatePane(35,true,true);
			PlotSeries(paneRSI, rsiSlow, Color.Blue, LineStyle.Solid, 2);
			PlotSeries(paneRSI, rsiFast, Color.Red, LineStyle.Solid, 2);
			DrawHorzLine(paneRSI, 60.00, Color.Green, LineStyle.Solid, 1);
			DrawHorzLine(paneRSI, 40.00, Color.Red, LineStyle.Solid, 1);
			PlotSeries(PricePane,maSlow,Color.Blue,LineStyle.Solid,2);
			PlotSeries(PricePane,maFast,Color.Red,LineStyle.Solid,2);

			for(int bar = GetTradingLoopStartBar(40); bar < Bars.Count; bar++)
			{
				if (IsLastPositionActive)
				{
					Position p = LastPosition;
					
					if( paramLoser.ValueInt == 1  && 
					p.NetProfitAsOfBarPercent(bar) <= 0 && 
					bar > p.EntryBar + paramExit.ValueInt )
						SellAtMarket( bar+1, p, "Exit loser" );
							
					if (p.EntrySignal.Contains("correction"))
					{
						if( (Close[bar] < maFast[bar]) && 
						CrossUnder(bar, rsiFast, 40) )
							SellAtMarket(bar + 1, p, "Correction sell");
					}
					else
					{
						if( (Close[bar] < maSlow[bar]) && 
						CrossUnder(bar, rsiSlow, 40.00) )
							SellAtMarket(bar + 1, p, "Trend sell");
					}
				}
				else
				{
					if( ( rsiSlow[bar] < 40 ) && CrossOver(bar, rsiFast, 60.00) &&
					(Close[bar] > maFast[bar]) )
						if( BuyAtMarket(bar + 1, "correction") != null )
							LastPosition.Priority = -Close[bar];

					if (CrossOver(bar, rsiSlow, 60.00) && 
					(Close[bar] > maSlow[bar]) )
						if( BuyAtMarket(bar + 1, "trend") != null )
							LastPosition.Priority = -Close[bar];

				}
			}
		}
	}
}

—Eugene
www.wealth-lab.com

BACK TO LIST


AMIBROKER: COMBINING RSI WITH RSI

In “Combining Rsi With Rsi” in this issue, author Peter Konner presents a simple trading system that combines five and 17-bar Rsi. We have prepared a ready-to-use formula for the article (available below). The code includes both indicator code as well as the trading strategy presented in the article. It also includes the Kst() function that implements the Kst indicator mentioned in the article.

The formula can be used in Automatic Analysis window (for backtesting) and for a chart. To use it, enter the formula in the Afl Editor, then press the “Insert Indicator” button to see the chart, or press “Backtest” to perform a historical test of the strategy.

LISTING 1

function KST() 
{ 
   p1 = MA( ROC(Close,10), 10); 
   p2 = MA( ROC( Close, 15), 10 ); 
   p3 = MA( ROC( Close, 20), 10 ) ; 
   p4 = MA( ROC( Close, 30), 15); 

  return p1 + 2 * p2 + 3 * p3 + 4 * p4; 
} 

Buy = Cross( RSI( 17 ), 60 ) AND C > MA( C, 40 ); 
Sell = Cross( 40, RSI( 17 ) ) OR C < MA( C, 40 ); 

InDownTrend = Flip( Sell, Buy ); 

CBuy = Cross( RSI( 5 ), 60 ) AND C > MA( C, 10 ) AND InDownTrend; 
CSell = ( Cross( 40, RSI( 5 ) ) OR C < MA( C, 10 ) ) AND InDownTrend; 

Buy = Buy OR CBuy; 
Sell = Sell OR CSell; 

//Plot( KST(), "KST", colorGreen ); 
Plot( RSI( 5 ), "RSI5", colorRed ); 
Plot( RSI( 17 ), "RSI17", colorBlue );

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

BACK TO LIST


WORDEN BROTHERS STOCKFINDER: COMBINING RSI WITH RSI

In his article “Combining Rsi With Rsi” in this issue, Peter Konner discusses a strategy using “slow” and “fast” Rsi plots to trade in both uptrends and downtrends.

You can download the chart “Combining Rsi with Rsi” from the StockFinder share library by clicking Share→Browse, and searching the Charts tab.

The chart has four conditions built from the 10- and 40-week moving averages and the five- and 17-week Rsi plots: buy in uptrend, sell in downtrend, buy in downtrend correction, and sell in downtrend correction.

The conditions on the chart can be used to display markers on the chart, light up symbols passing in the watchlist, filter a watchlist, and also to use in the BackScanner for strategy testing. (See Figure 5.)

Figure 5: STOCKFINDER, COMBINING RSI WITH RSI. The markers on the chart show the “buy in uptrend” (cyan) and “sell in downtrend” (red) signals generated by the conditions. Harman International (HAR) is currently showing a “buy in uptrend” symbol along with eight more stocks in the S&P 500 list on the left.

To use the layouts, indicators, conditions, and charts discussed here, you will need the StockFinder software. Go to www.StockFinder.com to download the software and get a free trial.

— Bruce Loebrich and Patrick Argo
Worden Brothers, Inc.
www.StockFinder.com

BACK TO LIST


NEUROSHELL TRADER: COMBINING RSI WITH RSI

The combined Rsi trading signals described by Peter Konner in his January 2011 S&C article can be easily implemented with a few of NeuroShell Trader’s 800+ indicators using the Indicator Wizard, with the steps shown below. Simply select “New Indicator…” from the Insert menu and use the Indicator Wizard to create the following indicator:

SLOWBUY: 
And2( CrossAbove( RSI(Close, 17), 60 ), A>B( Close, MovAvg(Close,40) ) )

SLOWSELL:
Or2( CrossBelow( RSI(Close, 17), 40 ), A<B( Close, MovAvg(Close,40) ) )

SLOWSIGNAL:
SelectiveMovAvg (SLOWBUY, Or2(SLOWBUY, SLOWSELL), 1 )

QUICKBUY:
And3( CrossAbove( RSI(Close, 5), 60 ), A>B( Close, MovAvg(Close,10) ), A=B( SLOWSIGNAL, 0 ) )

QUICKSELL:
Or2( CrossBelow( RSI(Close, 5), 40 ), A<B( Close, MovAvg(Close,10) ) )

QUICKSIGNAL:
SelectiveMovAvg (QUICKBUY, Or2(QUICKBUY, QUICKSELL), 1 )

To recreate the combined RSI trading system, select “New Trading Strategy…” from the Insert menu and enter the following in the appropriate locations of the Trading Strategy Wizard:

Generate a buy long market order if ONE of the following is true:

A=B(SLOWSIGNAL,1)
AND2(A=B(SLOWSIGNAL,0), A=B(QUICKSIGNAL,1) )

Generate a sell short market order if ALL of the following are true:

AND2(A=B(SLOWSIGNAL,0), A=B(QUICKSIGNAL,0) )

If you have NeuroShell Trader Professional, you can also choose whether the parameters should be optimized. After backtesting the trading strategy, use the “Detailed Analysis…” button to view the backtest and trade-by-trade statistics for the strategy.

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 past Traders’ Tips.

A sample chart is shown in Figure 6.

Figure 6: NEUROSHELL TRADER, COMBINING RSI WITH RSI. Here is a sample NeuroShell Trader chart that shows the combined RSI trading system.

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

BACK TO LIST


AIQ: COMBINING RSI WITH RSI

The Aiq code for Peter Konner’s article in this issue, “Combining Rsi With Rsi,” is shown below. I tested the author’s system on the Russell 1000 list of stocks from 1/3/2000 to 11/11/2010. The table in Figure 7 shows the results of a backtest on all trades. This summary report table shows the average trade is 17.63% with a 231-bar average holding period.

Figure 7: AIQ SYSTEMS, RSI WITH RSI BACKTEST RESULTS. Here is a summary report of results for Peter Konner’s system as applied to the Russell 1000 list of stocks over the period 1/03/2000 to 11/11/2010.

Since it is nearly impossible to take positions in all of the Russell 1000 stocks, I also ran a trading simulation using the Aiq Portfolio Manager using the same list of stocks and same test period. I took a maximum of 10 positions at a time and compounded profits monthly. When there were more signals than available positions, I used the quick Rsi in descending order to choose which signals to take so as to limit the maximum concurrent positions to 10.

Figure 8 shows the resulting equity curve versus the S&P 500. The system beat buy & hold but took a rather large drawdown in the recent bear market of 2008–09. I based my system on the author’s description of the system given in the text explanation rather than the system code. In the exits, the text description uses “and,” whereas the coded version uses “or.”

Figure 8: AIQ SYSTEMS, AIQ Portfolio Manager. Here is a sample equity curve for Peter Konner’s system as applied to the Russell 1000 list of stocks over the period 1/03/2000 to 11/11/2010.

The code and Eds file can be downloaded from www.TradersEdgeSystems.com/traderstips.htm and is also shown below..


!! COMBINING RSI WITH RSI
! Author: Peter Konner
! Coded by: Richard Denning 11/10/10
! www.tradersEdgeSystems.com

!!!!!************ CHANGE PROPERTIES TO WEEKLY*******************!!!!

!! RSI WILDER
!To convert Wilder Averaging to Exponential Averaging use this formula:
!ExponentialPeriods = 2 * WilderPeriod - 1.

C 	is [close].
C1 	is valresult(C,1).
OSD	is offSetToDate(month(),day(),year()).

U 	is C - C1.
D 	is C1 - C.
W1	is 5.
rsiLen1	is 2 * W1 - 1.
AvgU 	is ExpAvg(iff(U>0,U,0),rsiLen1).
AvgD 	is ExpAvg(iff(D>=0,D,0),rsiLen1).
rsiQwk	is 100-(100/(1+(AvgU/AvgD))).

W2	is 17.
rsiLen2	is 2 * W2 - 1.
AvgU2 	is ExpAvg(iff(U>0,U,0),rsiLen2).
AvgD2 	is ExpAvg(iff(D>=0,D,0),rsiLen2).
rsiSlow	is 100-(100/(1+(AvgU2/AvgD2))).

smaST 	is simpleavg(C,10).
smaLT 	is simpleavg(C,40).

BarsSinceUp is scanany(rsiSlow > 60,200) then OSD.
BarsSinceDn is scanany(rsiSlow < 40,200) then OSD.
UpTrendLT if ^BarsSinceUp < ^BarsSinceDn.
BarsSinceUpQ is scanany(rsiQwk > 60,200) then OSD.
BarsSinceDnQ is scanany(rsiQwk < 40,200) then OSD.
UpTrendQ if ^BarsSinceUpQ < ^BarsSinceDnQ.

Buy	if (UpTrendLT and C > smaLT)
	or (not UpTrendLT and UpTrendQ and C > smaST).

ExitBuy if not UpTrendLT and C < smaLT
	and not UpTrendQ and C < smaST.


—Richard Denning
info@TradersEdgeSystems.com
for AIQ Systems

BACK TO LIST


TRADERSSTUDIO: COMBINING RSI WITH RSI

The TradersStudio code for Peter Konner’s article, “Combining Rsi With Rsi,” is shown below. I tested the author’s system on 76 volatile and highly liquid Nasdaq stocks from 1/2/2001 to 11/10/2010 trading equal dollar-sized positions at $10,000 each. To take all positions, starting capital is assumed to be $760,000.

In Figure 9, I show the resulting equity curve and in Figure 10, I show the resulting underwater equity curve. Maximum drawdown was approximately 34% in 2009 with an average annual return of approximately 19.4% on the initial capital.

FIGURE 9: TRADERSSTUDIO, RSI WITH RSI SYSTEM RESULTS. Here is the consolidated equity curve for the period 1/2/2001 to 11/10/2010. The average annual return was approximately 19.4% on the initial capital.

FIGURE 10: TRADERSSTUDIO, SYSTEM DRAWDOWN. Here is the consolidated underwater equity curve for the period 1/2/2001 to 11/10/2010. Maximum drawdown was approximately 34% in 2009.


' COMBINING RSI WITH RSI
' Author: Peter Konner
' Coded by: Richard Denning 11/10/10
' www.tradersEdgeSystems.com

' TO BE RUN ON WEEKLY DATA

Sub RSI_RSI_V(rsiQuickLen,rsiSlowLen,smaSTlen,smaLTlen)
Dim rsiQuick As BarArray
Dim rsiSlow As BarArray
Dim smaST As BarArray
Dim smaLT As BarArray
Dim b1 As BarArray
Dim b2 As BarArray
Dim bb1 As BarArray
Dim bb2 As BarArray
Dim b3 As BarArray
Dim b4 As BarArray
Dim b5 As BarArray
Dim b6 As BarArray
Dim theSize As BarArray

rsiQuick = rsi(C,rsiQuickLen,0)
rsiSlow = rsi(C,rsiSlowLen,0)
smaST = Average(C,smaSTlen)
smaLT = Average(C,smaLTlen)

b1 = (CrossesOver(rsiSlow,60) And C > smaLT)
b2 = (CrossesUnder(rsiSlow,40) Or C < smaLT)
If BarNumber = FirstBar Then
    b3 = False
    b4 = False
    b5 = False
    b6 = False
End If

If b1 = False And b2 = True Then
    b3 = False
    b4 = True
Else If b1 = True And b2 = False Then
    b3 = True
    b4 = False
End If
End If
bb1 = CrossesOver(rsiQuick,60) And C > smaST
bb2 = CrossesUnder(rsiQuick,40) Or C < smaST
If bb1 = False And bb2 = True Then
    b5 = False
    b6 = True
Else If bb1 = True And bb2 = False Then
    b5 = True
    b6 = False
End If
End If
If (b3 And b5) Or (b3 And b6) Or (b4 And b5) Then
    theSize = 10000 / C / 200
    Buy("LE",theSize,0,Market,Day)
End If
If (b4 And b6) Then
    ExitLongAllPos("LX","",0,Market,Day)
End If
       
End Sub

The code can be downloaded from the TradersStudio website at www.TradersStudio.com→Traders Resources→FreeCode or www.TradersEdgeSystems.com/traderstips.htm.

—Richard Denning
info@TradersEdgeSystems.com
for TradersStudio

BACK TO LIST


TRADECISION: COMBINING RSI WITH RSI

The article by Peter Konner in this issue, “Combining Rsi With Rsi,” describes how to combine two Rsi indicators to trade long-term uptrends and short-term corrections, all in one strategy.

You can recreate the Rsi with Rsi strategy in Tradecision’s Strategy Builder using the following code:

Long Rule:
return RSI(C,17) >= 60 and C > SMA(C,40)
or RSI(C,5) >= 60 and C > SMA(C,10) and RSI(C,17) < 60;

Short Rule:
return RSI(C,17) <= 40 and C < SMA(C,40)
or RSI(C,5) <= 40 and C > SMA(C,10);

To import the strategy into Tradecision, visit the area “Traders’ Tips from TASC Magazine” at www.tradecision.com/support/tasc_tips/tasc_traders_tips.htm or copy the code above.

A sample chart is shown in Figure 11.

FIGURE 11: TRADECISION, MSFT WEEKLY CHART WITH RSI TECHNIQUE. Here is an example of the two RSI indicators and two moving averages plotted on a MSFT chart with buy and sell signals generated by Peter Konner’s RSI-with-RSI trading strategy.

—Yana Timofeeva, Alyuda Research
510 931-7808, sales@tradecision.com
www.tradecision.com

BACK TO LIST


NINJATRADER: COMBINING RSI WITH RSI

We created an automated strategy named “RsiWithRsi” based on Peter Konner’s January 2011 S&C article, “Combining Rsi With Rsi.” The strategy is available for download at www.ninjatrader.com/SC/January2011SC.zip.

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

You can review the strategy source code by selecting the menu Tools→Edit NinjaScript→Strategy from within the NinjaTrader Control Center window and selecting “RsiWithRsi.”

NinjaScript uses compiled Dlls that run native, not interpreted, for the highest performance possible.

A sample chart implementing the strategy is in Figure 12.

Figure 12: NINJATRADER, RSI WITH RSI. This sample screenshot shows the RsiWithRsi applied to a weekly chart of Cisco (CSCO).

—Raymond Deux & Ryan Millard
NinjaTrader, LLC
www.ninjatrader.com

BACK TO LIST


NEOTICKER: COMBINING RSI WITH RSI

Based on the trading signals presented in “Combining Rsi With Rsi” by Peter Konner in this issue, I have developed two formula language–based backtesting systems. The first one is to generate a buy signal based on a slow weekly Rsi and a moving average uptrend; the second one is for when a slow weekly Rsi is in a downtrend, with a signal generated by a fast Rsi and a fast moving average.

The first system is named Tasc Rsi long-term uptrend system (see Listing 1 below). It has four parameters: MA period, Rsi period, uptrend Rsi level, and downtrend Rsi level. A filter is added within the code so that it only takes the signal after a simple moving average is returning valid values.

LISTING 1
compressseries( wb, data1, ppWeekly, 1);
makeindicator ( wma, average, wb, param1);
makeindicator ( wrsi, rsindex, wb, param2);
$minbar := param1*5;
LongAtMarket ((openpositionflat >>0) and (barsnum > $minbar) and
              (xaboveconst(wrsi, param3)>0) and (data1>wma),
              defaultordersize,
              "long term uptrend buy");
LongExitatmarket ((openpositionlong > 0) and
                  (xbelowconst(wrsi, param4)>0) and (data1<wma),
                   defaultordersize,
                   "long term uptrend sell");
plot1 := currentequity;

The second system is named Tasc Rsi long-term downtrend system (see Listing 2 below). It has five parameters: slow Rsi period, fast MA period, fast Rsi period, Rsi buy level, and Rsi sell level. This code only trades when the slow Rsi is in a downtrend. The signal is generated from a fast Rsi and fast moving average.

LISTING 2 
compressseries( wb, data1, ppWeekly, 1);
makeindicator ( wsrsi, rsindex, wb, param1);
makeindicator ( wfma, average, wb, param2);
makeindicator ( wfrsi, rsindex, wb, param3);
$ltdowntrend := choose(xaboveconst(wsrsi, param4) > 0, 0,
                       xbelowconst(wsrsi, param5) > 0, 1, $ltdowntrend);
LongAtMarket ((openpositionflat > 0) and ($ltdowntrend > 0) and (barsnum > 200) and
              (xabove(wfrsi, param4) > 0) and (data1 > wfma),
              defaultordersize,
              "long term downtrend short term buy");
LongExitatmarket ((openpositionlong > 0) and
                  (xbelow(wfrsi, param5) > 0) and (data1 < wfma),
                  defaultordersize,
                  "long term downtrend short term sell");
plot1 := currentequity;

A downloadable version of these trading systems will be available at the NeoTicker blog site (https://blog.neoticker.com). A sample chart implementing the strategy is shown in Figure 13.

Figure 13: NEOTICKER, COMBINING RSI WITH RSI, two trading systems. System 1 is the long-term uptrend system and system 2 is the long-term downtrend system.

—Kenneth Yuen, TickQuest, Inc.
www.neoticker.com

BACK TO LIST


WAVE59: COMBINING RSI WITH RSI

In Peter Konner’s article “Combining Rsi With Rsi” in the January 2011 issue of S&C, he describes a system of combining Rsi with Rsi to catch trends and minimize risk.

Figure 14 shows the indicator on the Dow Jones Industrial Average. We constructed the indicator as Konner describes, but we used daily calculations extrapolated to the weekly recommendations of the article. Thus, his 40-week moving average became a 200-day moving average, and so on (assuming five trading days per week, although holidays may bring about slight discrepancies). This not only gave much more freedom over the parameters, it would theoretically give (the same) signals sooner. Konner writes of trading only on the weekend, but some traders may be able to check a system’s signals nightly for 15 minutes.

The Wave59 script to implement this indicator in Wave59 is shown below. Users of Wave59 can also download the script directly using the QScript Library found at https://www.wave59.com/library.


Indicator:  SC_Konner
input: slow_len(85), quick_len(25), smaslow(200),smaquick(50);   

Rsislow = rsi(close,slow_len);
Rsiquick = rsi(close,quick_len);
sma1= average(c,smaslow);
sma2= average(c,smaquick);


if (Rsislow > 60 and c > sma1 and marketposition<=0)
{
buy(1,c,"market","gtc"); 
}  
if (Rsislow < 40 and c < sma1 and marketposition>=0)
{
sell(1,c,"market","gtc");
}  

if (Rsiquick > 60 and c > sma2 and rsislow < 40 and marketposition<=0)
{
buy(1,c,"market","gtc"); 
}   

if (Rsiquick < 40 and c < sma2 and marketposition>=0)
{
sell(1,c,"market","gtc");
} 

plot1=rsislow;
plot2=rsiquick;
color2=blue;   
plot3=40;
plot4=60;
#plot3=sma1;
color3=green;  
#plot4=sma2;  
color4=purple;    
--------------------------------------------


FIGURE 14: WAVE59, COMBINING RSI WITH RSI. This screen capture shows Peter Konner’s indicator on the Dow Jones Industrial Average. Our version of indicator is based on daily calculations rather than weekly.

—Patrick J. Stiles
Wave59 Technologies Int’l, Inc.
www.wave59.com

BACK TO LIST


UPDATA: COMBINING RSI WITH RSI

Our Traders’ Tip for this month is based on the article by Peter Konner, “Combining Rsi With Rsi.”

Konner creates a system that is simple by design using a medium-term Rsi and moving average to determine long-term trend, and a shorter-term Rsi and moving average to time entry into the market. Our code for this strategy (shown below) follows the listed rules.


PARAMETER "Long Term RSI Period" #LTRSIPERIOD=17 
PARAMETER "Short Term RSI Period" #STRSIPERIOD=5 
PARAMETER "Long Term Mov. Avg. Period" #LTMAPERIOD=40   
PARAMETER "Short Term Mov. Avg. Period" #STMAPERIOD=10 
PARAMETER "Upper Thresh. RSI" #UPPER=60 
PARAMETER "Lower Thresh. RSI" #LOWER=40  
NAME "Mov. Avg. Periods" #LTMAPERIOD "&" #STMAPERIOD 
NAME3 "Long Term RSI Period" #LTRSIPERIOD 
NAME4 "Short Term RSI Period" #STRSIPERIOD    
DISPLAYSTYLE 4LINES 
INDICATORTYPE TOOL 
INDICATORTYPE3 CHART 
INDICATORTYPE4 CHART 
PLOTSTYLE LINE RGB(255,0,0)  
PLOTSTYLE2 LINE RGB(0,255,0) 
PLOTSTYLE3 LINE RGB(0,0,255) 
PLOTSTYLE4 LINE RGB(0,0,255) 
@LONGTERMRSI=0 
@SHORTTERMRSI=0  
@LTMOVAVG=0 
@STMOVAVG=0  
@LONGMODE=0 
@SHORTMODE=0 
  
FOR #CURDATE=0 TO #LASTDATE    
    
   If #CURDATE>(#LTRSIPERIOD+#LTMAPERIOD) 
  
   @LONGTERMRSI=RSI(#LTRSIPERIOD) 
   @SHORTTERMRSI=RSI(#STRSIPERIOD) 
   'Long Term (LT) Mov. Avg.  
   @LTMOVAVG=MAVE(#LTMAPERIOD)  
   'Short Term (ST) Mov. Avg. 
   @STMOVAVG=MAVE(#STMAPERIOD) 
    
   'Switches Trade Regime Between Long Only To Short Only 
   If CLOSE<@LTMOVAVG AND @LONGTERMRSI<#LOWER   
      @SHORTMODE=TRUE  
      @LONGMODE=FALSE       
   ElseIf CLOSE>@LTMOVAVG AND @LONGTERMRSI>#UPPER  
      @LONGMODE=TRUE 
      @SHORTMODE=FALSE 
   EndIf 
    
   'Exits 
   If ORDERISOPEN=1 
      If CLOSE<@STMOVAVG OR @SHORTTERMRSI<#LOWER 
         SELL CLOSE 
      EndIf 
   ElseIf ORDERISOPEN=-1 
      If CLOSE>@STMOVAVG OR @SHORTTERMRSI>#UPPER 
         COVER CLOSE 
      EndIf 
   EndIf 
          
   'Entries                
   If CLOSE<@STMOVAVG AND @SHORTTERMRSI>#UPPER AND @SHORTMODE=TRUE    
      SHORT CLOSE 
   ElseIf CLOSE>@STMOVAVG AND @SHORTTERMRSI<#LOWER AND @LONGMODE=TRUE       BUY CLOSE 
   EndIf       
    
   @PLOT=@LTMOVAVG 
   @PLOT2=@STMOVAVG 
   @PLOT3=@LONGTERMRSI 
   @PLOT4=@SHORTTERMRSI 
       
   EndIf     
    
NEXT 


The new Updata Professional Version 7 accepts code written in VB.Net and C# in addition to our user-friendly custom code. Versions of this indicator and system in all these languages may be downloaded by clicking the Custom menu and then System or Indicator Library. Those who cannot access the library due to firewall issues may paste the following code into the Updata Custom editor and save it.

A sample chart is shown in Figure 15.

FIGURE 15: UPDATA, RSI WITH RSI. The chart shows dual-term RSIs and moving averages on the Danish stock Carlsberg B.

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

BACK TO LIST


TRADE NAVIGATOR: COMBINING RSI WITH RSI

Trade Navigator offers the features you need to be able to recreate the strategy presented in Peter Konner’s article in the January 2011 issue, “Combining Rsi With Rsi.”

To recreate the strategy, highlight bars, and template:

Go to the Strategies tab in the Trader’s Toolbox. Click on the New button. Click the New Rule button. To set up the first long entry rule, type the following code:

Downtrend Quick Cross Long:

IF Crosses Above (RSI (Close , 5 , False) , 60) And MovingAvg (Close , 10) > Close And
 RSI (Close , 17 , False) > 20 And RSI (Close , 17 , False) < 60 And Close < MovingAvg
 (Close , 40)

Set the Action to Long Entry (Buy) and the Order Type to Market.

Click on the Save button. Type a name for the rule and then click the OK button.

figure 16: Tradenavigator setup.

Repeat these steps for the three remaining rules using the following sets of code:

Downtrend Quick Cross Short:

IF Crosses Below (RSI (Close , 5 , False) , 40) And MovingAvg (Close , 10) < Close And
 RSI (Close , 17 , False) > 20 And RSI (Close , 17 , False) < 60 And Close < MovingAvg
 (Close , 40)

Set the Action to Short Entry (Sell) and the Order Type to Market.

Click on the Save button. Type a name for the rule and then click the OK button.

Slow RSI Long Cross:

IF Crosses Above (RSI (Close , 17 , False) , 60) And Close > MovingAvg (Close , 40)

Set the Action to Long Entry (Buy) and the Order Type to Market.

Click on the Save button. Type a name for the rule and then click the OK button.

Slow RSI Short Cross:

IF Crosses Below (RSI (Close , 17 , False) , 40)

Set the Action to Short Entry (Sell) and the Order Type to Market.

Click on the Save button. Type a name for the rule and then click the OK button.

Save the strategy by clicking the Save button, typing a name for the strategy and then clicking the OK button.

You can test your new strategy by clicking the Run button to see a report or you can apply the strategy to a chart for a visual representation of where the strategy would place trades over the history of the chart.

You can create the custom Highlight Bars used in the “Combining RSI With RSI” article by using the following TradeSense code.

First, open the Trader’s Toolbox, click on the Functions tab and click the New button.

Trending Down:

RSI (Close , 17 , False) > 20 And RSI (Close , 17 , False) < 60 And Close < MovingAvg (Close , 40)

Figure 17: Creating a Function

Click the Verify button.

When you are finished, click on the Save button, type a name for your new function and click OK.

Repeat these steps for the Trending Up function using the following formula:

RSI (Close , 17 , False) > 40 And RSI (Close , 17 , False) < 80 And Close > MovingAvg (Close , 40)

Creating the chart
On a weekly chart, go to the Add To Chart window by clicking on the chart and typing “A” on the keyboard.

Click on the HighlightBars, find the Trending Down and Trending Up Highlight Bars in the list, and either doubleclick on it or highlight the name and click the Add button.

Repeat these steps to add 2 MovingAvg and 2 RSI indicators. Once you have the indicators added to the chart, click on the label for MovingAvg and drag it into the price pane Repeat this for the other MovingAvg.

Highlight each indicator and change it to the desired color and values in the chart settings window.

When you have them the way you want to see them, click on the OK button.

You can save your new chart as a Template to use for other charts. Once you have the chart set up, go to the Charts dropdown menu, select Templates and then Manage chart templates. Click on the New button, type in a name for your new template and click OK.

Genesis Financial Technologies has already provided the strategy, highlight bars, and template discussed here as a special downloadable file for Trade Navigator. Click on the blue phone icon in Trade Navigator, select Download Special File, type SC1101 and click on the Start button. The library name will be “Combining the Rsi with Rsi,” the highlight bar names will be Trending Down and Trending Down. The strategy name will be “Rsi with Rsi” and the template name will be “Rsi with Rsi.”

—Michael Herman
Genesis Financial Technologies
www.TradeNavigator.com

BACK TO LIST


CHARTSY: COMBINING RSI WITH RSI
For Windows + Mac + Linux

The two-Rsi calculation described in Peter Konner’s article in this issue is available in Chartsy using the two-Rsi overlay plugin. To install this plugin, please go to Tools→Plugins→Available Plugins. The plugin is preinstalled in Chartsy version 1.4.

The overlay generates buy and sell signals based on Peter Konner’s two-Rsi strategy and displays them as green or red dots on the chart (Figure 18).

You can find the Java source code for the two-Rsi calculation here:
https://chartsy.svn.sourceforge.net/viewvc/chartsy/trunk/Chartsy/Two%20RSI/src/org/chartsy/ tworsi/TwoRSI.java?revision=363&view=markup

To download Chartsy, discuss these tools, and help us develop other tools, please visit our forum at www.chartsy.org. Our development staff will be happy to assist and you can become a Chartsy contributor yourself.

FIGURE 18: CHARTSY, TWO-RSI as overlay. Green and red dots indicate buy/sell signals. RSIs are used to calculate the indicators and the moving averages are used as overlays.

—Larry Swing
theboss@mrswing.com
281 968-2718, www.mrswing.com

BACK TO LIST


TRADESIGNAL: COMBINING RSI WITH RSI

In our implementation of Peter Konner’s strategy described in his article, “Combining Rsi With Rsi,” we include a percent-stop system and a simple position size system into the strategy (capital + closed equity / close price = position size).

This strategy can be easily implemented in the free Interactive Online Charting Tool found on www.TradesignalOnline.com (Figure 19). In the tool, select “New Strategy,” enter the code in the online code editor and save it. The strategy can now be added to any chart with a simple drag & drop.

Figure 19: TRADESIGNAL, RSI WITH RSI. Here is a Tradesignal Online implementation of Peter Konner’s RSI with RSI strategy on a chart of Apple Inc.

The strategy is also available in the Lexicon section of www.TradesignalOnline.com, where they can be imported with a single click.


Meta:
       Synopsis("RSI with RSI Strategy. Developed by Peter Konnor, published in
        Trades Tips - Stocks&Commodities 01/2011"),
       Weblink
       ("https://www.tradesignalonline.com/lexicon/view.aspx?id=RSI%20With%20RSI%20Strategy"),
       Subchart( True );
 
Inputs:     
       RSI_Fast_Period( 5 , 1 ),
       RSI_Fast_Upper( 61 , 1 ),
       RSI_Fast_Lower( 39 , 1 ),
       RSI_Slow_Period( 17 , 1 ),
       RSI_Slow_Upper( 61 , 1 ),
       RSI_Slow_Lower( 39 , 1 ),
       MA_Fast_Period( 10 , 1 ),
       MA_Slow_Period( 40 , 1 ),
       Percent_Invest( 10.0 ),
       Percent_Stop_Uptrend( 3.0 ),
       Percent_Stop_Downtrend( 1.5 );
      
Vars:
       rsiFast, rsiSlow, maFast, maSlow, longSigFast, shortSigFast,
       longSigSlow, shortSigSlow, longCondFast, shortCondFast, longCondSlow, shortCondSlow,
       stopLevelFast, stopLevelSlow, numPositions, newPosition, numberShares, freeCapital,
       percentCapital;
 
rsiFast = RSI( Close, RSI_Fast_Period );
rsiSlow = RSI( Close, RSI_Slow_Period );
maFast = Average( Close, MA_Fast_Period );
maSlow = Average( Close, MA_Slow_Period );
 
 
longSigFast = ( rsiFast Crosses Over RSI_Fast_Upper );
shortSigFast = ( rsiFast Crosses Under RSI_Fast_Lower );
longCondFast = Close > maFast;
shortCondFast = Close < maFast;
 
longSigSlow = ( rsiSlow Crosses Over RSI_Slow_Upper );
shortSigSlow = ( rsiSlow Crosses Under RSI_Slow_Lower );
longCondSlow = Close > maSlow;
shortCondSlow = Close < maSlow;
 
If longSigFast And longCondFast Then
       Begin
             stopLevelFast = Close - ( 0.01 * Close * Percent_Stop_Downtrend );
             Sell("Stop") From Entry("Fast") Next Bar at stopLevelFast Stop;
             freeCapital = ( InitialCapital + ClosedEquity );
             percentCapital = 0.01 * freeCapital * Percent_Invest;
             numberShares =  Floor( percentCapital / Close );
            
             Buy("Fast") numberShares Shares This Bar on Close;
       End;
 
If shortSigFast And shortCondFast Then
       Sell("xFast") From Entry("Fast") This Bar on Close;
 
If longSigSlow And longCondSlow Then
       Begin
             stopLevelSlow = Close - ( 0.01 * Close * Percent_Stop_Uptrend );
             Sell("Stop") From Entry("Slow") Next Bar at stopLevelSlow Stop;
             freeCapital = ( InitialCapital + ClosedEquity );
             percentCapital = 0.01 * freeCapital * Percent_Invest;
             numberShares =  Floor( percentCapital / Close );
            
             Buy("Slow") numberShares Shares This Bar on Close;
       End;
 
If shortSigSlow And shortCondSlow Then
       Sell("xSlow") From Entry ("Slow") This Bar on Close;
 
numPositions = TotalPositions;
newPosition = numPositions > numPositions;
 
If MarketPosition = 1 Then
       Begin
             If newPosition Then
                    Begin
                           stopLevelFast = Entryprice - ( 0.01 * Close * Percent_Stop_Downtrend );
                           stopLevelSlow = EntryPrice - ( 0.01 * Close * Percent_Stop_Uptrend );
                    End;
            
             If EntryLabel = "Fast" Then
                    Sell("Stop") Next Bar at stopLevelfast Stop
             Else If EntryLabel = "Slow" Then
                    Sell("Stop") Next Bar at stopLevelSlow Stop;  
       End;
 
global::maFast = maFast;
global::maSlow = maSlow;
 
DrawLine( rsiFast, "RSI Fast", StyleSolid, 2, Blue );
DrawLine( rsiSlow, "RSI Slow", StyleSolid, 2, Black );
 
DrawLine( RSI_Fast_Lower, "Fast Lower", StyleDash, 1, Black );
DrawLine( RSI_Fast_Upper, "Fast Upper", StyleDash, 1, Black );
 
DrawLine( RSI_Slow_Lower, "Slow Lower", StyleDash, 1, Black );
DrawLine( RSI_Slow_Upper, "Slow Upper", StyleDash, 1, Black );
 

—Sebastian Schenck, Tradesignal GmbH
support@tradesignalonline.com
www.TradesignalOnline.com, www.Tradesignal.com

BACK TO LIST

MICROSOFT EXCEL: COMBINING RSI WITH RSI

This tip is based on Peter Konner’s article in this issue, “Combining Rsi With Rsi,” which describes the thinking and steps in his progression from general idea to a possible trading system.

The Excel workbook with the filename “Combining Rsi With Rsi.xls” (updated 2/14/2011) performs all of the necessary calculations in spreadsheet formulas and uses a couple of simple charting steps to get the price (as candlesticks) and moving average indicators onto the same chart along with the buy and sell point markers.

A sample chart is shown in Figure 20.

FIGURE 20: microsoft excel, RSI combo chart

—Ron McAllister
rpmac_xltt@Sprynet.com

BACK TO LIST


RSI WITH RSI — KONNER ARTICLE CODE

For my purposes, I have developed the model for AvanzaVikingen, a technical analysis program used by many traders in Scandinavia. The model, which I have named Riviera, can be downloaded from my website at https://www.pointfigure.dk. You will find the source code below. In the code, I have modified the exit by using an “OR” statement. This is merely because it gives a quicker exit. You can use either “And” or “OR” conditions for the exit.

RIVIERA MODEL CODE FOR AVANZAVIKINGEN
par(Main             : instrument; 
    LenRSIs, LenRSIq : Integer;
    LenMAs, LenMAq   : Integer;
    BuyRSIs, SellRSIs, BuyRSIq, SellRSIq : Integer;
    out sRSI, qRSI   : RealVector;
    out BuyRSIsLin, SellRSIsLin, BuyRSIqLin, SellRSIqLin : RealVector;
    out MAsPrice, MAqPrice : RealVector;
    out Buy, Sell    : BooleanVector);
var b01, b02, b03, b04, b05, b06 : BooleanVector;
    i     : Integer;
    Price : RealVector;
begin
    // Initialize buy- and sell-levels for both RSI’s
    BuyRSIsLin := BuyRSIs;
    SellRSIsLin := SellRSIs;
    BuyRSIqLin := BuyRSIq;
    SellRSIqLin := SellRSIq;
    // Prepare price and MA’s
    Price := FILL(Main.Close);
    MAsPrice := MAVN(Price, LenMAs);
    MAqPrice := MAVN(Price, LenMAq);
    // Calculate SlowRSI and QuickRSI
    sRSI := RSI(Price, LenRSIs);
    qRSI := RSI(Price, LenRSIq);
    // Calculate buy- and sell points for SlowRSI
    b01 := (SHIFT(sRSI, 1) <= BuyRSIs) AND (sRSI > BuyRSIs) AND (Price > MAsPrice);
    b02 := ((SHIFT(sRSI, 1) >= SellRSIs) AND (sRSI < SellRSIs)) OR (Price < MAsPrice);
    // Expand the buy/sell points (opposite to FILTERBUY/-SELL in Vikingen...)
    b03 := FALSE;   b04 := FALSE;
    for i := 1 to LEN(b01) - 1 do
      if (b01[i] = FALSE) AND (b02[i] = TRUE) then
        b03[i] := FALSE;   b04[i] := TRUE;
      else
        if (b01[i] = TRUE) AND (b02[i] = FALSE) then
          b03[i] := TRUE;   b04[i] := FALSE;
        else  // ...will always be FALSE-FALSE, never TRUE-TRUE!
          b03[i] := b03[i-1];   b04[i] := b04[i-1];
        end;
      end;
    end;
    // Calculate buy and sell for QuickRSI when SlowRSI is in downtrend, ie b04 = TRUE...
    b01 := (SHIFT(qRSI, 1) <= BuyRSIq) AND (qRSI > BuyRSIq) AND (Price > MAqPrice) AND (b04 = TRUE);
    b02 := ((SHIFT(qRSI, 1) >= SellRSIq) AND (qRSI < SellRSIq)) OR (Price < MAqPrice);
    // Expand the buy/sell points (opposite to FILTERBUY/-SELL in Vikingen...)
    b05 := FALSE;   b06 := FALSE;
    for i := 1 to LEN(b01) - 1 do
      if (b01[i] = FALSE) AND (b02[i] = TRUE) then
        b05[i] := FALSE;   b06[i] := TRUE;
      else
        if (b01[i] = TRUE) AND (b02[i] = FALSE) then
          b05[i] := TRUE;   b06[i] := FALSE;
        else  // ...will always be FALSE-FALSE, never TRUE-TRUE!
          b05[i] := b05[i-1];   b06[i] := b06[i-1];
        end;
      end;
    end;
    // b03, b04, b05 and b06 now contains the relevant signals for buy and sell
    // Determine the buysignals
    b01 := (b03 AND b05) OR (b03 AND b06) OR (b04 AND b05); 
    // Determine the sell signals
    b02 := (b04 AND b06);
    Buy := FILTERBUY(b01, b02);
    Sell := FILTERSELL(b01, b02);
end;

—Peter Konner
peter.konner@gmail.com

BACK TO LIST

Return to Contents