OPEN-SOURCE SCRIPT

4 Bar Momentum Reversal strategy

█ STRATEGY DESCRIPTION
The "4 Bar Momentum Reversal Strategy" is a mean-reversion strategy designed to identify price reversals following a sustained downward move. It enters a long position when a reversal condition is met and exits when the price shows strength by exceeding the previous bar's high. This strategy is optimized for indices and stocks on the daily timeframe.

█ WHAT IS THE REFERENCE CLOSE?
The Reference Close is the closing price from X bars ago, where X is determined by the Lookback period. Think of it as a moving benchmark that helps the strategy assess whether prices are trending upwards or downwards relative to past performance. For example, if the Lookback is set to 4, the Reference Close is the closing price 4 bars ago (`close[4]`).

█ SIGNAL GENERATION
1. LONG ENTRY
A Buy Signal is triggered when:
  • The close price has been lower than the Reference Close for at least `Buy Threshold` consecutive bars. This indicates a sustained downward move, suggesting a potential reversal.
  • The signal occurs within the specified time window (between `Start Time` and `End Time`).


2. EXIT CONDITION
  • A Sell Signal is generated when the current closing price exceeds the high of the previous bar (`close > high[1]`). This indicates that the price has shown strength, potentially confirming the reversal and prompting the strategy to exit the position.


█ ADDITIONAL SETTINGS
  • Buy Threshold: The number of consecutive bearish bars needed to trigger a Buy Signal. Default is 4.
  • Lookback: The number of bars ago used to calculate the Reference Close. Default is 4.
  • Start Time and End Time: The time window during which the strategy is allowed to execute trades.


█ PERFORMANCE OVERVIEW
  • This strategy is designed for trending markets with frequent reversals.
  • It performs best in volatile conditions where price movements are significant.
  • Backtesting results should be analysed to optimize the Buy Threshold and Lookback parameters for specific instruments.

Breadth IndicatorsChart patternsdaytradingIndicesmeanreversalStocksswingtradingtdsequentialtrendTrend Analysis

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