OPEN-SOURCE SCRIPT
Trailing Reversal Trading System [MarkitTick]

💡 The Trailing Reversal Trading System turns one classic, single-variable rule into a complete, rule-based trade workflow on the chart. Price is followed swing by swing: an up swing stays in force until price falls a set percentage from the highest point reached since the swing began, and a down swing stays in force until price rises the same percentage from the lowest point reached. Each confirmed reversal of the swing becomes a potential entry, each entry receives a volatility-based stop and three risk-multiple targets, and every event in the life of a trade, from entry to partial exits to the final close, is drawn on the chart, tracked on a dashboard and available as a structured alert. The goal is to give traders a transparent, mechanical way to follow the dominant swing while ignoring the minor price ripples that do not reach the chosen threshold.
✨ Originality and Utility
The underlying idea, entering long when price rises n percent from a recent pivot low and selling long and selling short when price falls n percent from a recent pivot high, is documented by Robert W. Colby in his Encyclopedia of Technical Market Indicators, where n is the system's only variable. There is no built-in version of this system in Pine Script, and the description in the literature stops at the rule itself. This script builds the rule into a working tool and adds the parts a trader needs to act on it:
● Why these components belong together
The script combines a percentage swing rule, ATR, an exponential moving average on a higher timeframe and the ADX. These are not stacked for their own sake; each answers a different question the base rule leaves open:
The swing engine decides direction and timing, ATR and the pivot decide risk, and the two filters decide whether a given reversal is worth taking. Removing any one of them leaves a question unanswered.
🔬 Methodology and Concepts

• Choosing the price series
The Extremes setting decides which prices define the swing. In High/Low mode, the swing high is tracked on bar highs, the swing low on bar lows, and a reversal is measured on the opposite extreme: an up swing reverses when a bar's low falls the reversal percentage below the swing high, and a down swing reverses when a bar's high rises the reversal percentage above the swing low. In Close mode, pivots and reversals are all measured on closing prices, which ignores intrabar spikes.
Optionally, both series can be smoothed before anything is measured, using a simple, exponential, Wilder (RMA), weighted or Hull moving average of a chosen length. Smoothing removes small, noisy extremes; the trade-off is lag, and with smoothing on, the pivots and the pivot cap on the stop are smoothed values rather than actual bar highs or lows.
• The swing engine
The script keeps a swing direction with three states: no swing yet, up swing, and down swing.
The Reversal Level is then simply the swing high times (1 minus the percentage) during an up swing, or the swing low times (1 plus the percentage) during a down swing. Because the swing high can only rise during an up swing, the Reversal Level only moves up in an up swing, and only moves down in a down swing, which is what makes it a trailing level.
• From reversal to entry
A long signal requires an up reversal, a short signal requires a down reversal, and in both cases the bar must be confirmed (closed). If the higher-timeframe filter is on, a long also requires the previous completed higher-timeframe close to be above its EMA, and a short requires it to be below. If the ADX filter is on, the previous confirmed bar's ADX must be at or above the chosen minimum. A reversal that passes the swing rule but fails a filter opens no trade and is added to the Filtered count.
• Stop and targets
The entry price is the close of the signal bar. For a long, the stop candidate is the entry minus ATR times the SL ATR multiplier; the final stop is the higher of that candidate and the pivot low, so the stop is never placed below the pivot the swing reversed from. For a short, the mirror logic applies with the pivot high. Risk is the distance from entry to stop, and the three targets sit at the entry plus (long) or minus (short) risk times each R multiple.
Before a trade opens, the levels must pass several checks: the ATR must be available, the stop and all targets must be above zero, the risk must be larger than one tick, the stop must be on the correct side of the entry, and the first target must round to a price beyond the entry. A signal that fails any check opens no trade and is added to the Rejected count.
• Managing an open trade
Trade events are checked only on bars after the entry bar:
A new trade replaces the previous one: the old levels are removed and the new set is drawn.
• Lock Signal
When Lock Signal is on, the most recent bar cannot open a new trade and cannot close the current trade on a reversal, so the current signal is frozen on screen. Target and stop events are still tracked, and historical bars are not affected.
🎨 Visual Guide

