OPEN-SOURCE SCRIPT
Trend Momentum (Algionics) - Ribbon Pressure Field

Trend Momentum interprets a 28-line EMA ribbon field as a physical force landscape. It reads what directional pressure price is under, how strong that pressure is, and what the current market state is, all within a single framework.
The ribbon spans periods 20 to 236 in steps of 8. Each line is not a simple EMA. It passes through a multi-stage smoothing kernel:
Pine Script®
The average of EMA and SMA is computed first, then a secondary smoothing pass is applied using a kernel length equal to 8 percent of the original period. This dual-smoothing structure suppresses both the phase lag of a pure EMA and the ripple noise of a pure SMA simultaneously. Because the kernel ratio scales proportionally with the period, short lines and long lines maintain consistent smoothing characteristics across the entire ribbon.
Force Boundary
The histogram plots Bull Force above the zero line and Bear Force below it.
Pine Script®
Bull Force is the distance from price to the bottom edge of the field. Bear Force is the distance from price to the top edge. When price is inside the field, both are active. When price breaks above, Bear Force converges to zero. When price drops below, Bull Force converges to zero.
The space between them defines the force boundary. When the boundary widens, price is moving away from the field edges. When it narrows, price is returning toward the center.
Pine Script®
Where Force Boundary measures raw displacement between price and the field edges, Pressure Ratio measures the internal pressure distribution within the field.
float bp_a = math.max(v001-v020,0)+math.max(v001-v028,0)+math.max(v001-Pine Script®
For each of the 28 lines, the distance from price is measured individually. Lines below price contribute to bull pressure. Lines above contribute to bear pressure. Both sides are summed independently, then the ratio is computed.
This is not a simple count of how many lines are above or below. A line 10 points below price contributes 10 times more bull pressure than a line 1 point below. The ratio reflects both the number of lines favoring each side and how far they are from price.
At 100, every line sits below price. At 0, every line sits above. At 50, the total upward and downward distances are equal.
Pine Script®
The Bias Line sits inside the force boundary. Its position is determined by the pressure ratio.
Pine Script®
It divides the space between Bull Force and Bear Force using the pressure ratio as a positioning weight. A 73 percent bull reading does not place the line at 73 percent of the field. It places the line at 73 percent of the distance between Bear Force and Bull Force at that moment.
The Bias Line responds to two independent inputs: how far the field edges are from price, and how the internal pressure is distributed. The separation between boundary logic and positioning logic is the structural core of this design.
The color follows a gradient based on its position within the force boundary.
Ribbon Overlay
The ribbon draws two boundary lines on the price chart. The upper line marks the highest value across the field. The lower line marks the lowest.
Each boundary changes color independently based on price crossovers. When price crosses above a boundary, it turns bull color. When price crosses below, it turns bear color. The moment both boundaries switch to the same color confirms that price has moved fully to one side of the field.
A gradient fill appears between price and the nearest boundary, fading as price moves away from the edge.
Price Candles
When enabled, candles on the main chart are colored based on where the Bias Line sits within the force boundary.
Pine Script®
The Bias Line position is converted to a scale from minus 1 to plus 1, then mapped to a color gradient. Bear color at the bottom, bull color at the top.
This coloring reflects pressure balance, not price direction. A rising candle with bear coloring means price moved up but field pressure remains tilted to the downside. When candle color and price direction disagree, the field is telling a different story than the bar itself.
Dashboard
BIAS
Displays bull and bear pressure percentages. Each value updates with a directional arrow indicating whether the percentage increased or decreased from the previous bar. A segment bar provides a visual representation of the pressure distribution.
Flow
Tracks whether the dominant pressure is accelerating or decelerating. It compares the current pressure percentage against its own smoothed average.
Pine Script®
The smoothing length is derived as the geometric mean of the ribbon endpoints:
Pine Script®
No arbitrary period. A natural interaction scale derived from the ribbon structure.
When the percentage is above its average, the label reads Rising. When below, Falling. When pressure reaches full saturation, Maxed.
Status
A four-state market condition classifier.
Trend activates when price moves outside the field entirely. Hold activates when the dominant side remains intact but price is inside the field. Weakening activates when the dominant side still leads but its pressure is declining. Reversal Warning activates when price crosses the center of mass to the opposing side.
The state engine uses two mechanisms. A trend latch and a condition matrix.
Pine Script®
The latch sets only when the pressure ratio touches either extreme. It does not reset at any intermediate value. It only changes at the next full saturation on the opposite side. 100 and 0 are mathematical boundaries. 50 is the equilibrium point where upward and downward pressure are equal. There is no arbitrary threshold in this system.
The natural state progression is Trend to Hold to Weakening to Reversal Warning. When states skip steps, for example jumping from Trend directly to Reversal Warning, it signals a sharp shift in pressure. The faster the sequence moves, the less time available to react.
Trend
Confirms the established directional bias. It reads Bull when the last confirmed extreme was at full bullish saturation, and Bear when at full bearish saturation. The direction holds until the opposite extreme is reached.
Note
A one-line contextual summary tied to the active status. Each of the four states has its own message describing the current condition and what to watch for.
Technical Implementation
Ribbon Kernel Structure
Each ribbon line is not a simple EMA. The EMA-SMA average serves as a first-stage compromise between exponential responsiveness and rectangular stability. The secondary kernel, scaled to 8 percent of the input period, applies consistent proportional smoothing across the entire ribbon. Short-period lines receive short kernels. Long-period lines receive long kernels. The noise suppression ratio remains uniform regardless of where a line sits in the ribbon.
Distance-Weighted Pressure Measurement
Conventional ribbon-based indicators measure strength as the count of lines above or below price divided by the total number of lines. This approach treats every line equally. A line barely below price and a line far below price contribute the same.
This engine converts the absolute distance to each line into pressure. A line 10 points below price contributes 10 times more bull pressure than a line 1 point below. Because this distance weighting is embedded in the ratio, the system reads the pressure gradient inside the field, which a simple count cannot capture.
Dual Separation Architecture
Force Boundary and Pressure Ratio are computed independently. Force Boundary measures only the raw displacement between price and the field edges. Pressure Ratio measures only the distance-weighted sum across all 28 individual lines.
The Bias Line is the sole point where these two independent inputs converge. The boundary defines the range of possible positions. The pressure ratio determines the position within that range. A change in one does not affect the calculation of the other.
Latch-Based State Engine
State transitions are driven by mathematical extremes, not arbitrary thresholds. The latch sets only at 100 (all lines below price) or 0 (all lines above price). These are physical limits of the distribution, not chosen values.
50 is the point where the sum of upward distances exactly equals the sum of downward distances. The condition matrix uses only these three structural boundaries: 0, 50, and 100.
Interlocking Constant Architecture
Every parameter in this system branches from a single root:
Pine Script®
From these two constants the 28-line ribbon is defined, and from that ribbon: Force Boundary, Pressure Ratio, Bias Line, Flow smoothing length, and every boundary in the state engine are all derived. The smoothing length used for Flow is the geometric mean of the two endpoints. The state classification boundaries of 0, 50, and 100 derive directly from the mathematical limits of the pressure distribution.
Change one constant and the ribbon structure shifts, the field boundaries move, the pressure distribution recalculates, and every downstream output cascades accordingly.
Settings
Ribbon Overlay:
displays the upper and lower field boundaries on the price chart with color-coded crossover states.
Price Candles:
colors candles on the main chart based on the Bias Line position within the force boundary.
Dashboard:
shows the status panel with BIAS percentages, segment bar, Flow, Status classification, Trend direction, and Note.
Force Boundary:
plots the Bull Force and Bear Force histogram in the indicator pane.
Bias Line:
plots the pressure-weighted position line inside the force boundary.
Position Point:
marks the current Bias position on the last bar.
The ribbon spans periods 20 to 236 in steps of 8. Each line is not a simple EMA. It passes through a multi-stage smoothing kernel:
The average of EMA and SMA is computed first, then a secondary smoothing pass is applied using a kernel length equal to 8 percent of the original period. This dual-smoothing structure suppresses both the phase lag of a pure EMA and the ripple noise of a pure SMA simultaneously. Because the kernel ratio scales proportionally with the period, short lines and long lines maintain consistent smoothing characteristics across the entire ribbon.
Force Boundary
The histogram plots Bull Force above the zero line and Bear Force below it.
Bull Force is the distance from price to the bottom edge of the field. Bear Force is the distance from price to the top edge. When price is inside the field, both are active. When price breaks above, Bear Force converges to zero. When price drops below, Bull Force converges to zero.
The space between them defines the force boundary. When the boundary widens, price is moving away from the field edges. When it narrows, price is returning toward the center.
Where Force Boundary measures raw displacement between price and the field edges, Pressure Ratio measures the internal pressure distribution within the field.
float bp_a = math.max(v001-v020,0)+math.max(v001-v028,0)+math.max(v001-
For each of the 28 lines, the distance from price is measured individually. Lines below price contribute to bull pressure. Lines above contribute to bear pressure. Both sides are summed independently, then the ratio is computed.
This is not a simple count of how many lines are above or below. A line 10 points below price contributes 10 times more bull pressure than a line 1 point below. The ratio reflects both the number of lines favoring each side and how far they are from price.
At 100, every line sits below price. At 0, every line sits above. At 50, the total upward and downward distances are equal.
The Bias Line sits inside the force boundary. Its position is determined by the pressure ratio.
It divides the space between Bull Force and Bear Force using the pressure ratio as a positioning weight. A 73 percent bull reading does not place the line at 73 percent of the field. It places the line at 73 percent of the distance between Bear Force and Bull Force at that moment.
The Bias Line responds to two independent inputs: how far the field edges are from price, and how the internal pressure is distributed. The separation between boundary logic and positioning logic is the structural core of this design.
The color follows a gradient based on its position within the force boundary.
Ribbon Overlay
The ribbon draws two boundary lines on the price chart. The upper line marks the highest value across the field. The lower line marks the lowest.
Each boundary changes color independently based on price crossovers. When price crosses above a boundary, it turns bull color. When price crosses below, it turns bear color. The moment both boundaries switch to the same color confirms that price has moved fully to one side of the field.
A gradient fill appears between price and the nearest boundary, fading as price moves away from the edge.
Price Candles
When enabled, candles on the main chart are colored based on where the Bias Line sits within the force boundary.
The Bias Line position is converted to a scale from minus 1 to plus 1, then mapped to a color gradient. Bear color at the bottom, bull color at the top.
This coloring reflects pressure balance, not price direction. A rising candle with bear coloring means price moved up but field pressure remains tilted to the downside. When candle color and price direction disagree, the field is telling a different story than the bar itself.
Dashboard
BIAS
Displays bull and bear pressure percentages. Each value updates with a directional arrow indicating whether the percentage increased or decreased from the previous bar. A segment bar provides a visual representation of the pressure distribution.
Flow
Tracks whether the dominant pressure is accelerating or decelerating. It compares the current pressure percentage against its own smoothed average.
The smoothing length is derived as the geometric mean of the ribbon endpoints:
No arbitrary period. A natural interaction scale derived from the ribbon structure.
When the percentage is above its average, the label reads Rising. When below, Falling. When pressure reaches full saturation, Maxed.
Status
A four-state market condition classifier.
Trend activates when price moves outside the field entirely. Hold activates when the dominant side remains intact but price is inside the field. Weakening activates when the dominant side still leads but its pressure is declining. Reversal Warning activates when price crosses the center of mass to the opposing side.
The state engine uses two mechanisms. A trend latch and a condition matrix.
The latch sets only when the pressure ratio touches either extreme. It does not reset at any intermediate value. It only changes at the next full saturation on the opposite side. 100 and 0 are mathematical boundaries. 50 is the equilibrium point where upward and downward pressure are equal. There is no arbitrary threshold in this system.
The natural state progression is Trend to Hold to Weakening to Reversal Warning. When states skip steps, for example jumping from Trend directly to Reversal Warning, it signals a sharp shift in pressure. The faster the sequence moves, the less time available to react.
Trend
Confirms the established directional bias. It reads Bull when the last confirmed extreme was at full bullish saturation, and Bear when at full bearish saturation. The direction holds until the opposite extreme is reached.
Note
A one-line contextual summary tied to the active status. Each of the four states has its own message describing the current condition and what to watch for.
Technical Implementation
Ribbon Kernel Structure
Each ribbon line is not a simple EMA. The EMA-SMA average serves as a first-stage compromise between exponential responsiveness and rectangular stability. The secondary kernel, scaled to 8 percent of the input period, applies consistent proportional smoothing across the entire ribbon. Short-period lines receive short kernels. Long-period lines receive long kernels. The noise suppression ratio remains uniform regardless of where a line sits in the ribbon.
Distance-Weighted Pressure Measurement
Conventional ribbon-based indicators measure strength as the count of lines above or below price divided by the total number of lines. This approach treats every line equally. A line barely below price and a line far below price contribute the same.
This engine converts the absolute distance to each line into pressure. A line 10 points below price contributes 10 times more bull pressure than a line 1 point below. Because this distance weighting is embedded in the ratio, the system reads the pressure gradient inside the field, which a simple count cannot capture.
Dual Separation Architecture
Force Boundary and Pressure Ratio are computed independently. Force Boundary measures only the raw displacement between price and the field edges. Pressure Ratio measures only the distance-weighted sum across all 28 individual lines.
The Bias Line is the sole point where these two independent inputs converge. The boundary defines the range of possible positions. The pressure ratio determines the position within that range. A change in one does not affect the calculation of the other.
Latch-Based State Engine
State transitions are driven by mathematical extremes, not arbitrary thresholds. The latch sets only at 100 (all lines below price) or 0 (all lines above price). These are physical limits of the distribution, not chosen values.
50 is the point where the sum of upward distances exactly equals the sum of downward distances. The condition matrix uses only these three structural boundaries: 0, 50, and 100.
Interlocking Constant Architecture
Every parameter in this system branches from a single root:
From these two constants the 28-line ribbon is defined, and from that ribbon: Force Boundary, Pressure Ratio, Bias Line, Flow smoothing length, and every boundary in the state engine are all derived. The smoothing length used for Flow is the geometric mean of the two endpoints. The state classification boundaries of 0, 50, and 100 derive directly from the mathematical limits of the pressure distribution.
Change one constant and the ribbon structure shifts, the field boundaries move, the pressure distribution recalculates, and every downstream output cascades accordingly.
Settings
Ribbon Overlay:
displays the upper and lower field boundaries on the price chart with color-coded crossover states.
Price Candles:
colors candles on the main chart based on the Bias Line position within the force boundary.
Dashboard:
shows the status panel with BIAS percentages, segment bar, Flow, Status classification, Trend direction, and Note.
Force Boundary:
plots the Bull Force and Bear Force histogram in the indicator pane.
Bias Line:
plots the pressure-weighted position line inside the force boundary.
Position Point:
marks the current Bias position on the last bar.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Calculated, Not Arbitrary.
algionics.com
algionics.com
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Calculated, Not Arbitrary.
algionics.com
algionics.com
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.