equitySymbol: The symbol for the equity index (default is "SPY" for the S&P 500 ETF). bondSymbol: The symbol for the bond market (default is "TLT" for the 20+ Year Treasury Bond ETF). Fetch Data:
equityClose and bondClose retrieve the daily closing prices for the specified equity and bond symbols. Relative Spread Calculation:
The relative spread is calculated by dividing the equity index's closing price by the bond market's closing price. Thresholds:
The 50-period Simple Moving Average (SMA) of the relative spread is calculated. Overvalued and undervalued thresholds are set at 10% above and below the SMA, respectively. Normalized Spread:
The normalized spread is calculated to normalize the relative spread around its SMA, which helps in visualizing it as an oscillator. Plotting:
The normalized spread is plotted as a blue line in the oscillator panel. Overvalued and undervalued thresholds are plotted as dotted lines at 0.1 and -0.1, respectively. The zero line is plotted as a solid orange line. Background colors indicate overvalued (red) and undervalued (green) regions. Signals:
Buy signals are plotted when the normalized spread crosses above the undervalued threshold (-0.1).
Sell signals are plotted when the normalized spread crosses below the overvalued threshold (0.1).
This script plots the relative spread as an oscillator, allowing you to see overvalued and undervalued conditions in a separate panel. You can further customize the look and feel based on your preferences and trading strategy.
نص برمجي مفتوح المصدر
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
For quick access on a chart, add this script to your favorites — learn more here.
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
For quick access on a chart, add this script to your favorites — learn more here.
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.