jayy

Relative Strength of 2 securities - Jayy

146 2 8
This is an update of the Relative Strength to index as used by Leaf_West.. 4th from the top. my original RS             script is 3rd from the top.
In this use of the term " Relative Strength" ( RS             ) what is meant is a ratio of one security to another.
The RS             can be inerpreted in a fashion similar to price action on a regual security chart.
If you follow his methods be aware of the different moving averages for the different time periods.
From Leaf_West: "on my weekly and monthly R/S charts, I include a 13 EMA of the R/S (brown dash line) and
an 8 SMA of the 13 EMA (pink solid line). The indicator on the bottom of the weekly/monthly charts is an
8 period momentum indicator of the R/S line. The red horizontal line is drawn at the zero line.
For daily or 130-minute time periods (or shorter), my R/S charts are slightly different
- the moving averages of the R/S line include a 20EMA (brown dash line), a 50 EMA (blue dash line) and
an 8 SMA of the20 EMA (pink solid line). The momentum indicator is also slightly different from the weekly/monthly
charts – here I use a 12 period calculation (vs 8 SMA period for the weekly/monthly charts)."
Leaf's website has gone but I if you are interested in his methods message me.
What is different from my previous RS: The RS             now displays RS             candles. So if you prefer to watch price action of candles to
a line chart which only plots the ratio of closes then this will be more interesting to you.
I have also thrown in a few options to have fun with.

Jayy
Remove from Favorite Scripts Add to Favorite Scripts
//  This is an update of the Relative Strength to index as used by Leaf_West.
//  In this use of the term " Relative Strength" (RS) what is meant is a ratio of one security to another.
//  The RS can be inerpreted in a fashion similar to price action on a regual security chart.
// If you follow his methods be aware of the different moving averages for the different time periods.
// From Leaf_West: "on my weekly and monthly R/S charts, I include a 13 EMA of the R/S (brown dash line) and
// an 8 SMA of the 13 EMA (pink solid line). The indicator on the bottom of the weekly/monthly charts is an 
// 8 period momentum indicator of the R/S line. The red horizontal line is drawn at the zero line. 
// For daily or 130-minute time periods (or shorter), my R/S charts are slightly different 
// - the moving averages of the R/S line include a 20EMA (brown dash line), a 50 EMA (blue dash line) and
// an 8 SMA of the20 EMA (pink solid line). The momentum indicator is also slightly different from the weekly/monthly 
// charts – here I use a 12 period calculation (vs 8 SMA period for the weekly/monthly charts)." 
// Leaf's website has gone but I if you are interested in his methods message me. 
//  What is different from my previous RS:  The RS now displays RS candles.  So if you prefer to watch price action of candles to 
// a line chart which only plots the ratio of closes then this will be more interesting to you.
// I have also thrown in a few options to have fun with.  

// Jayy

study(title = "Relative Strength of 2 securities - Jayy", shorttitle=" relative chart strength Jayy", overlay=false)
hidecandles=input(false, title= "Hide relative strength candles (source divided by index or other as per following options?)")
justlinechart=input(false, title= "Show Relative Strength line chart (source divided by index or other as per following options?)")

sym = input(title="Default choice is the source security divided by an index or security you select here (x100) ", type=symbol, defval="NASDAQ:QQQ")  //"NASDAQ:QQQ"  "AMEX:SPY"
do1by2 =input(false, title= " Check to show relative strength index of any 2 securities you select below - default is choice above")
sym1 = input(title="Security 1 ", type=symbol, defval="AMEX:VIXY")  // eg "NASDAQ:QQQ" or "AMEX:SPY"
sym2 = input(title="Security 2 (security 1 divided by security 2 (x100) ", type=symbol, defval="AMEX:VXX")  //eg "NASDAQ:QQQ" or "AMEX:SPY"

FANGnotuse= input(false, title= "Check box to show security relative to a cumulative of 4 select security/index or uncheck for either choice above")