• Reversal Level line
A step line that shows the price whose touch would reverse the current swing. It is drawn in the Bull colour (teal by default) during an up swing, where it sits below price and trails upward, and in the Bear colour (red by default) during a down swing, where it sits above price and trails downward. The line breaks when the swing direction changes, so each swing has its own segment, and it is absent until the first swing forms.
• Swing Candles
The whole candle, body, wicks and border, is recoloured by swing direction: the Candle Bull colour (teal by default) during an up swing and the Candle Bear colour (red by default) during a down swing. Before the first swing forms, candles keep the chart's own colours. Because these candles are drawn over the chart's candles, the chart's own candle colours are hidden while this is on.
• Trade level lines
When a trade opens, a set of horizontal lines starts at the signal bar:
While the trade is open, the lines extend ten bars past the latest bar; once the trade closes, they stop ten bars after the closing bar, leaving a clear record of where the trade ended.
• Level labels
At the right end of the lines, each level carries a filled label with white text: the stop label marked with a cross and its price, the entry label marked with a play arrow and its price, and the target labels marked with diamond or star markers and their prices. When two targets round to the same tick, they share one label, for example "TP1 / TP2", and the duplicate label is not drawn. When a level is reached, its label text changes to show it was hit, followed by the percentage move from the entry to that level, for example a positive percentage on a target and typically a negative one on the stop.
• Dashboard
A two-column table, placed in the corner chosen in the settings. The header shows "TRTS" with the symbol and timeframe. Rows, from top to bottom:
📖 How to Use

