gaperton

Linear Regression Relative Strength

gaperton 已更新   
[image/x/iZvwDWEY/

Relative Strength indicator comparing the current symbol to SPY (or any other benchmark). It may help to pick the right assets to complement the portfolio build around core ETFs such as SPY.

The general idea is to show if the current symbol outperforms or underperforms the benchmark (SPY by default) when bought some certain time ago. Relative performance is displayed as percent and is calculated for three different time ranges - short (1 mo by default), mid (1 quarter), and long (half a year). To smooth the volatility, the script uses linear regression to estimate the trend and takes the start and the end points of the linear regression line to compute the relative strength.

It is important to remember that the script shows the gain relative to SPY (or other selected benchmark), not the asset's gain. Therefore, it may indicate that the asset is profitable, but it still may lose value if SPY is in downtrend.

Therefore, it is crucial to check other indicators before making a decision. In the example above, standard linear regression for one quarter is used to indicate the direction of the trend.
發布通知:
Added source filtering options:

- "None" - Relative Strength computed using the raw data: the current price and the price back in time.
- "3-point average" - an average of the three neighboring prices is used instead of the raw price.
- "5-point average" - an average of the five neighboring prices is used instead of the raw price.
- "Linear Regression Trend" - instead of the prices, linear regression trend is computed for the period and its first and last values are taken.

Comparison with baseline is now optional. You can turn it off in options and see how the asset alone performed.
發布通知:
Fixed bug in the calculation.

New formula:

Gain = ( endPrice - startPrice ) / startPrice
RS = Gain( X ) - Gain( S&P )

The values are percent and they have clear economic sense. Given the period is P, RS is the profit which you would receive from buying the asset P days ago when compared to S&P (or other selected baseline).
發布通知:
- Added source selection, which is daily by default. It keeps the indicator values when switching to intraday.
- 3 and 5 points average filters now use the weighted average, with wights 1-2-3 and 1-2-3-4-5 respectively. It reduces the delay of the filter to one and two bars.
- Changed the colors. Red is a short one, yellow is mid, and the blue area chart is long range.
- Changed the default periods so the red line is really close to MACD (and it can be used as MACD).
發布通知:
- Added Sharpe Ratio as another strength metric option
- Various usability fixes
開源腳本

本著真正的TradingView精神,該腳本的作者將其開源發布,以便交易者可以理解和驗證它。為作者喝彩吧!您可以免費使用它,但在出版物中重複使用此代碼受網站規則的約束。 您可以收藏它以在圖表上使用。

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。

想在圖表上使用此腳本?