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

Скрипт с открытым кодом

В истинном духе TradingView автор этого скрипта опубликовал его с открытым исходным кодом, чтобы трейдеры могли понять, как он работает, и проверить на практике. Вы можете воспользоваться им бесплатно, но повторное использование этого кода в публикации регулируется Правилами поведения. Вы можете добавить этот скрипт в избранное и использовать его на графике.

Хотите использовать этот скрипт на графике?

Отказ от ответственности