The system is always in a swing but not always in a trade: a reversal that is filtered or rejected still flips the swing, so the candles and Reversal Level may change direction without a trade opening.
● Repainting and data behaviour
Entries, stop exits and reversal exits are only taken on confirmed bars, and their alerts fire at bar close, so they do not change once the bar closes. The higher-timeframe filter reads the previous completed higher-timeframe bar, so it does not use future data. However, on the live, still-forming bar, the swing state is recalculated with every price update: the candle colour, the Reversal Level and the dashboard's swing values can change during the bar and may differ from what remains once the bar closes. Target hits are detected intrabar on a touch of the high or low and can be reported before the bar closes. Treat any swing flip on an unclosed bar as provisional until the bar confirms.
● Alerts
Two kinds of alerts are available.
Entry, stop and reversal messages are sent once per bar at bar close; target messages are sent once per bar when the touch occurs.
⚙️ Inputs and Settings
• Core
• Filters
• Trade Tools
• Visuals and Dashboard
• Alerts
• Colors
Every colour on the chart and the dashboard can be changed: Bull and Bear states, swing candles, stop, entry, targets, label text, the dashboard header, background and text, the three progress-bar colours, and the warning fill.
🔍 Deconstruction of the Underlying Scientific and Academic Framework
• Percentage filters and the separation of signal from noise
The system belongs to the family of swing filters described in technical analysis literature: each high and low is examined, and reversals smaller than a minimum percentage are ignored, so that minor movements, the "ripples" of Dow Theory, are filtered out and only the main swings remain. Point and Figure charting is a long-established example of the same principle. Mathematically, the threshold acts as a non-linear filter: unlike a moving average, it does not average prices but makes a binary decision, either a move is large enough to count or it is discarded. This means the system responds with no averaging lag once the threshold is crossed, but it always gives back exactly the reversal percentage from the extreme before acknowledging a turn.
• Why a percentage, not a fixed price distance
Measuring the reversal as a percentage of the extreme makes the rule scale-invariant: the same setting means the same relative move on a low-priced and a high-priced instrument, and it stays meaningful as one instrument's price changes over time. This reflects the common treatment of price changes in relative or logarithmic terms rather than absolute ones. Note that, because the reference point differs, a fall of n percent from a high and a rise of n percent from a low are not exact mirror images in absolute price.
• The threshold as a trade-off between responsiveness and whipsaw
Any fixed threshold faces a fundamental trade-off. A small threshold detects turns early but is crossed more often by random fluctuations, producing frequent reversals in sideways markets. A large threshold produces fewer false reversals but surrenders a larger portion of each move at both entry and exit. There is no setting that is best in all conditions, which is why the threshold is exposed as the system's single main parameter and why the ADX filter is offered to stand aside when the market lacks directional strength.
• Volatility normalisation of risk
The Average True Range, introduced by J. Welles Wilder, Jr. in 1978, measures how much price typically moves per bar, including gaps, as a Wilder-smoothed average of the true range. Using it for the stop distance ties risk to current volatility: in calm markets the stop sits closer, in volatile markets farther away. Expressing targets as multiples of that risk turns every trade into the same structure in risk units, which makes trades on different instruments and in different volatility regimes comparable. ATR measures volatility only, not direction, and its absolute values cannot be compared across instruments at different price levels.
• Trend strength as a regime filter
The ADX, also from Wilder, measures the strength of a trend on a 0 to 100 scale without regard to its direction, derived from smoothed directional movement relative to the true range. Wilder designed it as a filter to keep traders out of sideways markets. Common readings treat values below about 20 as a weak or absent trend and values above about 25 as a strong one. Because of its heavy smoothing, the ADX lags and needs a long history to settle, so the filter reflects the recent regime rather than the current bar.
• Multi-timeframe confirmation
The higher-timeframe filter applies the idea that a signal aligned with the larger trend is more consistent with the broader context. The exponential moving average weights recent prices more heavily, reducing lag compared with a simple average, and the script compares the previous completed higher-timeframe close with its EMA to define that larger trend without relying on an unfinished higher-timeframe bar.
• Limitations of the framework
The rule assumes that swings large enough to cross the threshold tend to continue for some time. In markets that oscillate within a range roughly the size of the threshold, this assumption fails and the system can reverse repeatedly at a loss. Each exit by reversal gives back the full reversal percentage from the extreme, and stops based on bar closes can exit beyond the stop price. None of the filters remove these properties; they only change which reversals are taken.
● Credits
The trailing reversal rule set and its typical settings follow the Trailing Reversal Trading System as described by Robert W. Colby in The Encyclopedia of Technical Market Indicators. Average True Range and the Directional Movement Index with ADX were developed by J. Welles Wilder, Jr. The Hull Moving Average smoothing option is based on the work of Alan Hull.
⚠️ Disclaimer
All provided scripts and indicators are strictly for educational exploration and must not be interpreted as financial advice or a recommendation to execute trades. We expressly disclaim all liability for any financial losses or damages that may result, directly or indirectly, from the reliance on or application of these tools. Market participation carries inherent risk where past performance never guarantees future returns, leaving all investment decisions and due diligence solely at your own discretion.
✨ Originality and Utility
The underlying idea, entering long when price rises n percent from a recent pivot low and selling long and selling short when price falls n percent from a recent pivot high, is documented by Robert W. Colby in his Encyclopedia of Technical Market Indicators, where n is the system's only variable. There is no built-in version of this system in Pine Script, and the description in the literature stops at the rule itself. This script builds the rule into a working tool and adds the parts a trader needs to act on it:
- A precise, state-based swing engine that tracks the running extreme of the current swing bar by bar, records the pivot each swing reversed from, and resolves the rare case where both reversal conditions appear on the same bar with a defined tie-break rather than an arbitrary choice.
- A live Reversal Level drawn on the chart, so the exact price that would end the current swing is always visible in advance instead of being discovered after the fact.
- A stop that combines two ideas: a distance measured in Average True Range from the entry, capped so it never sits beyond the pivot the swing reversed from. The dashboard states which of the two set the stop on every trade.
- Three targets expressed as multiples of the initial risk, automatically sorted nearest to farthest if they are entered out of order, and merged into a single label when two targets round to the same price.
- Two optional, independent entry filters (a higher-timeframe trend filter and an ADX trend-strength filter) that only gate new entries and never change the swing or the reversal exit.
- Safety checks that refuse to open a trade when the computed levels are invalid, together with counters that report how many reversals were filtered out and how many signals were rejected, so the user can see what the filters and checks are actually doing.
- Structured JSON alert messages for entries, partial exits and full exits, with configurable action words for automation workflows.
● Why these components belong together
The script combines a percentage swing rule, ATR, an exponential moving average on a higher timeframe and the ADX. These are not stacked for their own sake; each answers a different question the base rule leaves open:
- The percentage swing rule answers "which way is the dominant swing, and when has it reversed?" It is the only source of signals and exits.
- ATR answers "how far away should the stop be for current volatility?" A percentage reversal alone gives no sensible stop distance, because the pivot can be very far from the entry after a large move. ATR sizes the stop to the market's typical bar range, and the pivot cap keeps it from sitting beyond the point that defined the swing.
- The higher-timeframe EMA answers "is the larger trend on the same side as this entry?" It lets the user take only reversals aligned with the broader direction.
- The ADX answers "is the market trending at all?" Swing reversal rules suffer in sideways markets, where price can reverse back and forth across the threshold; the ADX filter lets the user stand aside when trend strength is low.
The swing engine decides direction and timing, ATR and the pivot decide risk, and the two filters decide whether a given reversal is worth taking. Removing any one of them leaves a question unanswered.
🔬 Methodology and Concepts
• Choosing the price series
The Extremes setting decides which prices define the swing. In High/Low mode, the swing high is tracked on bar highs, the swing low on bar lows, and a reversal is measured on the opposite extreme: an up swing reverses when a bar's low falls the reversal percentage below the swing high, and a down swing reverses when a bar's high rises the reversal percentage above the swing low. In Close mode, pivots and reversals are all measured on closing prices, which ignores intrabar spikes.
Optionally, both series can be smoothed before anything is measured, using a simple, exponential, Wilder (RMA), weighted or Hull moving average of a chosen length. Smoothing removes small, noisy extremes; the trade-off is lag, and with smoothing on, the pivots and the pivot cap on the stop are smoothed values rather than actual bar highs or lows.
• The swing engine
The script keeps a swing direction with three states: no swing yet, up swing, and down swing.
- While the swing is up (or not yet defined), every new higher value of the high series becomes the new swing high and its bar is recorded.
- While the swing is down (or not yet defined), every new lower value of the low series becomes the new swing low and its bar is recorded.
- An up swing reverses down when the low series reaches or falls below the swing high multiplied by (1 minus the reversal percentage). A down swing reverses up when the high series reaches or rises above the swing low multiplied by (1 plus the reversal percentage).
- A reversal can only be triggered on a bar after the bar that set the extreme, so a single wide bar cannot both set the extreme and reverse from it.
- When the swing reverses up, the swing low it reversed from is stored as the pivot low, and tracking of a new swing high starts from the current bar. When it reverses down, the swing high is stored as the pivot high, and tracking of a new swing low starts from the current bar.
- Before the first swing exists, both an up and a down reversal can qualify on the same bar. The script resolves this by favouring the extreme that was set more recently; if both were set on the same bar, the close relative to the midpoint of the swing high and swing low decides.
The Reversal Level is then simply the swing high times (1 minus the percentage) during an up swing, or the swing low times (1 plus the percentage) during a down swing. Because the swing high can only rise during an up swing, the Reversal Level only moves up in an up swing, and only moves down in a down swing, which is what makes it a trailing level.
• From reversal to entry
A long signal requires an up reversal, a short signal requires a down reversal, and in both cases the bar must be confirmed (closed). If the higher-timeframe filter is on, a long also requires the previous completed higher-timeframe close to be above its EMA, and a short requires it to be below. If the ADX filter is on, the previous confirmed bar's ADX must be at or above the chosen minimum. A reversal that passes the swing rule but fails a filter opens no trade and is added to the Filtered count.
• Stop and targets
The entry price is the close of the signal bar. For a long, the stop candidate is the entry minus ATR times the SL ATR multiplier; the final stop is the higher of that candidate and the pivot low, so the stop is never placed below the pivot the swing reversed from. For a short, the mirror logic applies with the pivot high. Risk is the distance from entry to stop, and the three targets sit at the entry plus (long) or minus (short) risk times each R multiple.
Before a trade opens, the levels must pass several checks: the ATR must be available, the stop and all targets must be above zero, the risk must be larger than one tick, the stop must be on the correct side of the entry, and the first target must round to a price beyond the entry. A signal that fails any check opens no trade and is added to the Rejected count.
• Managing an open trade
Trade events are checked only on bars after the entry bar:
- A target counts as hit when the bar's high (long) or low (short) touches it. TP1 and TP2 are partial exits; TP3 is the final exit.
- The stop counts as hit only when a bar closes beyond it, not when price merely wicks through it. This reduces exits on brief spikes, at the cost of exiting at the close of that bar, which may be beyond the stop price.
- An opposite swing reversal on a confirmed bar closes the trade at that bar's close, whether or not any target was reached. This reversal exit is never filtered: even if the filters block the opposite entry, the current trade still closes.
A new trade replaces the previous one: the old levels are removed and the new set is drawn.
• Lock Signal
When Lock Signal is on, the most recent bar cannot open a new trade and cannot close the current trade on a reversal, so the current signal is frozen on screen. Target and stop events are still tracked, and historical bars are not affected.
🎨 Visual Guide
• Reversal Level line
A step line that shows the price whose touch would reverse the current swing. It is drawn in the Bull colour (teal by default) during an up swing, where it sits below price and trails upward, and in the Bear colour (red by default) during a down swing, where it sits above price and trails downward. The line breaks when the swing direction changes, so each swing has its own segment, and it is absent until the first swing forms.
• Swing Candles
The whole candle, body, wicks and border, is recoloured by swing direction: the Candle Bull colour (teal by default) during an up swing and the Candle Bear colour (red by default) during a down swing. Before the first swing forms, candles keep the chart's own colours. Because these candles are drawn over the chart's candles, the chart's own candle colours are hidden while this is on.
• Trade level lines
When a trade opens, a set of horizontal lines starts at the signal bar:
- Stop line: solid, thicker, in the SL colour (red by default).
- Entry line: dashed, in the Entry colour (blue by default).
- TP1, TP2 and TP3 lines: dashed, in the TP colour (teal by default), with TP1 the most transparent and TP3 fully opaque, so the farthest target reads strongest.
While the trade is open, the lines extend ten bars past the latest bar; once the trade closes, they stop ten bars after the closing bar, leaving a clear record of where the trade ended.
• Level labels
At the right end of the lines, each level carries a filled label with white text: the stop label marked with a cross and its price, the entry label marked with a play arrow and its price, and the target labels marked with diamond or star markers and their prices. When two targets round to the same tick, they share one label, for example "TP1 / TP2", and the duplicate label is not drawn. When a level is reached, its label text changes to show it was hit, followed by the percentage move from the entry to that level, for example a positive percentage on a target and typically a negative one on the stop.
• Dashboard
A two-column table, placed in the corner chosen in the settings. The header shows "TRTS" with the symbol and timeframe. Rows, from top to bottom:
- Lock: ACTIVE in the Bear colour when Lock Signal is on, otherwise OFF.
- Swing: Up, Down, or a dash before the first swing, coloured by direction.
- Reversal % and Extremes: the current settings.
- Swing High and Swing Low: the extreme of the current swing, or the last pivot on the other side.
- Reversal Level: the live reversal price, coloured by swing direction.
- To Reversal: a ten-block progress bar with a percentage, showing how much of the reversal distance price has already covered from the swing extreme. It is teal at 66% and above, amber from 33% to 65%, and red below 33%. A high reading means the swing is close to reversing.
- Signal: Long or Short for the latest trade.
- Status: Open, TP1 Hit, TP2 Hit, TP3 Hit, Stopped or Reversed, with "after TP1" or "after TP2" added when targets were reached before a stop or reversal.
- Entry, Stop, Stop Basis, TP1, TP2, TP3 and Exit: the trade's prices, with Stop Basis stating whether the ATR distance or the pivot cap set the stop.
- Risk: the entry-to-stop distance in price and as a percentage of the entry.
- Targets Hit and Bars Since: progress of the trade and bars since its signal.
- ATR: the current ATR value.
- Filtered and Rejected: running counts of reversals blocked by a filter and signals refused by the safety checks.
- Conditional rows: a warning-filled "Targets" row when the R inputs were out of order and have been sorted; an "HTF Filter" row showing Bull or Bear with the higher timeframe, or "Skipped · below chart TF" when the chosen timeframe is lower than the chart's; an "ADX Filter" row with a progress bar of the previous bar's ADX on a 0 to 100 scale; and a "Smoothing" row showing the method and length.
📖 How to Use
- Choose a Reversal % that suits your timeframe and holding period. Colby's guidance for this system is roughly 1% to 5% for traders and 7% to 15% for investors. Smaller values react sooner and produce more swings; larger values ignore more noise but give back more of each move before reversing.
- Read the swing first. Teal candles and a teal Reversal Level below price mean the up swing is in force; red candles and a red level above price mean the down swing is in force.
- Watch the Reversal Level and the To Reversal bar. As the bar fills toward 100%, price is approaching the level that would end the swing.
- When a reversal confirms at bar close and passes any active filters, the trade levels appear. The entry is the signal bar's close; the stop and targets are fixed at that moment.
- Manage the trade with the levels: TP1 and TP2 are natural places to scale out, TP3 is the final target, a close beyond the stop ends the trade, and an opposite reversal ends it regardless of targets.
- Use the filters when the base rule is too active. The ADX filter helps avoid reversals in quiet, trendless conditions; the higher-timeframe filter keeps entries on the side of the larger trend. Check the Filtered count to see how many reversals each filter is removing.
- If the Rejected count rises, the computed levels are often invalid, for example on very low-priced symbols where the risk falls below one tick, or early in the history before the ATR is available.
The system is always in a swing but not always in a trade: a reversal that is filtered or rejected still flips the swing, so the candles and Reversal Level may change direction without a trade opening.
● Repainting and data behaviour
Entries, stop exits and reversal exits are only taken on confirmed bars, and their alerts fire at bar close, so they do not change once the bar closes. The higher-timeframe filter reads the previous completed higher-timeframe bar, so it does not use future data. However, on the live, still-forming bar, the swing state is recalculated with every price update: the candle colour, the Reversal Level and the dashboard's swing values can change during the bar and may differ from what remains once the bar closes. Target hits are detected intrabar on a touch of the high or low and can be reported before the bar closes. Treat any swing flip on an unclosed bar as provisional until the bar confirms.
● Alerts
Two kinds of alerts are available.
- Named alert conditions: BUY Signal, SELL Signal, TP1 Hit, TP2 Hit, TP3 Hit, Stop Hit and Reversal Close, each with a short fixed message.
- Structured messages, available through an "Any alert() function call" alert: each is a JSON object containing an action word, the ticker, the timeframe and the direction. Entry messages also carry the entry, stop, all three targets and the reversal percentage. TP1 and TP2 messages carry the partial-close action and the target reached. TP3, stop and reversal messages carry the close action, the exit price and the reason for the exit.
Entry, stop and reversal messages are sent once per bar at bar close; target messages are sent once per bar when the touch occurs.
⚙️ Inputs and Settings
• Core
- Reversal %: the move away from the swing extreme that reverses the swing. This is the main control of the whole system.
- Extremes: High/Low measures swings on bar highs and lows; Close measures them on closing prices only.
• Filters
- HTF Filter, HTF TF and HTF EMA Len: turn on the higher-timeframe trend filter, choose its timeframe (it must not be lower than the chart's, or it is skipped), and set the EMA length used on that timeframe.
- ADX Filter, ADX Min and ADX Len: turn on the trend-strength filter, set the minimum ADX, and set the DI and ADX smoothing length.
- Smoothing and Smooth Len: optionally smooth the price series with SMA, EMA, RMA, WMA or HMA before swings are measured, and set the smoothing length.
• Trade Tools
- Lock Signal: freeze the current signal on the latest bar and block new ones.
- SL ATR: the stop distance in multiples of ATR, capped at the pivot the swing reversed from.
- TP1 R, TP2 R and TP3 R: the targets as multiples of the initial risk. Values entered out of order are sorted automatically.
- ATR Len: the ATR length used for the stop distance.
• Visuals and Dashboard
- Reversal Line and Candle Colors: show or hide the Reversal Level and the swing candle colouring.
- Show Dashboard and Position: show or hide the table and choose its corner.
• Alerts
- Long Action, Short Action, Close Long Action, Close Short Action, Partial Close Long Action and Partial Close Short Action: the action words written into the structured alert messages, so they can match whatever the receiving system expects.
• Colors
Every colour on the chart and the dashboard can be changed: Bull and Bear states, swing candles, stop, entry, targets, label text, the dashboard header, background and text, the three progress-bar colours, and the warning fill.
🔍 Deconstruction of the Underlying Scientific and Academic Framework
• Percentage filters and the separation of signal from noise
The system belongs to the family of swing filters described in technical analysis literature: each high and low is examined, and reversals smaller than a minimum percentage are ignored, so that minor movements, the "ripples" of Dow Theory, are filtered out and only the main swings remain. Point and Figure charting is a long-established example of the same principle. Mathematically, the threshold acts as a non-linear filter: unlike a moving average, it does not average prices but makes a binary decision, either a move is large enough to count or it is discarded. This means the system responds with no averaging lag once the threshold is crossed, but it always gives back exactly the reversal percentage from the extreme before acknowledging a turn.
• Why a percentage, not a fixed price distance
Measuring the reversal as a percentage of the extreme makes the rule scale-invariant: the same setting means the same relative move on a low-priced and a high-priced instrument, and it stays meaningful as one instrument's price changes over time. This reflects the common treatment of price changes in relative or logarithmic terms rather than absolute ones. Note that, because the reference point differs, a fall of n percent from a high and a rise of n percent from a low are not exact mirror images in absolute price.
• The threshold as a trade-off between responsiveness and whipsaw
Any fixed threshold faces a fundamental trade-off. A small threshold detects turns early but is crossed more often by random fluctuations, producing frequent reversals in sideways markets. A large threshold produces fewer false reversals but surrenders a larger portion of each move at both entry and exit. There is no setting that is best in all conditions, which is why the threshold is exposed as the system's single main parameter and why the ADX filter is offered to stand aside when the market lacks directional strength.
• Volatility normalisation of risk
The Average True Range, introduced by J. Welles Wilder, Jr. in 1978, measures how much price typically moves per bar, including gaps, as a Wilder-smoothed average of the true range. Using it for the stop distance ties risk to current volatility: in calm markets the stop sits closer, in volatile markets farther away. Expressing targets as multiples of that risk turns every trade into the same structure in risk units, which makes trades on different instruments and in different volatility regimes comparable. ATR measures volatility only, not direction, and its absolute values cannot be compared across instruments at different price levels.
• Trend strength as a regime filter
The ADX, also from Wilder, measures the strength of a trend on a 0 to 100 scale without regard to its direction, derived from smoothed directional movement relative to the true range. Wilder designed it as a filter to keep traders out of sideways markets. Common readings treat values below about 20 as a weak or absent trend and values above about 25 as a strong one. Because of its heavy smoothing, the ADX lags and needs a long history to settle, so the filter reflects the recent regime rather than the current bar.
• Multi-timeframe confirmation
The higher-timeframe filter applies the idea that a signal aligned with the larger trend is more consistent with the broader context. The exponential moving average weights recent prices more heavily, reducing lag compared with a simple average, and the script compares the previous completed higher-timeframe close with its EMA to define that larger trend without relying on an unfinished higher-timeframe bar.
• Limitations of the framework
The rule assumes that swings large enough to cross the threshold tend to continue for some time. In markets that oscillate within a range roughly the size of the threshold, this assumption fails and the system can reverse repeatedly at a loss. Each exit by reversal gives back the full reversal percentage from the extreme, and stops based on bar closes can exit beyond the stop price. None of the filters remove these properties; they only change which reversals are taken.
● Credits
The trailing reversal rule set and its typical settings follow the Trailing Reversal Trading System as described by Robert W. Colby in The Encyclopedia of Technical Market Indicators. Average True Range and the Directional Movement Index with ADX were developed by J. Welles Wilder, Jr. The Hull Moving Average smoothing option is based on the work of Alan Hull.
⚠️ Disclaimer
All provided scripts and indicators are strictly for educational exploration and must not be interpreted as financial advice or a recommendation to execute trades. We expressly disclaim all liability for any financial losses or damages that may result, directly or indirectly, from the reliance on or application of these tools. Market participation carries inherent risk where past performance never guarantees future returns, leaving all investment decisions and due diligence solely at your own discretion.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
💡 Proprietary indicators. Original research. Built by analysts who trade.
📢 Free Telegram: t.me/MarkitTick_Updates
👑 Premium: TradingView Marketplace
📘 Guides: markittick.com
📢 Free Telegram: t.me/MarkitTick_Updates
👑 Premium: TradingView Marketplace
📘 Guides: markittick.com
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
💡 Proprietary indicators. Original research. Built by analysts who trade.
📢 Free Telegram: t.me/MarkitTick_Updates
👑 Premium: TradingView Marketplace
📘 Guides: markittick.com
📢 Free Telegram: t.me/MarkitTick_Updates
👑 Premium: TradingView Marketplace
📘 Guides: markittick.com
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.