Skip to main content

Real Relative Strength Tradingview PineScript








 



// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/

// © WorkPiece 12.28.21

//@version=5

indicator(title="Real Relative Strength", shorttitle="RRS")

comparedWithSecurity = input.symbol(title="Compare With", defval="SPY")

length = input(title="Length", defval=12)

//##########Rolling Price Change##########

comparedClose = request.security(symbol=comparedWithSecurity, timeframe="", expression=close)

comparedRollingMove = comparedClose - comparedClose[length]

symbolRollingMove = close - close[length]

//##########Rolling ATR Change##########

symbolRollingATR = ta.atr(length)[1]

comparedRollingATR = request.security (symbol=comparedWithSecurity, timeframe="", expression= ta.atr(length)[1])

//##########Calculations##########

powerIndex = comparedRollingMove / comparedRollingATR

RRS = (symbolRollingMove - powerIndex * symbolRollingATR) / symbolRollingATR

//##########Plot##########

RealRelativeStrength = plot(RRS, "RealRelativeStrength", color=color.blue)

Baseline = plot(0, "Baseline", color=color.red)

//##########Extra Stuff##########

fill(RealRelativeStrength, Baseline, color = RRS >= 0 ? color.green : color.red, title="fill")

correlated = ta.correlation(close, comparedClose, length)

Correlation = plot(0, title="Correlation", color = correlated > .75 ? #00FF00 : correlated > .50 ? #00C000 : correlated > .25 ? #008000 : correlated > 0.0 ? #004000 :correlated > -.25 ? #400000 :correlated > -.50 ? #800000 :correlated > -.75 ? #C00000 :#FF0000, linewidth=3, style=plot.style_circles)

Comments

Popular posts from this blog

TB 100.1.1 tsf tema linear

_SECTION_BEGIN("Magnified Market Price"); //by Vidyasagar, vkunisetty@yahoo.com// SetChartOptions(0,chartShowArrows|chartShowDates); FS=Param("Font Size",30,11,100,1); GfxSelectFont("Times New Roman", FS, 700, True ); GfxSetBkMode( colorWhite ); GfxSetTextColor( ParamColor("Color",colorWhite) ); Hor=Param("Horizontal Position",750,1,1200,1); Ver=Param("Vertical Position",7,1,830,1); GfxTextOut(""+C , Hor , Ver ); YC=TimeFrameGetPrice("C",inDaily,-1); DD=Prec(C-YC,2); xx=Prec((DD/YC)*100,2); GfxSelectFont("Times New Roman", 11, 700, True ); GfxSetBkMode( colorWhite ); GfxSetTextColor(ParamColor("Color",colorWhite) ); //GfxTextOut("Open - "+O+" High - "+H+" Low - "+L+" Close - "+C, Horr , Verr-14 ); //GraphXSpace = Param("Graph Space",500,-10,500,1); _SECTION_END(); _SECTION_BEGIN("Trend Blaster V1.2"); SetChartBkColor(...

ALMA KAMA

_SECTION_BEGIN("KAMA - Kaufman Adaptive Moving Average"); LBPeriods = Param( "LB Periods", 81, 1, 200, 1 ); FSCPeriods = Param( "FSC Periods", 15, 1, 200, 1 ); SSCPeriods = Param( "SSC Periods", 30, 1, 200, 1 ); FastSmoothConst = 2 / ( FSCPeriods + 1 ); SlowSmoothConst = 2 / ( SSCPeriods + 1 ); Direction = abs( Close - Ref( Close, -LBPeriods ) ); Volatility = Sum( abs( Close - Ref( Close, -1 ) ), LBPeriods ); EfficiencyRatio = Direction / Volatility; SC = ( EfficiencyRatio * ( FastSmoothConst - SlowSmoothConst ) + SlowSmoothConst ) ^ 2; KAMA = AMA( Close, SC ); Plot( KAMA, "KAMA", ParamColor( "Color", colorRed ), styleLine ); _SECTION_END(); "Arnaud Legoux Moving Average"; /*________________________________________________________________________________________________ AFL code by hiscores. Originally posted here http://finance.groups.yahoo.com/grou...message/154257 Minor mod by rmike to Modify the AFL in conform...

KBL Master Scalper Pro.

_SECTION_BEGIN("HA"); tchoice=Param("Title Selection ",2,1,2,1); Q=Param("% Change",2.1,1,10,1); Z= Ref(Zig(C ,q ),-1) ; HH=Ref(((Z<Ref(Z,-1) AND Ref(Z,-1) > Ref(Z,-2)) AND (Peak(z,q,1 ) >Peak(Z,q,2))),-1); LH=Ref(((Z<Ref(Z,-1) AND Ref(Z,-1) > Ref(Z,-2)) AND (Peak(Z,q,1 ) <Peak(Z,q,2))),-1); HL=Ref(((Z>Ref(Z,-1) AND Ref(Z,-1) < Ref(Z,-2)) AND (Trough(Z,q,1 ) >Trough(Z,q,2))),-1); LL=Ref(((Z>Ref(Z,-1) AND Ref(Z,-1) < Ref(Z,-2)) AND (Trough(Z,q,1 ) <Trough(Z,q,2))),-1); GraphXSpace = 5; dist = 0.5*ATR(20); for( i = 0; i < BarCount; i++ ) { if( HH[i] ) PlotText( "HH", i, H[ i ]+dist[i], colorCustom12 ); if( LH[i] ) PlotText( "LH", i, H[ i ]+dist[i], colorCustom12 ); if( HL[i] ) PlotText( "HL", i, L[ i ]-dist[i], colorBlack ); if( LL[i] ) PlotText( "LL", i, L[ i ]-dist[i], colorBlack ); } //calculates floor pivots from previous days data & plots it on the present intraday ...