N Reversal Detector

N Reversal Detector

The N Reversal Detector is a technical indicator developed to detect market trend reversal points. This indicator combines multiple approaches to identify both trends and potential market reversals, integrating the use of moving averages, the Supertrend indicator, and Donchian Channels. Its primary goal is to alert traders of potential changes in market direction, both in bullish and bearish trends.

Unlike other indicators that focus on a single method to identify market direction, the N Reversal Detector uses a multi-filter system. Depending on the selected configuration, the indicator can identify aligned or opposing trends, providing clear signals for traders looking for entries based on trend reversals.

In addition to filtering trends, the indicator also implements a reversal pattern detection system for both bullish and bearish reversals, making it highly versatile for use in multiple trading styles, whether on daily, intraday, or long-term charts.

Key Features:

  • Uses multiple trend filters (moving averages, Supertrend, and Donchian Channels).
  • Detects three-bar reversal patterns.
  • Provides clear visual signals for trading decisions.
  • Highly configurable, allowing adjustments according to the trader’s strategy.

2. Indicator Components

The N Reversal Detector consists of several key elements that work together to identify trends and potential reversal points. Below are the main components of the indicator:

2.1 Trend Filters

The indicator offers three types of trend filters that can be selected through the trendType variable. These filters allow you to adjust how the indicator detects trends and how it interprets reversal signals:

  • Moving Average (MA Trend): This filter uses two moving averages of different lengths to identify the trend. When the fast moving average (shorter period) is above the slow moving average (longer period), it is considered a bullish trend, and vice versa for a bearish trend.
    • Variables:
      • maFlength (default 50): Length of the fast moving average.
      • maSLength (default 200): Length of the slow moving average.
      • maType (default 7): Type of moving average (e.g., simple, exponential, etc.).
  • Supertrend (ST Trend): Uses the Supertrend indicator, which is based on the Average True Range (ATR) to determine whether the market is in a bullish or bearish trend. The Supertrend bands adjust according to volatility, making it particularly useful in volatile markets.
    • Variables:
      • atrPeriod (default 10): Period for the ATR.
      • factor (default 3): Multiplier for the ATR to determine trend bands.
  • Donchian Channels (Donchian Trend): This filter uses the highs and lows over a specified period to identify the trend. If prices are hitting new highs or lows, the trend is detected in that direction.
    • Variables:
      • length (default 13): Period for the Donchian Channels.

2.2 Reversal Pattern Detection

The indicator includes a reversal pattern detection module based on the last three bars of the chart. This module identifies conditions where the price has reached an extreme (high or low) and has started to reverse:

  • Bullish Reversal: A bullish reversal pattern is detected when the price has consistently dropped over several bars and begins to show signs of recovery. To confirm the bullish signal, the indicator also checks whether the overall trend supports the reversal.
    • Variables:
      • numBars (default 7): Number of bars used to detect the pattern.
      • minBars (default 50): Minimum percentage of bearish bars required to validate the reversal.
  • Bearish Reversal: Similar to the bullish reversal, this pattern identifies situations where the price has steadily risen and begins to retrace. It also requires that the overall trend is bearish to confirm the signal.
    • Variables:
      • numBars and minBars are also used for bearish reversals.

2.3 Trend Filter

The TrendFilter parameter is used to further refine the signals generated by the indicator. This filter allows the user to choose whether reversal signals should align with the overall trend or if they can be contrary:

  • TrendFilter enabled (True): Reversal signals are only generated when they align with the prevailing trend (bullish for bullish signals and bearish for bearish signals).
  • TrendFilter disabled (False): Reversal signals are allowed even if they are contrary to the main trend, which may generate more signals but also increases the risk of false alarms.

3. Indicator Configuration

The N Reversal Detector offers a range of adjustable parameters that allow users to tailor the indicator’s behavior to their preferences and trading strategies. Below are the main configuration variables and how they affect the indicator’s performance.

