[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Welles Wilder's Relative Strength Index (RSI)


  • To: <metastock@xxxxxxxxxxxxx>
  • Subject: Re: Welles Wilder's Relative Strength Index (RSI)
  • From: "Glen Wallace" <gcwallace@xxxxxxxx>
  • Date: Mon, 2 Aug 1999 15:38:13 -0700
  • In-reply-to: <003001bedb96$0d041020$5f1c4118@xxxxxxxxxxxxxxxxxxxxxx>

PureBytes Links

Trading Reference Links

Thanks to everyone who offered solutions.  Below is the code for an RSI
where you can customize the number of periods (perhaps to increase or
decrease as volatility changes) and the price array (perhaps to a moving
average of the close).  Although I have not tested it thoroughly, when I use
similar parameters, it matches the standard MetaStock RSI function.  Of
course, if you spot any flaws or improvements, let me know.

Note that the parameters used in the example below have no value as an
indicator; they're just for illustration.

RSIPeriod:= Int(14 / (Stdev(CLOSE,10)/Stdev(CLOSE,5)));
RSIDataArray:= Mov(CLOSE,25,SIMPLE);

U:= Wilders(If(ROC(RSIDataArray,1,$)>0,
      ROC(RSIDataArray,1,$), 0),
      LastValue(RSIPeriod));

D:= Wilders(If(ROC(RSIDataArray,1,$)<0,
      Abs(ROC(RSIDataArray,1,$)), 0),
      LastValue(RSIPeriod));

100-(100/(1+U/D))


----- Original Message -----
From: Glen Wallace <gcwallace@xxxxxxxx>
To: MetaStock listserver <metastock@xxxxxxxxxxxxxxxxxx>
Sent: July 31, 1999 13:43
Subject: Welles Wilder's Relative Strength Index (RSI)


> The standard RSI function in MetaStock does not permit the use of a
> variable for the number of periods or for the price array, so I need to
> write the long-hand version.  Unfortunately, I'm having a brain fart when
> it comes to coding the sum of the absolute price changes on the up
> days (or down days) in a particular, user defined period.  Does anyone
> have the code for this, or can anyone suggest a solution?
>
> RSI = 100 - (100 / (1+U/D))
>
> Where:    U = an average of upward price change on a closing basis
>                D = an average of downward price change on a closing basis