SI
SI
discoversearch

We've detected that you're using an ad content blocking browser plug-in or feature. Ads provide a critical source of revenue to the continued operation of Silicon Investor.  We ask that you disable ad blocking while on Silicon Investor in the best interests of our community.  If you are not using an ad blocker but are still receiving this message, make sure your browser's tracking protection is set to the 'standard' level.
Strategies & Market Trends : TA-Quotes Plus

 Public ReplyPrvt ReplyMark as Last ReadFilePrevious 10Next 10PreviousNext  
To: Gary Lyben who wrote (6127)8/24/1998 9:18:00 PM
From: TechTrader42   of 11149
 
It appears to be the stochastics applied to an 8 period rsi array
using a 5 period weighted moving average to smooth the %k.


Gary: Some use a weighted MA in the smoothing, and others an
exponential MA.

Here are three StochRSI scans that give values equal to those in
Metastock -- two with the weighted MA, and the other with the
exponential MA.

//StochRSI(8,5), using weighted MA, by Andy Gabor

output = "srsi85ag.lst";
input ="portfoli.lst";

Daystoload = 250;

float StochRSI,PrevStochRSI;
set rsi=8;

StochRSI:=((rsi(0)-min(0,-7,rsi))/(.000001+max(0,-7,rsi)-min(0,-7,rsi))*(33.3333))+
((rsi(-1)-min(-1,-8,rsi))/(.000001+max(-1,-8,rsi)-min(-1,-8,rsi))*26.6666)+
((rsi(-2)-min(-2,-9,rsi))/(.000001+max(-2,-9,rsi)-min(-2,-9,rsi))*20.0000)+
((rsi(-3)-min(-3,-10,rsi))/(.000001+max(-3,-10,rsi)-min(-3,-10,rsi))*13.3333)+
((rsi(-4)-min(-4,-11,rsi))/(.000001+max(-4,-11,rsi)-min(-4,-11,rsi))*6.6666);

PrevStochRSI:=((rsi(-1)-min(-1,-8,rsi))/(.000001+max(-1,-8,rsi)-min(-1,-8,rsi))*33.3333)+
((rsi(-2)-min(-2,-9,rsi))/(.000001+max(-2,-9,rsi)-min(-2,-9,rsi))*26.6666)+
((rsi(-3)-min(-3,-10,rsi))/(.000001+max(-3,-10,rsi)-min(-3,-10,rsi))*20.0000)+
((rsi(-4)-min(-4,-11,rsi))/(.000001+max(-4,-11,rsi)-min(-4,-11,rsi))*13.3333)+
((rsi(-5)-min(-5,-12,rsi))/(.000001+max(-5,-12,rsi)-min(-5,-12,rsi))*6.6666);

//If StochRSI > 20 and PrevStochRSI <= 20 then
Println Symbol,",", "Close: ", Close(0):6:3,", ", "StochRSI: ", StochRSI:6:2,", ",
"Prev. SRSI: ", PrevStochRSI:6:2,", ", "Avgvol: ", avgvol(0,-54):8:0,", ",
"QRS: ", qrs(0),", ", "Rev. Growth: ", rev1growth;
//endif;

********************************

//StochRSI (Variable with WMA), by Brooke

output="srsivar.lst";
input="portfoli.lst";

daystoload= 250;

integer i, j;
float weight, maperiod1, maperiod2, total, totaldays,
StochRSI,PrvStRSI, PrvPrvSRSI, //These are for first StochRSI
StochRSI2, PrvStRSI2, PrvPrvSRSI2, //These are for second StochRSI
maperiod1a, maperiod2a, weighta, totala, totaldaysa;

//SET MA'S FOR FIRST STOCHRSI
maperiod1:=8; //set MA: e.g., in StochRSI(8,5), set for 8; in StochRSI(10), set for 10
maperiod2:=5;// set MA: e.g., in StochRSI(8,5), set for 5; in StochRSI(10), set for 10

set rsi = maperiod1;

//SET MA'S FOR SECOND STOCHRSI -- Second RSI is automatically set below when you set periods
maperiod1a:=10; //set MA: e.g., in StochRSI(8,5), set for 8; in StochRSI(10), set for 10
maperiod2a:=10;// set MA: e.g., in StochRSI(8,5), set for 5; in StochRSI(10), set for 10

weight:=0;
total:=0;
for i = maperiod2 to 1 step -1 do
total:= total + i;
next i;
totaldays:=total;