3.1 Input Variables

  • trendType (default 0): Defines the type of trend filter to use.
    • 0: No trend filter. The indicator will detect reversal signals without considering the overall market trend.
    • 1: Filter based on moving averages (MA).
    • 2: Filter based on the Supertrend indicator (ST).
    • 3: Filter based on Donchian Channels.
  • TrendFilter (default 1): Controls whether signals should align with the detected trend.
    • 1 (True): Only signals aligned with the trend will be allowed.
    • 0 (False): Reversal signals are allowed even if they go against the main trend.
  • Moving Averages:
    • maFlength (default 50): Defines the period for the fast moving average.
    • maSLength (default 200): Defines the period for the slow moving average.
    • maType (default 7): Determines the type of moving average (simple, exponential, etc.).
  • Supertrend:
    • atrPeriod (default 10): Number of periods used to calculate the Average True Range (ATR), which is key for determining the Supertrend bands.
    • factor (default 3): Multiplier applied to the ATR to set the Supertrend bands.
  • Donchian Channels:
    • length (default 13): Number of bars used to calculate the highs and lows for the Donchian channel.
  • Reversal Pattern Detection:
    • numBars (default 7): Number of bars analyzed to detect a bullish or bearish reversal. A higher number of bars provides more conservative signals.
    • minBars (default 50): Defines the minimum percentage of bars that must be bullish or bearish for the reversal pattern to be considered valid.

3.2 Parameter Adjustments

The N Reversal Detector is highly customizable, meaning traders can adjust the parameters according to market conditions or their risk preferences. Below are some common adjustment examples:

  • Moving Average Trend: If the trader prefers to use moving averages to define the trend, they can select trendType = 1 and adjust maFlength and maSLength according to the timeframe they are analyzing. For intraday charts, it may be more effective to reduce the moving averages periods (e.g., maFlength = 20 and maSLength = 50).
  • Supertrend for Volatile Markets: In highly volatile markets, the Supertrend can provide more dynamic signals. In this case, adjusting atrPeriod = 14 and factor = 2 can help produce tighter bands that react to price fluctuations.
  • Donchian Channels for Range-Bound Markets: If the market is in a sideways range, using the Donchian Channels (trendType = 3) may be more appropriate. Adjusting the length to 20 or more can help capture significant breakout movements.

3.3 Usage Considerations

  • No Trend Filter: For traders who prefer to trade against the trend or look for quick reversals, they can disable the trend filters by selecting trendType = 0 and TrendFilter = 0. This will generate more signals but may increase the number of false signals.
  • Trend Alignment: If the priority is to trade in the direction of the prevailing trend, it is advisable to keep TrendFilter = 1. This will reduce the number of signals generated but increase the likelihood that they are reliable.

4. How the Indicator Works

The N Reversal Detector works by combining different technical analysis techniques to detect both trends and potential reversals. In this section, we will break down the code to explain how buy and sell signals are generated and how the different components of the indicator interact.

4.1 Trend Filters

4.1.1 Moving Average

When trendType = 1 is selected, the indicator uses two moving averages to identify the trend:

  • Fast moving average (maFast): Calculated with the maFlength parameter, which defines the number of periods.
  • Slow moving average (maSlow): Calculated with the maSLength parameter.

If the fast moving average (maFast) is above the slow moving average (maSlow), it is considered a bullish trend, and an area between the two moving averages is colored in green (RGB: 8, 153, 129). Otherwise, it is considered a bearish trend, and the area is colored in red (RGB: 242, 54, 69).


This code draws the area between the two moving averages using colors to indicate whether the trend is bullish or bearish, enhancing trend visualization on the chart.

4.1.2 Supertrend

With trendType = 2, the Supertrend indicator is activated, which uses the ATR (Average True Range) to calculate trend bands:

  • Upper band (up): Calculated by subtracting the ATR multiplied by the adjustment factor (factor) from the bar’s high.
  • Lower band (dn): Calculated by adding the ATR multiplied by the factor to the bar’s low.

