OPEN-SOURCE SCRIPT
Friendly Trend

Friendly Trend is an adaptive trend-state indicator designed to answer two practical questions:
Is the current market structure in a confirmed bullish or bearish state?
Do the selected timeframes support the same directional bias?
The indicator simplifies trend reading without reducing the analysis to a basic moving-average crossover.
It combines directional efficiency, normalized price impulse, adaptive smoothing, volatility-sensitive boundaries, confirmation rules, and multi-timeframe context into one coordinated trend model.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🧩 WHAT MAKES FRIENDLY TREND DIFFERENT
Friendly Trend is not a collection of unrelated indicators placed on the same chart.
Every component is part of one connected trend-state engine and has a specific role:
• Directional efficiency determines whether price is moving cleanly in one direction or following a noisy path.
• Normalized impulse measures the direction and strength of recent price movement.
• Adaptive smoothing changes the response speed of the trend basis according to current market conditions.
• The volatility model determines how far price must move before a change can qualify as meaningful.
• Slope, momentum, reversal-buffer, and consecutive-bar conditions confirm a new trend state.
• The multi-timeframe dashboard applies the same complete trend engine independently to each selected timeframe.
• The Overall result converts the individual timeframe states into a weighted directional score.
The script uses established mathematical building blocks such as exponential smoothing, True Range, and absolute price change.
Its original contribution is the way these measurements are connected into one adaptive trend-state architecture rather than used as separate signals or combined into a simple indicator mashup.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🧭 DIRECTIONAL EFFICIENCY
The model compares:
• the net distance price has moved over the selected Length;
• the total path travelled by price during the same period.
A relatively direct move produces a higher efficiency value.
A market that repeatedly moves up and down while making little net progress produces a lower efficiency value.
This measurement helps the trend basis behave differently during:
• clean directional movement;
• noisy consolidation;
• uncertain or transitional conditions.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚡ NORMALIZED IMPULSE
The script separately calculates directional impulse by comparing:
• smoothed signed price changes;
• smoothed absolute price changes.
The result is normalized around zero:
• positive values indicate upward directional pressure;
• negative values indicate downward directional pressure;
• values close to zero indicate weak or balanced movement.
Impulse performs two functions inside the model:
It helps determine how quickly the adaptive basis should react.
It filters trend changes that are not supported by sufficient directional strength.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📈 ADAPTIVE TREND BASIS
Friendly Trend calculates a faster and a slower smoothed price estimate.
It then blends them according to the current combination of:
• directional efficiency;
• absolute normalized impulse.
During clean directional movement, the faster estimate receives more influence, allowing the basis to follow price more closely.
During noisy or indecisive conditions, the slower estimate receives more influence, reducing unnecessary reactions to minor price fluctuations.
The result is a basis that adapts its response speed instead of using one fixed smoothing behavior in every market condition.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🌊 ADAPTIVE TREND ZONE
The trend zone is not based on a fixed percentage or a single ATR value.
Its width combines:
• smoothed True Range;
• the mean absolute distance between price and the adaptive basis;
• the relationship between short-term and long-term volatility;
• the user-defined Band Multiplier.
The short-term versus long-term volatility ratio allows the zone to:
• expand when current market activity increases;
• contract when conditions become calmer;
• adjust to changing volatility regimes.
The volatility ratio is limited to prevent a single extreme movement from distorting the zone for an unnecessarily long period.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ TREND CONFIRMATION
A new bullish state requires all of the following conditions:
• price closes above the upper adaptive boundary;
• the adaptive basis has a positive slope;
• normalized impulse is above the Momentum Filter;
• price clears the additional Reversal Buffer;
• the complete condition remains valid for the selected number of Confirmation Bars.
A bearish state uses the opposite conditions:
• price closes below the lower adaptive boundary;
• the adaptive basis has a negative slope;
• normalized impulse is below the negative Momentum Filter;
• price clears the Reversal Buffer;
• the condition remains valid for the required number of closed bars.
Once a trend is confirmed, the state remains active until the opposite trend passes the same confirmation process.
This persistence is intentional. The trend does not change merely because price returns inside the adaptive zone.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🎨 HOW TO READ THE CHART
🟢 Green basis and green zone
A bullish trend state has been confirmed.
🔴 Red basis and red zone
A bearish trend state has been confirmed.
⚪ Gray basis
The script does not yet have enough confirmed information to assign a bullish or bearish state.
🏷️ Bullish and Bearish labels
A label marks the bar where a new trend state was confirmed.
Labels are not printed on every bar.
The colored zone visualizes the active trend structure. It is not a profit target, stop-loss level, support level, or resistance level.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🕒 MULTI-TIMEFRAME DASHBOARD
The dashboard calculates the complete Friendly Trend engine independently on four configurable timeframes.
The default timeframes are:
• 15 minutes;
• 1 hour;
• 4 hours;
• 1 day.
Each row can display one of three states:
• Bullish
• Bearish
• Neutral
The dashboard does not copy the state of the chart timeframe into the other rows.
Each selected timeframe performs its own calculation using the same adaptive trend model.
Higher-timeframe rows use the state of the most recently completed higher-timeframe bar.
When a selected timeframe is lower than the chart timeframe, the script uses a previously completed lower-timeframe state. This conservative approach introduces a small delay but avoids presenting an unfinished lower-timeframe candle as a confirmed trend.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚖️ OVERALL TREND
The Overall result is not calculated through a simple majority vote.
Each timeframe state is converted into a numerical value:
• Bullish = +1
• Bearish = −1
• Neutral = 0
The values are then weighted according to timeframe duration.
Larger timeframes receive more influence through logarithmic weighting, while smaller timeframes continue to contribute to the result.
The normalized score is classified as:
• Bullish when it is above the Overall Threshold;
• Bearish when it is below the negative Overall Threshold;
• Mixed when it remains between the two thresholds.
This means that two short-term bullish readings do not automatically override bearish conditions on both the 4-hour and daily timeframes.
A Mixed result indicates disagreement or insufficient directional alignment. It is not a separate market direction.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🛠️ HOW TO USE FRIENDLY TREND
Friendly Trend is designed primarily as a directional filter, not as a complete entry system.
One possible workflow is:
1. Identify the broader bias
Use Overall to understand the weighted multi-timeframe direction.
2. Review timeframe alignment
Check the individual dashboard rows to see where agreement or disagreement occurs.
3. Confirm the local trend
Use the trend state on the chart timeframe as the immediate directional context.
4. Apply an independent entry method
Combine the indicator with your own:
• market-structure setup;
• entry conditions;
• stop placement;
• position-sizing rules;
• exit plan.
5. Treat Mixed conditions cautiously
A Mixed result suggests that directional alignment is weak or divided.
Instead of forcing a bullish or bearish interpretation, traders may choose to reduce directional conviction until the timeframes become more aligned.
For example, a trader may prioritize long setups when both the chart state and Overall are Bullish, while avoiding countertrend setups when the higher timeframes remain strongly Bearish.
This is an example of interpretation, not a trading recommendation.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚙️ MAIN SETTINGS
Length
Controls the main observation window used by:
• the directional-efficiency calculation;
• the slower trend basis;
• the long-term volatility model.
Higher values generally produce:
• smoother behavior;
• fewer reactions to short-term changes;
• greater signal delay.
Lower values generally produce:
• faster reactions;
• greater sensitivity to local movement;
• more potential noise.
Band Multiplier
Controls the visible width of the adaptive trend zone.
Higher values:
• require a larger move before the trend can change;
• reduce sensitivity;
• may produce fewer signals.
Lower values:
• make the model more responsive;
• reduce the distance required for a trend change;
• may increase switching during sideways markets.
Confirmation Bars
Defines how many consecutive closed bars must satisfy all trend-change conditions.
A higher value provides stricter confirmation but also delays the signal.
Reversal Buffer
Adds extra distance beyond the displayed adaptive zone before a new trend can be confirmed.
Its purpose is to reduce rapid Bullish and Bearish changes when price repeatedly tests the zone during consolidation.
Momentum Filter
Defines the minimum normalized impulse required for a new trend.
Increasing this value rejects weaker directional moves.
Setting it too high may cause the indicator to miss gradual trends that develop without strong short-term momentum.
Overall Threshold
Controls how much weighted multi-timeframe agreement is required before Overall becomes Bullish or Bearish.
Higher values:
• require stronger agreement;
• produce more Mixed readings.
Lower values:
• classify directional alignment more easily;
• produce Bullish or Bearish results more frequently.
Time Frame 1–4
Define the four periods calculated in the dashboard.
The timeframes can be adjusted to match the user’s trading horizon.
A logical progression from lower to higher periods generally provides the clearest context.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔔 ALERTS
The script includes alert conditions for:
• confirmed bullish trend changes on the chart timeframe;
• confirmed bearish trend changes on the chart timeframe;
• any confirmed chart-timeframe trend change;
• bullish and bearish changes for each dashboard timeframe;
• changes of Overall to Bullish;
• changes of Overall to Bearish.
Chart-timeframe trend alerts are based on confirmed bar-close changes.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⏱️ REAL-TIME AND CONFIRMED-BAR BEHAVIOR
The adaptive basis and visible zone can move while the current price bar is still open because they reflect live market data.
However:
• the chart trend state changes only after the bar is confirmed;
• Bullish and Bearish labels are generated only on confirmed chart bars;
• chart-timeframe trend alerts are based on confirmed state changes;
• higher-timeframe dashboard states use completed higher-timeframe bars;
• lower-timeframe dashboard states are intentionally delayed to avoid using an unfinished lower-timeframe candle as a confirmed signal.
Users should distinguish between:
• the live movement of the adaptive basis and zone;
• a confirmed change of trend state.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠️ LIMITATIONS
Friendly Trend does not predict future prices.
Like any trend-following model, it may react with delay after a sudden reversal.
Confirmation Bars, the Reversal Buffer, and the Momentum Filter intentionally exchange some response speed for greater trend stability.
Sideways markets can still produce alternating trend states, especially when using:
• a short Length;
• a narrow trend zone;
• low confirmation requirements.
The indicator does not guarantee exact entries, exits, profits, or a specific win rate.
It should be used together with independent analysis and appropriate risk-management rules.
Is the current market structure in a confirmed bullish or bearish state?
Do the selected timeframes support the same directional bias?
The indicator simplifies trend reading without reducing the analysis to a basic moving-average crossover.
It combines directional efficiency, normalized price impulse, adaptive smoothing, volatility-sensitive boundaries, confirmation rules, and multi-timeframe context into one coordinated trend model.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🧩 WHAT MAKES FRIENDLY TREND DIFFERENT
Friendly Trend is not a collection of unrelated indicators placed on the same chart.
Every component is part of one connected trend-state engine and has a specific role:
• Directional efficiency determines whether price is moving cleanly in one direction or following a noisy path.
• Normalized impulse measures the direction and strength of recent price movement.
• Adaptive smoothing changes the response speed of the trend basis according to current market conditions.
• The volatility model determines how far price must move before a change can qualify as meaningful.
• Slope, momentum, reversal-buffer, and consecutive-bar conditions confirm a new trend state.
• The multi-timeframe dashboard applies the same complete trend engine independently to each selected timeframe.
• The Overall result converts the individual timeframe states into a weighted directional score.
The script uses established mathematical building blocks such as exponential smoothing, True Range, and absolute price change.
Its original contribution is the way these measurements are connected into one adaptive trend-state architecture rather than used as separate signals or combined into a simple indicator mashup.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🧭 DIRECTIONAL EFFICIENCY
The model compares:
• the net distance price has moved over the selected Length;
• the total path travelled by price during the same period.
A relatively direct move produces a higher efficiency value.
A market that repeatedly moves up and down while making little net progress produces a lower efficiency value.
This measurement helps the trend basis behave differently during:
• clean directional movement;
• noisy consolidation;
• uncertain or transitional conditions.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚡ NORMALIZED IMPULSE
The script separately calculates directional impulse by comparing:
• smoothed signed price changes;
• smoothed absolute price changes.
The result is normalized around zero:
• positive values indicate upward directional pressure;
• negative values indicate downward directional pressure;
• values close to zero indicate weak or balanced movement.
Impulse performs two functions inside the model:
It helps determine how quickly the adaptive basis should react.
It filters trend changes that are not supported by sufficient directional strength.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📈 ADAPTIVE TREND BASIS
Friendly Trend calculates a faster and a slower smoothed price estimate.
It then blends them according to the current combination of:
• directional efficiency;
• absolute normalized impulse.
During clean directional movement, the faster estimate receives more influence, allowing the basis to follow price more closely.
During noisy or indecisive conditions, the slower estimate receives more influence, reducing unnecessary reactions to minor price fluctuations.
The result is a basis that adapts its response speed instead of using one fixed smoothing behavior in every market condition.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🌊 ADAPTIVE TREND ZONE
The trend zone is not based on a fixed percentage or a single ATR value.
Its width combines:
• smoothed True Range;
• the mean absolute distance between price and the adaptive basis;
• the relationship between short-term and long-term volatility;
• the user-defined Band Multiplier.
The short-term versus long-term volatility ratio allows the zone to:
• expand when current market activity increases;
• contract when conditions become calmer;
• adjust to changing volatility regimes.
The volatility ratio is limited to prevent a single extreme movement from distorting the zone for an unnecessarily long period.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ TREND CONFIRMATION
A new bullish state requires all of the following conditions:
• price closes above the upper adaptive boundary;
• the adaptive basis has a positive slope;
• normalized impulse is above the Momentum Filter;
• price clears the additional Reversal Buffer;
• the complete condition remains valid for the selected number of Confirmation Bars.
A bearish state uses the opposite conditions:
• price closes below the lower adaptive boundary;
• the adaptive basis has a negative slope;
• normalized impulse is below the negative Momentum Filter;
• price clears the Reversal Buffer;
• the condition remains valid for the required number of closed bars.
Once a trend is confirmed, the state remains active until the opposite trend passes the same confirmation process.
This persistence is intentional. The trend does not change merely because price returns inside the adaptive zone.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🎨 HOW TO READ THE CHART
🟢 Green basis and green zone
A bullish trend state has been confirmed.
🔴 Red basis and red zone
A bearish trend state has been confirmed.
⚪ Gray basis
The script does not yet have enough confirmed information to assign a bullish or bearish state.
🏷️ Bullish and Bearish labels
A label marks the bar where a new trend state was confirmed.
Labels are not printed on every bar.
The colored zone visualizes the active trend structure. It is not a profit target, stop-loss level, support level, or resistance level.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🕒 MULTI-TIMEFRAME DASHBOARD
The dashboard calculates the complete Friendly Trend engine independently on four configurable timeframes.
The default timeframes are:
• 15 minutes;
• 1 hour;
• 4 hours;
• 1 day.
Each row can display one of three states:
• Bullish
• Bearish
• Neutral
The dashboard does not copy the state of the chart timeframe into the other rows.
Each selected timeframe performs its own calculation using the same adaptive trend model.
Higher-timeframe rows use the state of the most recently completed higher-timeframe bar.
When a selected timeframe is lower than the chart timeframe, the script uses a previously completed lower-timeframe state. This conservative approach introduces a small delay but avoids presenting an unfinished lower-timeframe candle as a confirmed trend.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚖️ OVERALL TREND
The Overall result is not calculated through a simple majority vote.
Each timeframe state is converted into a numerical value:
• Bullish = +1
• Bearish = −1
• Neutral = 0
The values are then weighted according to timeframe duration.
Larger timeframes receive more influence through logarithmic weighting, while smaller timeframes continue to contribute to the result.
The normalized score is classified as:
• Bullish when it is above the Overall Threshold;
• Bearish when it is below the negative Overall Threshold;
• Mixed when it remains between the two thresholds.
This means that two short-term bullish readings do not automatically override bearish conditions on both the 4-hour and daily timeframes.
A Mixed result indicates disagreement or insufficient directional alignment. It is not a separate market direction.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🛠️ HOW TO USE FRIENDLY TREND
Friendly Trend is designed primarily as a directional filter, not as a complete entry system.
One possible workflow is:
1. Identify the broader bias
Use Overall to understand the weighted multi-timeframe direction.
2. Review timeframe alignment
Check the individual dashboard rows to see where agreement or disagreement occurs.
3. Confirm the local trend
Use the trend state on the chart timeframe as the immediate directional context.
4. Apply an independent entry method
Combine the indicator with your own:
• market-structure setup;
• entry conditions;
• stop placement;
• position-sizing rules;
• exit plan.
5. Treat Mixed conditions cautiously
A Mixed result suggests that directional alignment is weak or divided.
Instead of forcing a bullish or bearish interpretation, traders may choose to reduce directional conviction until the timeframes become more aligned.
For example, a trader may prioritize long setups when both the chart state and Overall are Bullish, while avoiding countertrend setups when the higher timeframes remain strongly Bearish.
This is an example of interpretation, not a trading recommendation.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚙️ MAIN SETTINGS
Length
Controls the main observation window used by:
• the directional-efficiency calculation;
• the slower trend basis;
• the long-term volatility model.
Higher values generally produce:
• smoother behavior;
• fewer reactions to short-term changes;
• greater signal delay.
Lower values generally produce:
• faster reactions;
• greater sensitivity to local movement;
• more potential noise.
Band Multiplier
Controls the visible width of the adaptive trend zone.
Higher values:
• require a larger move before the trend can change;
• reduce sensitivity;
• may produce fewer signals.
Lower values:
• make the model more responsive;
• reduce the distance required for a trend change;
• may increase switching during sideways markets.
Confirmation Bars
Defines how many consecutive closed bars must satisfy all trend-change conditions.
A higher value provides stricter confirmation but also delays the signal.
Reversal Buffer
Adds extra distance beyond the displayed adaptive zone before a new trend can be confirmed.
Its purpose is to reduce rapid Bullish and Bearish changes when price repeatedly tests the zone during consolidation.
Momentum Filter
Defines the minimum normalized impulse required for a new trend.
Increasing this value rejects weaker directional moves.
Setting it too high may cause the indicator to miss gradual trends that develop without strong short-term momentum.
Overall Threshold
Controls how much weighted multi-timeframe agreement is required before Overall becomes Bullish or Bearish.
Higher values:
• require stronger agreement;
• produce more Mixed readings.
Lower values:
• classify directional alignment more easily;
• produce Bullish or Bearish results more frequently.
Time Frame 1–4
Define the four periods calculated in the dashboard.
The timeframes can be adjusted to match the user’s trading horizon.
A logical progression from lower to higher periods generally provides the clearest context.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔔 ALERTS
The script includes alert conditions for:
• confirmed bullish trend changes on the chart timeframe;
• confirmed bearish trend changes on the chart timeframe;
• any confirmed chart-timeframe trend change;
• bullish and bearish changes for each dashboard timeframe;
• changes of Overall to Bullish;
• changes of Overall to Bearish.
Chart-timeframe trend alerts are based on confirmed bar-close changes.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⏱️ REAL-TIME AND CONFIRMED-BAR BEHAVIOR
The adaptive basis and visible zone can move while the current price bar is still open because they reflect live market data.
However:
• the chart trend state changes only after the bar is confirmed;
• Bullish and Bearish labels are generated only on confirmed chart bars;
• chart-timeframe trend alerts are based on confirmed state changes;
• higher-timeframe dashboard states use completed higher-timeframe bars;
• lower-timeframe dashboard states are intentionally delayed to avoid using an unfinished lower-timeframe candle as a confirmed signal.
Users should distinguish between:
• the live movement of the adaptive basis and zone;
• a confirmed change of trend state.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠️ LIMITATIONS
Friendly Trend does not predict future prices.
Like any trend-following model, it may react with delay after a sudden reversal.
Confirmation Bars, the Reversal Buffer, and the Momentum Filter intentionally exchange some response speed for greater trend stability.
Sideways markets can still produce alternating trend states, especially when using:
• a short Length;
• a narrow trend zone;
• low confirmation requirements.
The indicator does not guarantee exact entries, exits, profits, or a specific win rate.
It should be used together with independent analysis and appropriate risk-management rules.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Trading tools by MarketStructureLab. Professional indicators, algorithms & market structure logic. Get access: marketstructurelab.com
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Trading tools by MarketStructureLab. Professional indicators, algorithms & market structure logic. Get access: marketstructurelab.com
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.