OPEN-SOURCE SCRIPT

Trend Target Ribbon [BOSWaves]

12 185
Trend Target Ribbon [BOSWaves] - ALMA Conviction Trend Detection with Integrated Structure-Based Position Planning and R-Multiple Target Tracking

Overview

Trend Target Ribbon [BOSWaves] is an ALMA-based trend identification system that combines slope-normalized momentum confirmation with standard deviation band validation to determine trend state, and automatically generates a complete position planning framework on each trend flip including a structure-derived stop loss, up to four R-multiple take profit targets with proximity highlighting, and a risk zone visualization that tracks target hits and stop events throughout the position's active lifecycle.

snapshot

Instead of simply marking trend direction, each trend flip immediately produces a fully structured trade plan anchored to the current bar's close as entry and the recent swing structure as stop loss. Risk is calculated dynamically from the swing extreme within the configured lookback, clamped between ATR-based minimum and maximum bounds, and used to project equally-spaced R-multiple targets that extend forward for the configured projection length. As price develops, targets glow brighter as price approaches them, mark with a checkmark when reached, and the entire position freezes with a historical record when the next trend flip occurs.

This creates a trend system that bridges signal generation and trade planning within a single indicator. The ALMA gradient ribbon communicates conviction intensity through its width and opacity, adapting continuously to the strength of the slope and the distance of price from the baseline. The candle gradient reinforces conviction on every bar. And the position framework provides an immediate, fully calculated trade structure from entry through all targets without requiring manual level calculation on each new trend signal.

Price is therefore evaluated not just for its directional trend state but for its position within a dynamically constructed risk-reward framework that updates automatically with each new trend confirmation.

Conceptual Framework

Trend Target Ribbon is founded on the principle that a trend system should do more than identify direction — it should translate each directional signal into a complete, immediately actionable trade framework where entry, risk, and target levels are derived from measurable market characteristics rather than arbitrary fixed distances.

Traditional trend indicators produce a signal that the trader must then manually convert into a trade plan by selecting entry price, calculating stop placement, and choosing target distances. This framework eliminates that gap by automating the complete transition from signal to trade plan on each flip, using swing structure for stop placement and the resulting risk distance as the universal unit for all target projections. Every parameter of the trade plan is therefore grounded in the instrument's actual price behavior rather than fixed indicator values.

Three core principles guide the design:
  1. Trend confirmation should require simultaneous slope significance and price displacement beyond a standard deviation band, ensuring signals reflect genuine directional momentum rather than minor price oscillations around the ALMA baseline.
  2. The gradient ribbon width and opacity should scale continuously with trend conviction derived from slope magnitude and distance from the ALMA, communicating the strength of the current trend visually rather than switching between binary active and inactive states.
  3. Each trend flip should immediately generate a complete position framework with structure-derived stop loss, R-multiple targets, and active tracking of target proximity and hit status, translating the directional signal into a fully structured trade plan without manual intervention.

This shifts trend analysis from directional signal generation into an integrated signal-to-plan system where every trend confirmation produces both visual conviction context and a calculable trade framework simultaneously.

Theoretical Foundation

The indicator combines Arnaud Legoux Moving Average calculation for trend baseline, standard deviation band construction for displacement confirmation, ATR-normalized slope scoring for momentum significance, conviction scoring from slope and distance for gradient scaling, swing structure lookback for stop loss derivation with ATR clamping, and a multi-array position management system that tracks active and historical positions with target proximity gradients and hit state tracking.

The ALMA provides a low-lag weighted baseline with configurable offset and sigma parameters that control the balance between responsiveness and smoothness. Slope is measured as the ALMA change over the configured bar count normalized by ATR, producing a dimensionless score that reflects momentum strength independently of the instrument's price scale. The trend flip requires slope to exceed the minimum threshold in the signal direction while price simultaneously closes beyond the ALMA plus deviation band, ensuring both momentum and displacement conditions are satisfied. The conviction score combines double-weighted slope with distance-weighted separation, mapping to the gradient transparency of all ribbon fill layers simultaneously.

Four internal systems operate in tandem:
  • ALMA Trend Engine: Calculates the ALMA with configurable length, offset, and sigma, measures the normalized slope over the configured lookback, derives deviation bands for displacement confirmation, and flips trend state when both slope and displacement conditions are simultaneously satisfied.
  • Gradient Ribbon System: Constructs a four-layer ribbon between the ALMA and a deviation-scaled edge line, computing conviction from slope magnitude and price distance, and mapping that conviction to the transparency of each ribbon layer so width and brightness reflect trend momentum quality continuously.
  • Position Planning Engine: On each trend flip, derives stop price from swing structure within the lookback clamped by ATR multipliers, calculates risk distance, projects up to four equidistant R-multiple targets, and creates the complete set of glow-and-core dual-layer lines, risk box, target zones, inter-target bands, and R-multiple labels as a unified position framework.
  • Active Position Tracking System: Monitors each bar for target proximity to apply approach highlighting gradients, records target hit status when price reaches each level, detects stop events from bar extremes, freezes the position visually with historical styling on the next flip, and enforces the maximum visible position count by removing the oldest complete position objects.