The Supertrend follows the price action, adjusting dynamically according to volatility. If the current price crosses above the upper band, it is considered a bullish trend, while crossing below the lower band indicates a bearish trend.

Here, the indicator colors the area between the Supertrend line and the close price to visualize the prevailing trend.

4.1.3 Donchian Channels

When trendType = 3 is selected, the indicator uses Donchian Channels, which plot the highest and lowest values over a period defined by the length parameter to determine whether there is a bullish or bearish trend.


If the price is reaching new highs, the indicator detects a bullish trend; if it is reaching new lows, it detects a bearish trend. Like the other trend filters, the area between the Donchian channel lines is colored using green for bullish trends and red for bearish trends.

4.2 Reversal Pattern Detection

4.2.1 Bullish Reversal

The indicator looks for a bullish reversal pattern based on the last numBars bars. It evaluates whether the price has consistently dropped and has started to reverse. A minimum percentage of bearish bars (defined by minBars) is required to validate the pattern.

If the bullish reversal pattern is confirmed, and the overall trend is also bullish, the indicator generates a buy signal.

4.2.2 Bearish Reversal

The process for detecting a bearish reversal is similar, but this time the indicator looks for a series of bullish bars followed by a reversal to the downside.

If the bearish reversal pattern is confirmed and the overall trend is bearish, a sell signal is generated.

4.3 Visual Signals on the Chart

When a bullish or bearish reversal is confirmed, the indicator plots the corresponding signals on the chart, along with lines and rectangles highlighting key support and resistance levels.

  • Bullish Signals:
  • Bearish Signals:

5. Conclusion

The N Reversal Detector is a versatile and comprehensive indicator designed to detect both bullish and bearish reversals using a combination of trend filters and price patterns. This indicator allows traders to adapt their analysis to different market conditions, whether the market is trending or range-bound.

Key features of the indicator include:

  • Trend Filters: Moving averages, Supertrend, and Donchian Channels, allowing traders to adjust trend detection based on their preferences.
  • Reversal Pattern Detection: Identifies potential trend changes based on customizable settings that analyze recent bar behavior.
  • Flexibility: The indicator is highly configurable, allowing users to adjust parameters like moving average lengths, ATR periods, and trend filters to optimize it for their strategy.
  • Clear Visual Signals: Buy and sell signals are clearly displayed on the chart, helping traders make quick and accurate decisions.

In summary, the N Reversal Detector is a powerful tool for traders seeking to identify entry and exit points based on potential trend reversals, and who require flexibility to tailor the indicator to various market conditions.

Share this

Risk disclosure:

No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.

ProRealTime ITF files and other attachments : How to import ITF files into ProRealTime platform?

PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials

  1. mortezaali14 • 41 days ago #

    Bonjour, qu’est-ce qu’un fichier itf ? Comment ça marche ?

  2. mortezaali14 • 41 days ago #

    Hola, ¿qué es un archivo itf? ¿Cómo funciona?

avatar
Register or

Likes

