PureBytes Links
Trading Reference Links
|
Hello FT,
You asked -
"Does anyone know of an indicator that plots the relative price strength
of a stock and the SP500?"
If you want to just compare one stock versus the S&P you can use the
built in TS indicator - Spread(ratio).
Inputs: Input1(Close of data1){Stock}, Input2(Close of data2){Index};
Plot1(Input1 / Input2, "SpreadDiv");
When this indicator is trending up the stock is performing better than
the S&P and vice versa.
I'd guess what you really want to do though, is to rank all the stocks
in the S&P according to their relative strengths, like IBD does. One way
to do this is to write code that exports each stock's RS into Excel so
you can compare and sort them. The code below does that. It would be
nice if you could just turn the Workspace Assistant loose on a symbol
list of the entire S&P 500 and just kick back while it creates a
spreadsheet file of 500 stocks. For reasons explained in recent posts
though, the piece of %$*@ WA produces strange (or no) results when
trying to do this. Although tedious, manually clicking the "load next
symbol" button works correctly.
If anyone is able to get this (or any FileAppend code) to work correctly
with the WA, please let me know.
-Lance Fisher
**********Code Below**********
{This code returns Relative Strength, IBD style.
It samples a symbols' %increase (or %decrease) 4 times per year and
weights each sampling
as follows. 3Month - 40%, 6Month - 20%, 9Month - 20%, 12Month - 20%.
It will export
the RelStrength ranking of any # of symbols to a .csv file. From there
you can use Excel's
sort function to rank symbols according to their RS. For use with daily
bars.
You will have to change the input "FileName" to create the file in the
directory you
want it created in.
- Written by Lance Fisher }
Input: MakeFile (False), {Set to true to create .csv file}
FileName ("C:\Desktop\RelStrength.CSV") ;
Vars: ThreeMonth (00),
SixMonth (00),
NineMonth (00),
TwelveMonth(00),
RS (00) ;
ThreeMonth = ((Close / Close[60] ) - 1) * 100 ; {Rate of Change%}
SixMonth = ((Close / Close[120]) - 1) * 100 ; {Rate of Change%}
NineMonth = ((Close / Close[180]) - 1) * 100 ; {Rate of Change%}
TwelveMonth = ((Close / Close[240]) - 1) * 100 ; {Rate of Change%}
{Assign weights to ROC look back periods}
RS = (ThreeMonth * .4) + (SixMonth * .2) + (NineMonth * .2) +
(TwelveMonth * .2) ;
Plot1(RS, "RS.ibd");
If LastBarOnChart and MakeFile then begin
FileAppend(FileName, Text(GetSymbolName, ", ", NumToStr(RS, 2)) +
NewLine) ;
End;
Attachment:
Description: "RELSTRENGTH.IBD.ELA"
|