This design ensures the trend ribbon communicates conviction quality continuously while the position planning and tracking layers translate each trend event into a fully managed trade framework with real-time progress monitoring.

How It Works

Trend Target Ribbon evaluates price through a sequence of confirmation and planning processes:
  1. ALMA Calculation: The Arnaud Legoux Moving Average is calculated from the selected source over the configured length with the configured offset and sigma parameters, providing a smoothed low-lag baseline.
  2. Slope Measurement: The ALMA change over the configured slope lookback bars is divided by ATR, producing a normalized slope score that measures directional momentum independently of price scale.
  3. Deviation Band Construction: Standard deviation over the deviation length multiplied by the confirmation multiplier produces the upper and lower confirmation bands around the ALMA.
  4. Trend Flip Detection: A bullish flip requires slope above the minimum threshold and close above the upper confirmation band simultaneously. A bearish flip requires slope below the negative threshold and close below the lower confirmation band. Flips are only registered when the new state differs from the current state.
  5. Conviction Scoring: The conviction score combines doubled slope magnitude with distance-weighted separation between price and ALMA, normalized to a 0-1 range that drives ribbon transparency and candle gradient intensity.
  6. Ribbon Rendering: Four ribbon layers render between the ALMA and the deviation-scaled edge, with glow, edge, mid, and ALMA plots filled at conviction-scaled transparencies and broken across flip bars to prevent visual carryover between trend states.
  7. Position Freeze on Flip: When a flip occurs with an active position, all position objects are frozen at the flip bar with faded historical styling, preserving the completed position record on the chart.
  8. Stop Loss Derivation: The swing low over the stop lookback for long positions and swing high for short positions provides the structural stop reference, with the raw risk distance clamped between ATR minimum and ATR maximum bounds.
  9. Target Projection: Up to four targets are placed at equidistant R-multiples above entry for long positions and below for short positions, with inter-target band boxes filling the reward zones between consecutive levels.
  10. Active Tracking: Each bar, target proximity gradients are computed from price distance relative to the approach radius, driving glow and zone transparency. Target hit status is set when price reaches each level and persists with checkmark label addition. Stop hits terminate the position with darkened stop styling.
  11. Position Count Management: When the visible position limit is exceeded on a new flip, the oldest complete position's lines, boxes, and labels are removed from all storage arrays and deleted before the new position objects are created.

Together, these elements form a continuously updating trend conviction visualization with an integrated automated trade planning and tracking system that maintains a rolling history of the most recent positions.

Interpretation

Trend Target Ribbon should be interpreted as a conviction-weighted trend system with an attached automated position management overlay:
  • Bullish Trend State (Green): Active when slope exceeds the minimum threshold upward and close is above the upper deviation band, with the gradient ribbon rendering below the ALMA and candles coloring green with intensity proportional to conviction.
  • Bearish Trend State (Red/Pink): Active when slope exceeds the minimum threshold downward and close is below the lower deviation band, with the gradient ribbon rendering above the ALMA and candles coloring in the bearish color with conviction-scaled intensity.
  • Gradient Ribbon: The filled zone between the ALMA and the deviation-scaled edge communicates conviction through its visual depth. Strong slope and distant price produce a wide, opaque ribbon. Weakening slope or price compressing toward the ALMA produces a narrower, more transparent ribbon.
  • Candle Gradient: Price candles color from a muted version of the trend color at low conviction to full saturation at high conviction, providing a bar-level momentum intensity reading directly on the chart.
  • Entry Line: White core line with trend-colored glow at the flip bar close marks the position entry level, extending forward for the configured projection length.
  • Stop Loss Line: Red glow and core lines below entry for longs and above for shorts mark the structure-derived stop level. The risk box fills the zone between entry and stop.
  • Target Lines (T1 to T4): Green glow and core lines at successive R-multiples from entry mark the sequential take profit levels. Labels display the target number and R multiple.
  • Target Approach Highlighting: As price approaches each target within the configured approach radius, the glow and zone transparency increases progressively, creating a visual brightening effect that draws attention as price nears each level.
  • Target Hit Markers: When price reaches a target level, the line brightens fully, the zone shading intensifies, and the label gains a checkmark suffix, providing a persistent record of which targets were reached during the position.
  • Stop Hit Styling: When price reaches the stop level, the position freezes with stop-specific styling and the stop label receives a checkmark, indicating the position was closed at the stop.
  • Historical Positions: Frozen completed positions remain on the chart with faded styling for the configured number of past positions, providing a visual history of recent trend-triggered trade setups and their outcomes.

