April TRADERS' TIPS

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 issue.

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:

TRADESTATION / SUPERCHARTS
TECHNIFILTER PLUS
SMARTRADER
WAVEWI$E MARKET SPREADSHEET
WINDOW ON WALLSTREET

or return to April 1998 Contents

TRADESTATION / SUPERCHARTS

The r-squared calculation that Jack Karczewski focuses on in "Identifying market trends" is very useful in identifying trending and nontrending periods in the markets. This month, I'll present a revised version of the r-squared indicator given in Jon Andersen's September 1996 STOCKS & COMMODITIES article, "Standard error bands." I'll also include two PaintBar studies that identify trending and nontrending periods by painting the price bars. All three studies reference a function named "coeffR" for their basic calculation.

The "coeffR" function must be created and verified in the Power Editor prior to creating the studies. The EasyLanguage code for the function follows:

Type: Function

Name: coeffR

Inputs: Length(Numeric);

Vars: X(0), UpEQ(0), LowEQ1(0), LowEQ2(0), LowEQT(0);

X = BarNumber;

UpEQ = Summation(X * Close, Length) - (Length * Average(X, Length) * Average(Close, Length));

LowEQ1 = Summation(Square(X), Length) - (Length * Square(Average(X, Length)));

LowEQ2 = Summation(Square(Close), Length) - (Length * Square(Average(Close, Length)));

IF LowEQ1 * LowEQ2 > 0 Then

LowEQT = SquareRoot(LowEQ1 * LowEQ2);

IF LowEQT <> 0 Then

CoeffR = UpEQ / LowEQT;

The next step is to develop the r-squared indicator. The r-squared indicator plots the r-squared line as well as a zone for the trending and nontrending levels. In addition, a dot will be displayed on the r-squared line when it has been above/below a trending/nontrending level for a specified number of bars. The Length input determines the length of the r-squared calculation. The Smooth input allows for the r-squared line to be smoothed with a moving average. The Trend input determines the level above which the market is considered trending. The NoTrend input determines the level below which the market is considered nontrending. The RunLen input determines how many consecutive bars must be above/below the trending/nontrending levels in order for a mark to be placed on the r-squared line and an alert to be triggered. The suggested format settings are displayed after the EasyLanguage code.

Type: Indicator

Name: R-Squared

Inputs: Length(30), Smooth(1), Trend(.7), NoTrend(.3), RunLen(10);

Vars: R(0), SquareR(0), AvgSqrR(0);

R = coeffR(Length);

SquareR = Square(R);

IF Smooth > 0 Then

AvgSqrR = Average(SquareR, Smooth)

Else

AvgSqrR = SquareR;

Plot1(AvgSqrR, ÒAvgSqrRÓ);

Plot2(Trend, ÒTrendÓ);

Plot3(NoTrend, ÒNoTrendÓ);

IF MRO(AvgSqrR > Trend, RunLen, RunLen) <> -1 OR

MRO(AvgSqrR < NoTrend, RunLen, RunLen) <> -1 Then Begin

Plot4(AvgSqrR, ÒRunningÓ);

Alert = True;

End;

Style:
 
Plot Name Type Color Weight
Plot1 AvgSqrR Line Cyan thinnest
Plot2 Trend Line red thinnest
Plot3 NoTrend Line red thinnest
Plot4 Running Point white medium
Scaling:  Screen
Properties: Enable Alert
The PaintBar studies paint the bars that qualify as trending or nontrending. One PaintBar study paints the bars that are indicated to be trending, the other paints the nontrending. I found that all bars could be classified as trending or nontrending by setting the Trend and NoTrend inputs in both PaintBar studies to the same value. Although the default values do not reflect this type of setup, they can easily be modified to reflect such settings, since they are input values. The PaintBar studies can be developed using the EasyLanguage code that follows. The suggested format settings are given after the EasyLanguage.

Type: PaintBar

Name: R-Squared Trend

Inputs: Length(30), Smooth(1), Trend(.7);

Vars: R(0), SquareR(0), AvgSqrR(0);

R = coeffR(Length);

SquareR = Square(R);

IF Smooth > 0 Then

AvgSqrR = Average(SquareR, Smooth)

Else

AvgSqrR = SquareR;

IF AvgSqrR > Trend Then Begin

Plot1(High, ÒPaint_TrendÓ);

Plot2(Low, ÒPaint_TrendÓ);

Alert = True;

End;

Style:

Color: Cyan

Properties:

Enable Alert

Type: PaintBar

Name: R-Squared NoTrend

Inputs: Length(30), Smooth(1), NoTrend(.3);

Vars: R(0), SquareR(0), AvgSqrR(0);

R = coeffR(Length);

SquareR = Square(R);

IF Smooth > 0 Then

AvgSqrR = Average(SquareR, Smooth)

Else

AvgSqrR = SquareR;

IF AvgSqrR < NoTrend Then Begin

Plot1(High, ÒPaintNoTrendÓ);

Plot2(Low, ÒPaintNoTrendÓ);

Alert = True;

End;

Style:

Color: Red

Properties:

Enable Alert