symf = input(title="Facebook or ?", type=symbol, defval="NASDAQ:FB")
syma = input(title="AAPL or ?", type=symbol, defval="NASDAQ:AAPL")
symn = input(title="Netflix or ?", type=symbol, defval="NASDAQ:NFLX")
symg = input(title="Google or ?", type=symbol, defval="NASDAQ:GOOG")

MAsho= input(true, title= "Show moving averages?")
lenemarsh = input (20, title=" smoothing period for intraday and daily short ema")
lenemarlo = input (13, title=" smoothing period for weekly and monthly short ema")
lensma_ema = input (8, title="smoothing period for sma of ema")
lenemalong=input(50, title=" smoothing period for intraday and daily long ema")
shoemalong= input(false, title= "show 50 ema on weekly and monthly R/S")
lenemars= isintraday or period=='D' ? lenemarsh:lenemarlo


so = security(sym, period, open)
sh = security(sym, period, high)
sl = security(sym, period, low)
sc = security(sym, period, close)

sfo = security(symf, period, open) + security(syma, period, open) + security(symn, period, open) +security(symg, period, open)
sfh = security(symf, period, high) + security(syma, period, high) + security(symn, period, high) +security(symg, period, high)
sfl = security(symf, period, low) + security(syma, period, low) + security(symn, period, low) +security(symg, period, low)
sfc = security(symf, period, close) + security(syma, period, close) + security(symn, period, close) +security(symg, period, close)
s1o = security(sym1, period, open)
s1h = security(sym1, period, high)
s1l = security(sym1, period, low)
s1c = security(sym1, period, close)
s2o = security(sym2, period, open)
s2h = security(sym2, period, high)
s2l = security(sym2, period, low)
s2c = security(sym2, period, close)


s1= FANGnotuse==false?(do1by2? s1o/s2o*100:open/so*100):sfo/so*100
s2= FANGnotuse==false?(do1by2? s1h/s2h*100:high/sh*100):sfh/sh*100
s3= FANGnotuse==false?(do1by2? s1l/s2l*100:low/sl*100):sfl/sl*100
s4= FANGnotuse==false?(do1by2? s1c/s2c*100:close/sc*100):sfc/sc*100



emars= ema(s4,lenemars)//s3,lenemars
sma_ema= sma(emars, lensma_ema)
emalong= ema(s4, lenemalong)
plot(justlinechart== true?s4:na, color=black,title=" line chart of relative chart strength")
plot (MAsho?emars:na, color=maroon, title="e moving avg of rel chart strength")
plot (MAsho?emars:na, color=black,style=circles, title="e moving avg of rel chart strength")
plot (MAsho?sma_ema:na, color=fuchsia,  title="s moving avg of e moving avg ")
plot (MAsho?emalong:na, color=shoemalong or (isintraday or period=='D')?blue:na)

plotcandle(s4>s1 and not hidecandles?s1:na, s4>s1 and not hidecandles?s2:na, s4>s1 and not hidecandles?s3:na,s4>s1 and not hidecandles?s4:na, title="Color candles - bull bars", color =lime, wickcolor=black)
plotcandle(s4<s1 and not hidecandles?s1:na,s4<s1 and not hidecandles?s2:na,s4<s1 and not hidecandles?s3:na,s4<s1 and not hidecandles?s4:na, title=" Color candles - bear bars", color =red, wickcolor=black)
plotcandle(s4==s1 and not hidecandles?s1:na,s4==s1 and not hidecandles?s2:na,s4==s1 and not hidecandles?s3:na,s4==s1 and not hidecandles?s4:na, title="Color candles - close = open", color =gray, wickcolor=navy)
Jayy
coondawg71 PRO
5 months ago
Nice work jayy! You always offer something very useful! Thanks for sharing.
Reply
jayy PRO coondawg71
5 months ago
Thanks coondawg71
Reply
Ideas Scripts Chart
United States
United Kingdom
India
España
Italia
Brasil
Россия
Türkiye
日本
한국
Home Stock Screener Economic Calendar How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter
Private Messages Chat Ideas Published Followers Following Priority Support Public Profile Profile Settings Billing Sign Out