Ribbon conviction width, candle gradient, and target hit progression collectively communicate more trend and trade plan context than any element in isolation.

Signal Logic & Visual Cues

Trend Target Ribbon presents two primary trend transition signals that simultaneously trigger complete position framework generation:
  1. Bullish Trend Signal (◆): Green diamond below the bar when both slope and displacement conditions flip bullish, triggering a long position framework with structure-derived stop below entry and up to four equidistant R-multiple targets above.
  2. Bearish Trend Signal (◆): Red diamond above the bar when both slope and displacement conditions flip bearish, triggering a short position framework with structure-derived stop above entry and up to four equidistant R-multiple targets below.

Target proximity highlighting and hit tracking provide continuous secondary context throughout the active position lifecycle, with approach brightening identifying when price is near each target and checkmarks confirming reached levels.

Alert generation covers bullish and bearish trend flip events for systematic monitoring workflows.

Strategy Integration

Trend Target Ribbon fits within ALMA momentum-confirmed trend-following and integrated position management approaches:
  1. Conviction-Filtered Entries: Use the ribbon width and candle gradient at the flip bar as a conviction filter. Flips accompanied by a wide, opaque ribbon and bright candles indicate strong slope and displacement conditions. Flips producing a thin, subtle ribbon suggest borderline confirmation warranting greater caution.
  2. R-Multiple Target Sequencing: Use the automatically generated target sequence as a staged exit framework, planning partial position reductions at each successive target rather than holding for a single fixed level, allowing systematic profit capture while maintaining exposure to larger directional moves.
  3. Structure Stop Awareness: Monitor the stop distance relative to ATR on each new position. Positions where the structural stop requires maximum ATR clamping carry greater uncertainty about the structural validity of the stop level than positions where the structural stop falls naturally within the ATR bounds.
  4. Target Proximity Trading: Use the approach highlighting as a real-time proximity alert for active management decisions, using the brightening glow as a visual cue to prepare for partial exit or tightened stop management as price approaches each target level.
  5. Historical Position Review: Use the retained historical positions as a visual record of the indicator's recent signal behavior on the current instrument and timeframe, assessing whether the configured parameters are producing appropriately sized stops and reachable targets in recent market conditions.
  6. Multi-Timeframe Conviction Alignment: Apply higher-timeframe trend state as a directional bias filter, engaging with lower-timeframe flip signals only when they align with the established higher-timeframe ALMA direction and ribbon state.

Technical Implementation Details
  • Trend Engine: ALMA with configurable length, offset, and sigma; ATR-normalized slope over configurable lookback; standard deviation band displacement confirmation
  • Conviction System: Composite score from doubled slope magnitude and distance-weighted price separation mapped to multi-layer ribbon transparency and candle gradient
  • Position Engine: Swing structure stop derivation with ATR minimum and maximum clamping; equidistant R-multiple target projection; dual-layer glow-and-core line and zone construction
  • Tracking System: Per-bar target proximity gradient computation; hit state persistence with checkmark labels; stop detection from bar extremes; flip-triggered position freeze with historical styling
  • History Management: Three independent arrays for lines, boxes, and labels with configurable maximum position count enforced by oldest-first bulk removal
  • Visualization: Four-layer gradient ribbon with fill and plot combination; conviction-scaled candle gradient; signal diamonds at flip bars
  • Performance Profile: Real-time execution with object extension and state updates on every bar for the active position, position creation and freeze on flip bars, and bulk cleanup on position count overflow

Optimal Application Parameters

Timeframe Guidance:
  • 1 - 5 min: Intraday trend position planning for scalping with shorter ALMA length and tighter slope minimum for faster trend confirmation and responsive stop placement
  • 15 - 60 min: Session-level trend-following with balanced ALMA length and moderate deviation confirmation for meaningful trend state separation across typical session moves
  • 4H - Daily: Swing-level trend position management with longer ALMA length and higher slope minimum for sustained trend confirmation before position frameworks are generated

Suggested Baseline Configuration:
  • ALMA Length: 34
  • Trend Confirmation: 0.65
  • Minimum Slope: 0.08
  • Stop Structure Lookback: 12
  • Minimum Stop ATR: 0.75
  • Maximum Stop ATR: 3.0
  • Profit Targets: 4
  • Positions On Chart: 4
  • Show Trend Gradient: Enabled
  • Color Candles: Enabled (requires disabling original chart candles in chart settings)
  • Show Position Labels: Enabled

These suggested parameters should be used as a baseline; their effectiveness depends on the instrument's volatility characteristics, swing structure frequency, and preferred signal sensitivity, so fine-tuning is expected for optimal performance.

