OPEN-SOURCE SCRIPT
MAVW Trend Angle Strategy

This strategy is developed using the Mavilim indicator. It was chosen specifically because its smooth nature makes it ideal for trend angle analysis. However, this angle logic can also be applied to raw price action or other moving averages.
Overview This script is a Long-Only strategy designed specifically for spot markets (Stocks, Crypto) where short selling is not desired. It utilizes a highly smoothed custom moving average (MAVW - Weighted Moving Average of WMAs) and calculates the geometric angle (slope) of the trend to identify strong momentum and filter out market noise.
Unlike traditional Moving Average crossovers which often lag, this strategy focuses on the steepness of the trend. It aims to enter positions when the trend accelerates upward and exit when the momentum fades or turns downward.
How It Works
MAVW Calculation: The script calculates a complex chain of Weighted Moving Averages (WMAs) to create the "MAVW". This results in a curve that is extremely smooth and resistant to fake-outs compared to a standard SMA or EMA.
Trend Angle (The Core Logic): Instead of looking at raw price action, the script calculates the angle (in degrees) of the MAVW line over a specific lookback period.
Buy Signal: Triggered when the MAVW angle exceeds the Buy Threshold (e.g., > 0.2°). This indicates a strong upward impulse.
Sell (Exit) Signal: Triggered when the MAVW angle drops below the Sell Threshold (e.g., < -0.2°). This indicates a strong downward impulse.
Weak Trend / Flat Market Filter: A unique feature of this strategy is the "Close on Weak Trend" option. If enabled, the strategy will exit the position and go to CASH (Flat) if the trend angle falls between the Buy and Sell thresholds (e.g., between -0.2° and 0.2°). This protects capital during choppy, sideways markets.
Key Features
Long Only: No short selling. Ideal for spot trading and investors.
Angle Filtering: filters out insignificant price movements by measuring the trend's slope.
Sideways Market Protection: Optional setting to exit positions when the market loses direction (Trend Strength becomes "Weak").
Visuals: The MAVW line changes color based on your position status (Green = In Position, Gray = Cash).
Info Panel: Displays the current trend angle and position status in real-time on the chart.
Backtest Range: Includes a date filter to test specific time periods.
Settings & Configuration
MAVW Lengths: Adjust the First and Second lengths to change the sensitivity of the base curve.
Buy Angle Threshold: Minimum angle required to enter a Long position (Default: 0.2). Increase this value to wait for stronger trends.
Sell Angle Threshold: Angle required to hard-exit a position (Default: -0.2).
Close on Weak Trend: If checked (True), the strategy exits to cash when the angle is near zero (sideways market). If unchecked, it holds until a negative trend angle occurs.
Disclaimer This strategy is for educational purposes only. Past performance does not guarantee future results. Always perform your own backtesting before live trading.
Overview This script is a Long-Only strategy designed specifically for spot markets (Stocks, Crypto) where short selling is not desired. It utilizes a highly smoothed custom moving average (MAVW - Weighted Moving Average of WMAs) and calculates the geometric angle (slope) of the trend to identify strong momentum and filter out market noise.
Unlike traditional Moving Average crossovers which often lag, this strategy focuses on the steepness of the trend. It aims to enter positions when the trend accelerates upward and exit when the momentum fades or turns downward.
How It Works
MAVW Calculation: The script calculates a complex chain of Weighted Moving Averages (WMAs) to create the "MAVW". This results in a curve that is extremely smooth and resistant to fake-outs compared to a standard SMA or EMA.
Trend Angle (The Core Logic): Instead of looking at raw price action, the script calculates the angle (in degrees) of the MAVW line over a specific lookback period.
Buy Signal: Triggered when the MAVW angle exceeds the Buy Threshold (e.g., > 0.2°). This indicates a strong upward impulse.
Sell (Exit) Signal: Triggered when the MAVW angle drops below the Sell Threshold (e.g., < -0.2°). This indicates a strong downward impulse.
Weak Trend / Flat Market Filter: A unique feature of this strategy is the "Close on Weak Trend" option. If enabled, the strategy will exit the position and go to CASH (Flat) if the trend angle falls between the Buy and Sell thresholds (e.g., between -0.2° and 0.2°). This protects capital during choppy, sideways markets.
Key Features
Long Only: No short selling. Ideal for spot trading and investors.
Angle Filtering: filters out insignificant price movements by measuring the trend's slope.
Sideways Market Protection: Optional setting to exit positions when the market loses direction (Trend Strength becomes "Weak").
Visuals: The MAVW line changes color based on your position status (Green = In Position, Gray = Cash).
Info Panel: Displays the current trend angle and position status in real-time on the chart.
Backtest Range: Includes a date filter to test specific time periods.
Settings & Configuration
MAVW Lengths: Adjust the First and Second lengths to change the sensitivity of the base curve.
Buy Angle Threshold: Minimum angle required to enter a Long position (Default: 0.2). Increase this value to wait for stronger trends.
Sell Angle Threshold: Angle required to hard-exit a position (Default: -0.2).
Close on Weak Trend: If checked (True), the strategy exits to cash when the angle is near zero (sideways market). If unchecked, it holds until a negative trend angle occurs.
Disclaimer This strategy is for educational purposes only. Past performance does not guarantee future results. Always perform your own backtesting before live trading.
开源脚本
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
免责声明
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
开源脚本
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
免责声明
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.