OPEN-SOURCE SCRIPT

[MAD] Self-Optimizing RSI

已更新
Overview

This script evaluates multiple RSI lengths within a specified range, calculates performance metrics for each, and identifies the top 3 configurations based on a custom scoring system. It then plots the three best RSI curves and optionally displays a summary table and label.

How It Works
The script calculates a custom RSI for each length in the [Min RSI Length .. Max RSI Length] range.

It simulates entering a long position when RSI crosses below the Buy Value and exits when RSI crosses above the Sell Value.
Each trade's return is stored in the relevant StatsContainer.

Metrics Computation
After all bars have been processed,
* Net Profit,
* Sharpe Ratio, and
* Win Rate
are computed for each RSI length.
A weighted score is then derived using the input weights.

Top 3 Identification
The script finds the three RSI lengths with the highest scores.
The RSI lines for these top 3 lengths are plotted in different colors.
If enabled, a table listing the top 3 results (Rank, RSI length, Sharpe, NetPnL, Win Rate) is shown.
If enabled, a label with the highest-scoring RSI length and its score is placed on the final bar.

Usage Tips
Adjust Min RSI Length and Max RSI Length to explore a narrower or wider range of periods.
Be aware, to high settings will slow down the calculation.
Experiment with different RSI Buy Value and RSI Sell Value settings if you prefer more or fewer trade signals.
Confirm that Min Trades Required aligns with the desired confidence level for the computed metrics.
Modify Weight: Sharpe, Weight: NetProfit, and Weight: WinRate to reflect which metrics are most important.

Troubleshooting
If metrics remain - or NaN, confirm enough trades (Min Trades Required) have occurred.
If no top 3 lines appear, it could mean no valid trades were taken in the specified range, or the script lacks sufficient bars to calculate RSI for some lengths. In this case set better buyvalue and sellvalues in the inputs

Disclaimer
Past performance is not indicative of future results specialy as this indicator can repaint based on max candles in memory which are limited by your subscription
版本注释
Typo in the table, thx for notifying
Relative Strength Index (RSI)

开源脚本

本着真正的TradingView精神,此脚本的作者已将其开源,以便交易者可以理解和验证它。向作者致敬!您可以免费使用它,但在出版物中重复使用此代码受网站规则约束。 您可以收藏它以在图表上使用。

想在图表上使用此脚本?


djmad|Bitblockart

免责声明