Parameter Calibration Notes

Use the following adjustments to refine behavior without altering the core logic:
  • Too many trend flips: Increase Minimum Slope to demand stronger directional momentum before a flip registers, or increase Trend Confirmation to require greater price displacement beyond the ALMA before the signal fires.
  • Trend flips too infrequent: Decrease Minimum Slope toward 0.02 for more inclusive momentum qualification, or decrease Trend Confirmation toward 0.2 to allow trend flips on smaller deviations from the ALMA.
  • Stop loss too tight: Increase Minimum Stop ATR to enforce a larger minimum risk distance regardless of structural stop location, providing more breathing room around the entry price.
  • Stop loss too wide: Decrease Maximum Stop ATR to cap the risk distance at a tighter ATR multiple, preventing the structural stop from placing the position at an impractical risk size.
  • Targets too close together: The target spacing is determined by the risk distance. A wider stop produces more widely spaced targets. Reduce Minimum Stop ATR to produce tighter stops and therefore closer-spaced targets on instruments with small typical ranges.
  • Ribbon too wide or narrow: The ribbon width is driven by conviction from slope and distance. On instruments with consistently strong slope the ribbon may appear uniformly wide. Increase Minimum Slope to restrict confirmation to only the strongest momentum conditions, producing more variable ribbon widths.
  • ALMA too laggy or reactive: Increase ALMA Sigma toward 15 for a smoother less reactive baseline, or decrease toward 1 for a more reactive baseline. Adjust ALMA Offset toward 1.0 for greater recent-price weighting or toward 0.0 for more uniform weighting across the length.

Adjustments should be incremental and evaluated across multiple session types rather than isolated market conditions.

Performance Characteristics

High Effectiveness:
  • Trending markets where ALMA slope sustains above the minimum threshold for extended periods, producing well-spaced flip signals with wide conviction ribbons and providing sufficient price extension to reach multiple R-multiple targets
  • Instruments with consistent swing structure where the lookback-derived stop lands at structurally meaningful levels within the ATR bounds rather than being clamped to the minimum or maximum
  • Systematic position management approaches that benefit from automatically generated, consistently structured trade plans rather than manual level calculation on each signal
  • Historical analysis workflows where the retained position history provides a visual record of the indicator's recent signal behavior and target achievement rate on the current instrument

Reduced Effectiveness:
  • Choppy, range-bound markets where slope and displacement conditions flip frequently in alternating directions, generating position frameworks that are immediately frozen by the next flip before targets can be approached
  • Instruments with highly irregular swing structure where the stop lookback consistently finds extremes that place the stop at the ATR maximum, indicating structural stop placement is not meaningful on the instrument
  • Very low volatility environments where the ATR minimum stop dominates, producing artificially tight stops that bear no relationship to actual structural support or resistance levels
    *News-driven or gap-heavy instruments where instantaneous price movements trigger trend flips before the ALMA has developed sufficient slope, producing borderline-conviction signals with thin ribbons
    *Mean-reversion dominant conditions where sustained ALMA slope is rare and the slope requirement suppresses signal frequency to a level that makes the position history sparse and statistically insufficient for pattern assessment

Integration Guidelines
  • Confluence: Combine with BOSWaves structural tools, order flow analysis, or volume indicators to validate trend flip signals and assess whether the position framework aligns with broader market context before managing positions to the automated targets
  • Conviction Assessment: Evaluate ribbon width and candle gradient at each flip bar before committing to the generated position framework. Thin ribbons on borderline signals warrant reduced position sizing relative to the standard risk distance.
  • Stop Clamping Awareness: Note whether the stop loss is at the structural level or at an ATR boundary. ATR-clamped stops indicate the structural extreme was outside the acceptable range and the stop may be placed at a less meaningful price, warranting additional monitoring.
  • Target Achievement Review: Periodically review the historical position records retained on the chart to assess whether the configured target count and projection length are realistic for the instrument and timeframe, adjusting target count or extending projection bars if targets consistently remain unreached within the position lifecycle.
  • State Discipline: Maintain directional bias aligned with the current trend state until the next confirmed flip. Ribbon narrowing and candle gradient dimming within an established trend suggest conviction is weakening but do not constitute a flip signal until both slope and displacement conditions simultaneously satisfy the opposing direction requirements.

Disclaimer

Trend Target Ribbon [BOSWaves] is a professional-grade ALMA trend conviction visualization and integrated position planning tool. It uses slope-normalized momentum confirmation with structure-derived risk management but does not predict future price movements. Results depend on market conditions, instrument trend characteristics, parameter selection, and disciplined execution. BOSWaves recommends deploying this indicator within a broader analytical framework that incorporates order flow context, structural analysis, and comprehensive risk management.

Clause de non-responsabilité

Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.