leap-forward

Reverse Repo Correlation

Reverse Repo Correlation Indicator

This TradingView indicator calculates the correlation between the current stock's close price and the value of the Reverse Repo Rate (`RRPONTSYD`). It uses the Pearson correlation coefficient to measure the strength and direction of the relationship.

Inputs

- **Correlation Length**: The number of bars used to calculate the correlation.
- **Background Transparency**: The transparency level (0-100) for the background color indicating positive or negative correlation.

### How it works

1. The indicator retrieves the close price of the current stock and assigns it to the `stockClose` variable.
2. The **Correlation Length** input determines the number of bars used to calculate the correlation.
3. The `pearson_corr` function calculates the Pearson correlation between the `stockClose` and `rrpontsydValue` variables over the specified length.
4. The `rrpontsydValue` is retrieved using the `request.economic` function, which fetches the Reverse Repo Rate value (`RRPONTSYD`) for the "US" economic calendar.
5. The correlation value is plotted on the chart as a line, with positive correlations displayed in green and negative correlations in red.
6. The **Background Transparency** input determines the transparency level of the background color, which changes based on the correlation value. Positive correlations have a green background, while negative correlations have a red background.

Adjust the `correlationLength` and `transparency` inputs as needed.


สคริปต์โอเพนซอร์ซ

ด้วยจิตวิญญาณของ TradingView อย่างแท้จริง ผู้เขียนสคริปต์นี้ได้เผยแพร่เป็นโอเพนซอร์ส เพื่อให้ผู้ค้าสามารถเข้าใจและตรวจสอบได้ ไชโยให้กับผู้เขียน! คุณสามารถใช้ได้ฟรี แต่การใช้รหัสนี้ซ้ำในสิ่งพิมพ์อยู่ภายใต้กฎระเบียบการใช้งาน คุณสามารถตั้งเป็นรายการโปรดเพื่อใช้บนชาร์ตได้

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมที่ เงื่อนไขการใช้บริการ

ต้องการที่จะใช้สคริปต์นี้บนชาร์ตใช่ไหม?