OPEN-SOURCE SCRIPT
Güncellendi

System 0530 - Stoch RSI Strategy with ATR filter

258
Strategy Description: System 0530 - Multi-Timeframe Stochastic RSI with ATR Filter
Overview:
This strategy, "System 0530," is designed to identify trading opportunities by leveraging the Stochastic RSI indicator across two different timeframes: a shorter timeframe for initial signal triggers (assumed to be the chart's current timeframe, e.g., 5-minute) and a longer timeframe (15-minute) for signal confirmation. It incorporates an ATR (Average True Range) filter to help ensure trades are taken during periods of adequate market volatility and includes a cooldown mechanism to prevent rapid, successive signals in the same direction. Trade exits are primarily handled by reversing signals.

How It Works:

1. Signal Initiation (e.g., 5-Minute Timeframe):

Long Signal Wait: A potential long entry is considered when the 5-minute Stochastic RSI %K line crosses above its %D line, AND the %K value at the time of the cross is at or below a user-defined oversold level (default: 30).
Short Signal Wait: A potential short entry is considered when the 5-minute Stochastic RSI %K line crosses below its %D line, AND the %K value at the time of the cross is at or above a user-defined overbought level (default: 70). When these conditions are met, the strategy enters a "waiting state" for confirmation from the 15-minute timeframe.
2. Signal Confirmation (15-Minute Timeframe):

Once in a waiting state, the strategy looks for confirmation on the 15-minute Stochastic RSI within a user-defined number of 5-minute bars (wait_window_5min_bars, default: 5 bars).
Long Confirmation:
The 15-minute Stochastic RSI %K must be greater than or equal to its %D line.
The 15-minute Stochastic RSI %K value must be below a user-defined threshold (stoch_15min_long_entry_level, default: 40).
Short Confirmation:
The 15-minute Stochastic RSI %K must be less than or equal to its %D line.
The 15-minute Stochastic RSI %K value must be above a user-defined threshold (stoch_15min_short_entry_level, default: 60).
3. Filters:

ATR Volatility Filter: If enabled, trades are only confirmed if the current ATR value (converted to ticks) is above a user-defined minimum threshold (min_atr_value_ticks). This helps to avoid taking signals during periods of very low market volatility. If the ATR condition is not met, the strategy continues to wait for the condition to be met within the confirmation window, provided other conditions still hold.
Signal Cooldown Filter: If enabled, after a signal is generated, the strategy will wait for a minimum number of bars (min_bars_between_signals) before allowing another signal in the same direction. This aims to reduce overtrading.
4. Entry and Exit Logic:

Entry: A strategy.entry() order is placed when all trigger, confirmation, and filter conditions are met.
Exit: This strategy primarily uses reversing signals for exits. For example, if a long position is open, a confirmed short signal will close the long position and open a new short position. There are no explicit take profit or stop loss orders programmed into this version of the script.
Key User-Adjustable Parameters:

Stochastic RSI Parameters: RSI Length, Stochastic RSI Length, %K Smoothing, %D Smoothing.
Signal Trigger & Confirmation:
5-minute %K trigger levels for long and short.
15-minute %K confirmation thresholds for long and short.
Wait window (in 5-minute bars) for 15-minute confirmation.
Filters:
Enable/disable and configure the Signal Cooldown filter (minimum bars between signals).
Enable/disable and configure the ATR Volatility filter (ATR period, minimum ATR value in ticks).
Strategy Parameters:
Leverage Multiplier (Note: This primarily affects theoretical position sizing for backtesting calculations in TradingView and does not simulate actual leveraged trading risks).
Recommendations for Users:

Thorough Backtesting: Test this strategy extensively on historical data for the instruments and timeframes you intend to trade.
Parameter Optimization: Experiment with different parameter settings to find what works best for your trading style and chosen markets. The default values are starting points and may not be optimal for all conditions.
Understand the Logic: Ensure you understand how each component (Stochastic RSI on different timeframes, ATR filter, cooldown) interacts to generate signals.
Risk Management: Since this version does not include explicit stop-loss orders, ensure you have a clear risk management plan in place if trading this strategy live. You might consider manually adding stop-loss orders through your broker or using TradingView's separate strategy order settings for stop-loss if applicable.
Disclaimer:
This strategy description is for informational purposes only and does not constitute financial advice. Past performance is not indicative of future results. Trading involves significant risk of loss. Always do your own research and understand the risks before trading.
Sürüm Notları
Strategy Overview: System 0530 - Stochastic RSI Multi-Timeframe
This TradingView Pine Script outlines a strategy primarily based on the Stochastic RSI (Stoch RSI) indicator, employing a multi-timeframe approach for signal generation and confirmation. It is designed to operate on a 5-minute chart, referencing 15-minute data for higher-level context.

Core Mechanics:

Primary Indicator: Stochastic RSI, used to identify overbought/oversold conditions and potential momentum shifts.

Timeframes:

5-minute chart: For initial signal triggers and primary execution.

15-minute chart: For signal confirmation and certain take-profit conditions.

Entry Logic:

5-Minute Initial Trigger:

Long: 5-minute Stoch RSI K-line crosses above its D-line, AND the K-value at the time of the cross is below a specified stoch_5min_k_long_trigger level.

Short: 5-minute Stoch RSI K-line crosses below its D-line, AND the K-value at the time of the cross is above a specified stoch_5min_k_short_trigger level.

15-Minute Confirmation:

After a 5-minute trigger, the strategy waits for a configurable number of 5-minute bars (wait_window_5min_bars) for confirmation from the 15-minute timeframe.

Long Confirmation: 15-minute Stoch RSI K-line must be strictly greater than its D-line, AND the 15-minute K-value must be below stoch_15min_long_entry_level.

Short Confirmation: 15-minute Stoch RSI K-line must be strictly less than its D-line, AND the 15-minute K-value must be above stoch_15min_short_entry_level.

Position Lock: No new entry signals are generated if the strategy already holds an open position.

Duplicate Signal Filter: A cooldown period, defined by min_bars_between_signals, must pass before another signal in the same direction can be considered.

Exit Logic:

Stop-Loss (SL):

The SL is set based on the low (for longs) or high (for shorts) of the 5-minute bar on which the trade was entered.

The position is closed if a subsequent 5-minute bar's closing price moves beyond this SL level.

SL checks are prioritized over Take-Profit checks.

Take-Profit (TP) - Two-Stage Mechanism:

TP1 (Closes 50% of the position):

Priority A (Extreme K Levels): If the 5-minute Stoch K OR 15-minute Stoch K value exceeds extreme_long_tp_level (for longs) or drops below extreme_short_tp_level (for shorts).

Priority B (Conditional 5-min Cross + 15-min K-Reversal): If Extreme K conditions are not met, TP1 is triggered if:

A 5-minute Stoch RSI K/D crossover occurs (K crosses below D for longs; K crosses above D for shorts - using strict ta.crossunder/ta.crossover).

AND this 5-minute crossover is confirmed by a 15-minute Stoch K-value "reversal" (current 15m K < previous 15m K for longs; current 15m K > previous 15m K for shorts).

TP2 (Closes remaining 50% of the position):

This stage is active only after TP1 has been taken.

If the 5-minute Stoch K OR 15-minute Stoch K value reaches the same extreme_long_tp_level or extreme_short_tp_level again, a waiting period begins, defined by tp2_extreme_k_wait_bars (number of 5-minute bars).

If the extreme K condition persists after this waiting period, TP2 is executed.

If the extreme K condition disappears during the waiting period, the TP2 attempt for that instance is cancelled.

If tp2_extreme_k_wait_bars is set to 0, TP2 will trigger immediately upon the extreme K condition being met after TP1.

Note on Fine-Tuning (as per user context):
This strategy has been specifically fine-tuned for SPY. As with any trading system, its performance can vary across different instruments and market conditions. The user notes that to potentially maximize profits, especially in trending scenarios where the current "Extreme K" based TP2 might exit prematurely, it is advisable to explore and integrate other indicators or alternative take-profit methodologies. Dynamic approaches like ATR (Average True Range) trailing stops or trend-following exit signals could be considered for managing the second portion of the position.

Feragatname

Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.