OPEN-SOURCE SCRIPT
Relative Strength

Description
Relative Strength between a stock and a reference index (e.g., Intesa San Paolo vs. FTSEMIB).
This indicator calculates the Relative Strength (RS) as either a simple ratio of the base symbol's close to the comparative symbol's close, or as a normalized ratio over a lookback period. It helps identify the relative performance of a stock against an index, which can signal intermediate trends when the RS is above its moving average.
Key features:
- Input for comparative symbol (default: FTSEMIB).
- Option to toggle between simple ratio or ratio-over-time calculation.
- Adjustable lookback period for the ratio-over-time method.
- Optional display of a moving average on the RS line for trend analysis.
Use it to compare a stock's strength to the market—rising RS may indicate outperformance.
Script Overview
This is a Relative Strength (RS) indicator for TradingView (written in Pine Script version 5).
It compares the price performance of the current chart's symbol (e.g., a stock like Intesa San Paolo) against another symbol you choose (by default, the Italian index FTSEMIB).
The goal is to show whether the stock is outperforming or underperforming the reference index.
User Inputs (configurable in the settings panel)
Comparative Symbol Default: FTSEMIB
You can change it to any other ticker (e.g., SPX, DAX, etc.).
Calculate RS as simple ratio (true) or ratio over time (false)?
true (default): Simple ratio → current close of stock ÷ current close of index.
false: Ratio of returns over a lookback period (more normalized, less affected by absolute price levels).
Lookback Period (default 40 - weeks)
Only used when the above option is set to false.
Defines how many bars back to calculate the price change.
Show Moving Average (default off)
Optionally overlays a simple moving average on the RS line.
Moving Average Period (default 40 - weeks)
Length of the SMA when the MA is enabled.
Typical Use CaseTraders often look for:
Rising RS line → the stock is gaining strength vs. the index.
RS crossing above its moving average → potential bullish signal for relative performance.
Declining or falling RS → the stock is weakening vs. the broader market.
In summary, this is a clean and flexible relative strength comparator that lets you quickly visualize how strongly (or weakly) a stock is performing compared to a benchmark index, with two different calculation methods to suit different analytical preferences.
Relative Strength between a stock and a reference index (e.g., Intesa San Paolo vs. FTSEMIB).
This indicator calculates the Relative Strength (RS) as either a simple ratio of the base symbol's close to the comparative symbol's close, or as a normalized ratio over a lookback period. It helps identify the relative performance of a stock against an index, which can signal intermediate trends when the RS is above its moving average.
Key features:
- Input for comparative symbol (default: FTSEMIB).
- Option to toggle between simple ratio or ratio-over-time calculation.
- Adjustable lookback period for the ratio-over-time method.
- Optional display of a moving average on the RS line for trend analysis.
Use it to compare a stock's strength to the market—rising RS may indicate outperformance.
Script Overview
This is a Relative Strength (RS) indicator for TradingView (written in Pine Script version 5).
It compares the price performance of the current chart's symbol (e.g., a stock like Intesa San Paolo) against another symbol you choose (by default, the Italian index FTSEMIB).
The goal is to show whether the stock is outperforming or underperforming the reference index.
User Inputs (configurable in the settings panel)
Comparative Symbol Default: FTSEMIB
You can change it to any other ticker (e.g., SPX, DAX, etc.).
Calculate RS as simple ratio (true) or ratio over time (false)?
true (default): Simple ratio → current close of stock ÷ current close of index.
false: Ratio of returns over a lookback period (more normalized, less affected by absolute price levels).
Lookback Period (default 40 - weeks)
Only used when the above option is set to false.
Defines how many bars back to calculate the price change.
Show Moving Average (default off)
Optionally overlays a simple moving average on the RS line.
Moving Average Period (default 40 - weeks)
Length of the SMA when the MA is enabled.
Typical Use CaseTraders often look for:
Rising RS line → the stock is gaining strength vs. the index.
RS crossing above its moving average → potential bullish signal for relative performance.
Declining or falling RS → the stock is weakening vs. the broader market.
In summary, this is a clean and flexible relative strength comparator that lets you quickly visualize how strongly (or weakly) a stock is performing compared to a benchmark index, with two different calculation methods to suit different analytical preferences.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.