StochRSI:=0;
PrvStRSI:=0;
PrvPrvSRSI:=0;
for j = maperiod2 to 1 step -1 do
weight:=((j/totaldays)*100);
StochRSI:=StochRSI+((rsi(j-maperiod2)-min(j-maperiod2,(j-maperiod2)-(maperiod1-1),rsi))/
(.000001+max(j-maperiod2,(j-maperiod2)-(maperiod1-1),rsi)-min(j-maperiod2,(j-maperiod2)
-(maperiod1-1),rsi))*(weight));
PrvStRSI:=PrvStRSI+((rsi(j-(maperiod2+1))-min(j-(maperiod2+1),(j-maperiod2)-(maperiod1),rsi))/
(.000001+max(j-(maperiod2+1),(j-maperiod2)-(maperiod1),rsi)-min(j-(maperiod2+1),(j-maperiod2)
-(maperiod1),rsi))*(weight));
PrvPrvSRSI:=PrvPrvSRSI+((rsi(j-(maperiod2+2))-min(j-(maperiod2+2),(j-maperiod2)-(maperiod1+1),rsi))/
(.000001+max(j-(maperiod2+2),(j-maperiod2)-(maperiod1+1),rsi)-min(j-(maperiod2+2),(j-maperiod2)
-(maperiod1+1),rsi))*(weight));
next j;

println symbol, " StochRSI ", maperiod1:2, ": ", StochRSI:6:2, ", ", "PrvStRSI: ", PrvStRSI:6:2,
", ", "PrvPrvSRSI: ", PrvprvSRSI:6:2, ", ", "RSI: ", rsi(0);

set rsi = maperiod1a;

weighta:=0;
totala:=0;
for i = maperiod2a to 1 step -1 do
totala:= totala + i;
next i;
totaldaysa:=totala;

StochRSI2:=0;
PrvStRSI2:=0;
PrvPrvSRSI2:=0;
for j = maperiod2a to 1 step -1 do
weighta:=((j/totaldaysa)*100);
StochRSI2:=StochRSI2+((rsi(j-maperiod2a)-min(j-maperiod2a,(j-maperiod2a)-(maperiod1a-1),rsi))/
(.000001+max(j-maperiod2a,(j-maperiod2a)-(maperiod1a-1),rsi)-min(j-maperiod2a,(j-maperiod2a)
-(maperiod1a-1),rsi))*(weighta));
PrvStRSI2:=PrvStRSI2+((rsi(j-(maperiod2a+1))-min(j-(maperiod2a+1),
(j-maperiod2a)-(maperiod1a),rsi))/
(.000001+max(j-(maperiod2a+1),(j-maperiod2a)-(maperiod1a),rsi)-min(j-(maperiod2a+1),
(j-maperiod2a)-(maperiod1a),rsi))*(weighta));
PrvPrvSRSI2:=PrvPrvSRSI2+((rsi(j-(maperiod2a+2))-min(j-(maperiod2a+2),
(j-maperiod2a)-(maperiod1a+1),rsi))/
(.000001+max(j-(maperiod2a+2),(j-maperiod2a)-(maperiod1a+1),rsi)-min(j-(maperiod2a+2),
(j-maperiod2a)-(maperiod1a+1),rsi))*(weighta));
next j;

println symbol, "StochRSI2 ", maperiod1a:2, ": ", StochRSI2:6:2, ", ", "PrvStRSI2: ", PrvStRSI2:6:2,
", ", "PrvPrvSRSI2: ", PrvprvSRSI2:6:2, ", ", "RSI: ", rsi(0);

*****************************

//StochRSI with EMA, by David Smilay
output="SRSI-EMA.lst";
input="portfoli.lst";
Daystoload= 416;
issuetype=common;
exchange nyse,nasdaq,amex;

float prevEMA, EMA, pct1, pct2, maperiod1, SRSI, StochRSI, PrevStochRSI;
integer i;

maperiod1 := 14; // Exponential Moving Avg periods
pct1 := 2/(maperiod1 + 1); //calculate EMA percentage for current data
pct2 := 1 - pct1; //calculate EMA percentage for previous EMA data

Set RSI=maperiod1;

prevEMA := RSI(-(maperiod1*2)); //RSI seeds prevEMA.
//Recommend 2 to 4. 4 gives most accurate results but slows scan

for i=(maperiod1*2)-1 to 0 step -1 do

SRSI :=(RSI(-i)-Min(-i,-i-maPeriod1+1,RSI))/
(.00001+(Max(-i,-i-maPeriod1+1,RSI)-Min(-i,-i-maPeriod1+1,RSI)))*100;
EMA := (pct1 * SRSI) + (prevEMA * pct2);
if !i = 0 then
prevEMA := (pct1 * SRSI) + (prevEMA * pct2);
endif;

next i;

StochRSI := EMA;
PrevStochRSI := prevEMA;

println symbol, ",",StochRSI:5:3,", ", PrevStochRSI:5:3;
Report TOU ViolationShare This Post
 Public ReplyPrvt ReplyMark as Last ReadFilePrevious 10Next 10PreviousNext