avatar
Related users ' posts
robertogozzi I suggest that you open a new topic in the ProScreener support forum. Thank you.
massimo.g. questo screener si può usare anche sul mercato Azinario ?
robertogozzi Like my screener https://www.prorealcode.com/prorealtime-market-screeners/abcd-pattern-scree...
aldtrading Thanks for your work. I'm using V11 and nothing is drawn on the chart, I believe this is ...
robertogozzi It works on v10.3, v11 and v12. You are likely to have added it BELOW your chart (like RSI),...
jiddan78 how to convert to afl amibroker ?
Nicolas We do not supply free coding assistance for AFL Amibroker on the website. You can ask for pa...
Ngomsi @ Vonasi, how to use timeframe , 13 minutes ,21 minutes, 34 minutes,et 55 minutes with this...
Wolf I don't know why the indicator does not work for me. It gives me an error about RETURN... ...
sergibilbo Great job thanks!!!
druby I was glancing through the code and noticed that the variable name, Middle' has been used. I...
robert123 hi there, how do you get the images of the knights etc into your code....and is there anywhe...
swapping hello robert123, on this site -> https://fr.piliapp.com/symbol/
Nicolas change the lastline with: RETURN lastsig and check if lastsig change its value with the a...
nectouxg Hello Nicolas, I will try tonight when I get home, just one last question, I trade the DA...
FXtonio Bonjour, j'ai un problème avec le code, il me dit que ce n'est pas correct ligne 26-27-28: ...
Pablo Carmona del Moral hola juanjo, muchas gracias por este screener que nos has compartido. creo que lo voy a util...
Pablo Carmona del Moral para el volumen he cambiado: // Volumen significativo VS=volume>2*(average[10](volume[1...
Juanjo Muchas Gracias Pablo, ...Tengo varios screener, uno lo tengo adaptado para operar intradía, ...
Bhanu Pratap Dear Sir, Can I get MQL4 File for this indicator and last man standing . pls looking forward...
ISTJ_T Hi Nicolas Thanks a lot for the indicator. Trading off the TradingView and have issues wit...
Nicolas Just use ProRealTime and its powerful screener for stocks.
Geronima Ortiz I watched the video three times, but I can not put the npips parameter as a variable. I do...
Geronima Ortiz I think the video is for an old version of prorealtime, the images do not correspond at all ...
Nicolas indicator1 = CALL “PRC_StopReversal”[npips, 1] and define npips in the optimization window ...
FULVIO09 Attualmente non c'è sufficiente volatilità : la condizione "C0 = AverageTrueRange[1500](Clos...
vlongobardo67 Ma io intendevo in backtest ! Scusa non l’ho menzionato.
ciniselloftse salve fulvio .il trading sistem e sempre profittevole?
Nicolas Oui pourquoi pas? :)
claudiofred Bonjour Nicolas, merci encore pour ce super indicateur. se demander s'il est possible d'écr...
Nicolas Screener déjà présent sur le forum ici: https://www.prorealcode.com/topic/indicador-lastmans...
gblast I added this indicator to my pro real time but its not showing up on my candles. Its invisible
Steven Bahia Hi Nicolas - great indicator - is there a way to place a alert when the Oscillator crosses ...
Nicolas Alerts can't be programmed, you have to set them yourself with the Alert tool of the platfor...
Steven Bahia just to add to this would there be a way to establish a entry price from the Oscillator
leonz007 Hi Despair, dont know why after import and add your indicator, it does not go on to the pric...
Nicolas Apply it on the price chart with the wrench at the left upper side of the price chart.
Sydneyhom Hi Despair Thanks for writing the code and for generously making it available to the public...
Francesco78 Hi Pepmartorell, please let's continue the discussion on the forum thread so that we can sha...
Francesco78 Hi Pepmartorell, please let's continue the discussion on the forum thread so that we can sha...
Jusmih1 Hi there, i am looking at your Strategy however when you put in automatic trading mode its ...
wtangsiri Bonjour J'ai importé le fichier ITF en question, mais cela me donne, en bas de l'écran, un...
Nicolas Il faut ajouter l'indicateur sur le graphique du prix.
skuggan89 This is a great indicator, works very well!! Is there any algo based on this indicator that ...
Regan2020 Hi, has anybody update the above code to enable on a 15m or 5m TF?
gigi64 ik heb de code op mijn pro realtime gezet , en bij indicator staat hij erbij maar komt niet ...
gigi64 I have put the code on my pro realtime, and it is on the indicator, but it does not appear o...
Nicolas Thank you for contribution. Please consider that advertising is tolerate as long as you cont...
triss1965@gmail.com  Hi, I cant make it work. And if you doing so much money. Why do you have to sell it? It don...
T-rader Eva... He dosen´t sell anything. He is just a nice guy that want to share on of his strategy...

Top