OPEN-SOURCE SCRIPT

Super Investor Club SMA RSI Trailing Stop for SPX

Optimized for SPX, credit goes to Sean Seah Weiming

Key Features
Inputs:

smaLength: Length of the SMA (200 by default).
rsiLength: Length of the RSI calculation (14 by default).
rsiThreshold: RSI value below which entries are considered (40 by default).
trailStopPercent: Trailing stop loss percentage (5% by default).
waitingPeriod: The number of days to wait after an exit before entering again (10 days by default).
200 SMA and RSI Calculation:

Calculates the 200-period SMA of the closing price.
Computes the RSI using the given rsiLength.
Conditions for Entry:

A "buy" signal is triggered when:
The closing price is above the 200 SMA.
The RSI is below the defined threshold.
The waiting period since the last exit has elapsed.
Trailing Stop Loss:

When in a long position, the trailing stop price is adjusted based on the highest price since entry and the specified percentage.
Exit Conditions:

A sell signal is triggered when:
The price falls below the trailing stop price.
The price falls below the 200 SMA.
Visualization:

The 200 SMA is plotted on the chart.
"BUY" and "SELL" signals are marked with green and red labels, respectively.
relative-strength-indexRelative Strength Index (RSI)Simple Moving Average (SMA)simplemovingaveragestrailingstoptrailingstoploss

Skrip sumber terbuka

Dalam semangat sebenar TradingView, penulis telah menerbitkan kod Pine ini sebagai sumber terbuka supaya pedagang dapat memahami dan mengesahkannya. Sorakan kepada penulis! Anda boleh menggunakan perpustakaan ini secara percuma, tetapi penggunaan semula kod dalam penerbitan ini adalah dikawal oleh Peraturan dalaman. Anda boleh menyukainya untuk menggunakannya pada carta.

Ingin menggunakan skrip ini pada carta?

Penafian