This code is available at Omega Research's Web site. The name of the file is "RSqrd.ELA." Please note that all Traders' Tips analysis techniques posted at Omega Research's Web site can be utilized by both TradeStation and SuperCharts. Whenever possible, the posted analysis techniques will include both Quick Editor and Power Editor formats.

Gaston Sanchez, Omega Research
800 422-8587, 305 270-1095
Internet: https://www.omegaresearch.com
GO BACK

TECHNIFILTER PLUS

In "Identifying market trends," Jack Karczewski uses the statistic r-squared to determine whether an issue is trending. This statistic measures how closely the changes in two time series match. R-squared values close to one indicate the two series are synchronized, while values close to zero indicate the series are out of sync. Karczewski compares an issue's closing price to an upward moving straight-line time series. He suggests that r-squared values above 0.70 indicate the issue is trending up as the price is in sync with the upward line, and that values below 0.30 indicate nontrending behavior.

TechniFilter Plus includes an r-squared calculation in its formula library under the name RSquare. The library formula takes three parameters, the two time series, and the number of data points used in the calculation. For Karczewski's work, the two time series are C and CU13, representing the close and the series index. The time period is 30. The formula is thus:

RSquare(C,CU13,30)
This formula computes the r-squared values that form the basis of Karczewski's work. This formula is charted below a bar chart of SPX in Figure 1. The green bars on the bar chart mark the days where the r-squared values are above 0.70, or trending. The TechniFilter Plus formula for r-squared
(C,CU13,30) > 0.70
can be used to color such bars green.

FIGURE 1: TECHNIFILTER PLUS. TechniFilter Plus's r-squared formula is charted here.

This TechniFilter Plus strategy and the reports, strategies and formulas of earlier Traders' Tips can be downloaded from RTR's Web site.

--Clay Burch, RTR Software
919 510-0608, E-mail: rtrsoft@aol.com
Internet: https://www.rtrsoftware.com

GO BACK


SMARTRADER

Implementing Jack Karczewski's r-squared system is an easy process using SMARTrader. After adding the datafile, only two rows are needed. First, add the correlation function based on CLOSE and DATE for 30 days. Then, add a user row where the resultant correlation is squared, giving r-squared. Plot the r-squared as a line in a separate window or plot it over the price chart as an "overlay" plot.

The SMARTrader specsheet, shown in Figure 2, is also available at Stratagem Software's Web site.

FIGURE 2: SMARTRADER. This SMARTrader SpecSheet implements the r-squared indicator.
--Jim Ritter, Stratagem Software International
504 885-7353, E-mail: Stratagem1@aol.com
Internet: https://members.aol.com/stratagem1

GO BACK


WAVE WI$E MARKET SPREADSHEET

Here is a WAVE WI$E program implementation of Jack Karczewski's "Identifying market trends."

WAVE WI$E Spreadsheet Formulas

A: DATE @TC2000(c:\tc2000\data,

SP-500,STANDARD&POORS500,DB)

B: HIGH

C: LOW

D: CLOSE

E: OPEN

F: VOL

G: Lreg @LREG(CLOSE,30,0) 'linearregression

H: Slope @LREG(CLOSE,30,1) 'linearregressionslope

I: Rsq @LREG(CLOSE,30,2) 'Rsquared

J: count @IF(RSQ>.7,@CUM(1)) 'countconsecutivedaysRsq>.7

K:

==========End Formulas

--Peter Di Girolamo, Jerome Technology
908 369-7503, E-mail: jtiware@aol.com
Internet: https://members.aol.com/jtiware

GO BACK


WINDOW ON WALLSTREET

In "Identifying market trends," Jack Karczewski describes several standard statistical trend indicators and their relationship to spotting trends. Specifically, he describes r-squared, a predicted value (based on a least-squares fit) and the error associated with this prediction. This can be implemented in Window On WallStreet Day Trader and Window On WallStreet Professional Investor.

In Window On WallStreet, begin with any open chart on your screen. Click the Indicator button on the toolbar, click New and enter the following formulas:

Name: R-Squared

Description: Jack Karczewski's R-Squared from Technical Analysis of Stocks and Commodities.

Variables:

Name: pers

Prompt Text: Enter Number of Period for Correlation

Default Value: 10

Formula(s):

pwr(correl(c,RecIndex(),pers,0),2)

Predicted Value based on a least squares fit

Name: Linear Predicted Value

Description: Jack Karczewski's linear predicted value from Technical

Analysis of Stocks and Commodities.

Variables:

Name: pers

Prompt Text: Enter number of periods for trend

Default Value: 10

Formula(s):

ref(c,-1) +ref(slope(c,pers),-1)

Percent Error of the linear predicted value

Name: Percent Error of LPV

Description: Percent error of Jack Karczewski's linear predicted value from

Technical Analysis of Stocks and Commodities.

Variables:

Name: pers

Prompt Text: Enter number of periods for trend

Default Value: 10

Formula(s):

100*(c- ref(c,-1) + ref(slope(c,pers),-1))/( ref(c,-1)

+ref(slope(c,pers),-1) )

--Andrew E. Laska, Window On WallStreet
888 732-5969, 972 783-6792
Internet: https://www.wallstreet.net
GO BACK

Return to April 1998 Contents