OPEN-SOURCE SCRIPT

RSI Crossover Strategy with Compounding (Monthly)

Explanation of the Code:
Initial Setup:

The strategy initializes with a capital of 100,000.
Variables track the capital and the amount invested in the current trade.
RSI Calculation:

The RSI and its SMA are calculated on the monthly timeframe using request.security().
Entry and Exit Conditions:

Entry: A long position is initiated when the RSI is above its SMA and there’s no existing position. The quantity is based on available capital.
Exit: The position is closed when the RSI falls below its SMA. The capital is updated based on the net profit from the trade.
Capital Management:

After closing a trade, the capital is updated with the net profit plus the initial investment.
Plotting:

The RSI and its SMA are plotted for visualization on the chart.
A label displays the current capital.
Notes:
Test the strategy on different instruments and historical data to see how it performs.
Adjust parameters as needed for your specific trading preferences.
This script is a basic framework, and you might want to enhance it with risk management, stop-loss, or take-profit features as per your trading strategy.
Feel free to modify it further based on your needs!
Moving AveragesPine utilitiesTrend Analysis

Script open-source

Dans le plus pur esprit TradingView, l'auteur de ce script l'a publié en open-source, afin que les traders puissent le comprendre et le vérifier. Bravo à l'auteur! Vous pouvez l'utiliser gratuitement, mais la réutilisation de ce code dans une publication est régie par nos Règles. Vous pouvez le mettre en favori pour l'utiliser sur un graphique.

Vous voulez utiliser ce script sur un graphique ?


Aussi sur:

Clause de non-responsabilité