OPEN-SOURCE SCRIPT

Auto-Length Moving Average + Trend Signals (Zeiierman)

Overview
The Auto-Length Moving Average + Trend Signals (Zeiierman) is an easy-to-use indicator designed to help traders dynamically adjust their moving average length based on market conditions. This tool adapts in real-time, expanding and contracting the moving average based on trend strength and momentum shifts.
תמונת-בזק

The indicator smooths out price fluctuations by modifying its length while ensuring responsiveness to new trends. In addition to its adaptive length algorithm, it incorporates trend confirmation signals, helping traders identify potential trend reversals and continuations with greater confidence.
תמונת-בזק

This indicator suits scalpers, swing traders, and trend-following investors who want a self-adjusting moving average that adapts to volatility, momentum, and price action dynamics.
תמונת-בזק

How It Works

Dynamic Moving Average Length
The core feature of this indicator is its ability to automatically adjust the length of the moving average based on trend persistence and market conditions:

  • Expands in strong trends to reduce noise.
  • Contracts in choppy or reversing markets for faster reaction.
  • This allows for a more accurate moving average that aligns with current price dynamics.


Trend Confirmation & Signals
The indicator includes built-in trend detection logic, classifying trends based on market structure. It evaluates trend strength based on consecutive bars and smooths out transitions between bullish, bearish, and neutral conditions.
  • Uptrend: Price is persistently above the adjusted moving average.
  • Downtrend: Price remains below the adjusted moving average.
  • Neutral: Price fluctuates around the moving average, indicating possible consolidation.


Adaptive Trend Smoothing
A smoothing factor is applied to enhance trend readability while minimizing excessive lag. This balances reactivity with stability, making it easier to follow longer-term trends while avoiding false signals.


How to Use

Trend Identification
  • Bullish Trend: The indicator confirms an uptrend when the price consistently stays above the dynamically adjusted moving average.
  • Bearish Trend: A downtrend is recognized when the price remains below the moving average.

תמונת-בזק
תמונת-בזק

Trade Entry & Exit
  • Enter long when the dynamic moving average is green and a trend signal occurs. Exit when the price crosses below the dynamic moving average.
  • Enter short when the dynamic moving average is red and a trend signal occurs. Exit when the price crosses above the dynamic moving average.

תמונת-בזק

Slope-Based Reset
This mode resets the trend counter when the moving average slope changes direction.

Interpretation & Insights
Best for trend-following traders who want to filter out noise and only reset when a clear shift in momentum occurs.
  • Higher slope length (N): More stable trends, fewer resets.
  • Lower slope length (N): More reactive to small price swings, frequent resets.
  • Useful in swing trading to track significant trend reversals.

תמונת-בזק

RSI-Based Reset
The counter resets when the Relative Strength Index (RSI) crosses predefined overbought or oversold levels.

Interpretation & Insights
Best for reversal traders who look for extreme overbought/oversold conditions.
  • High RSI threshold (e.g., 80/20): Fewer resets, only extreme conditions trigger adjustments.
  • Lower RSI threshold (e.g., 60/40): More frequent resets, detecting smaller corrections.
  • Great for detecting exhaustion in trends before potential reversals.

תמונת-בזק

Volume-Based Reset
A reset occurs when current volume significantly exceeds its moving average, signaling a shift in market participation.

Interpretation & Insights
Best for traders who follow institutional activity (high volume often means large players are active).
  • Higher volume SMA length: More stable trends, only resets on massive volume spikes.
  • Lower volume SMA length: More reactive to short-term volume shifts.
  • Useful in identifying breakout conditions and trend acceleration points.

תמונת-בזק

Bollinger Band-Based Reset
A reset occurs when price closes above the upper Bollinger Band or below the lower Bollinger Band, signaling potential overextension.

Interpretation & Insights
Best for traders looking for volatility-based trend shifts.
  • Higher Bollinger Band multiplier (k = 2.5+): Captures only major price extremes.
  • Lower Bollinger Band multiplier (k = 1.5): Resets on moderate volatility changes.
  • Useful for detecting overextensions in strong trends before potential retracements.

תמונת-בזק

MACD-Based Reset
A reset occurs when the MACD line crosses the signal line, indicating a momentum shift.

Interpretation & Insights
Best for momentum traders looking for trend continuation vs. exhaustion signals.
  • Longer MACD lengths (260, 120, 90): Captures major trend shifts.
  • Shorter MACD lengths (10, 5, 3): Reacts quickly to momentum changes.
  • Useful for detecting strong divergences and market shifts.

תמונת-בזק

Stochastic-Based Reset
A reset occurs when Stochastic %K crosses overbought or oversold levels.

Interpretation & Insights
Best for short-term traders looking for fast momentum shifts.
  • Longer Stochastic length: Filters out false signals.
  • Shorter Stochastic length: Captures quick intraday shifts.

תמונת-בזק

CCI-Based Reset
A reset occurs when the Commodity Channel Index (CCI) crosses predefined overbought or oversold levels. The CCI measures the price deviation from its statistical mean, making it a useful tool for detecting overextensions in price action.

Interpretation & Insights
Best for cycle traders who aim to identify overextended price deviations in trending or ranging markets.
  • Higher CCI threshold (e.g., ±200): Detects extreme overbought/oversold conditions before reversals.
  • Lower CCI threshold (e.g., ±10): More sensitive to trend shifts, useful for early signal detection.
  • Ideal for detecting momentum shifts before price reverts to its mean or continues trending strongly.

תמונת-בזק

Momentum-Based Reset
A reset occurs when Momentum (Rate of Change) crosses zero, indicating a potential shift in price direction.

Interpretation & Insights
Best for trend-following traders who want to track acceleration vs. deceleration.
  • Higher momentum length: Captures longer-term shifts.
  • Lower momentum length: More responsive to short-term trend changes.

תמונת-בזק


How to Interpret the Trend Strength Table
The Trend Strength Table provides valuable insights into the current market conditions by tracking how the dynamic moving average is adjusting based on trend persistence. Each metric in the table plays a role in understanding the strength, longevity, and stability of a trend.

Counter Value
  • Represents the current length of trend persistence before a reset occurs.
  • The higher the counter, the longer the current trend has been in place without resetting.
  • When this value reaches the Counter Break Threshold, the moving average resets and contracts to become more reactive.


Example:
  • A low counter value (e.g., 10) suggests a recent trend reset, meaning the market might be changing directions frequently.
  • A high counter value (e.g., 495) means the trend has been ongoing for a long time, indicating strong trend persistence.


Trend Strength
  • Measures how strong the current trend is based on the trend confirmation logic.
  • Higher values indicate stronger trends, while lower values suggest weaker trends or consolidations.
  • This value is dynamic and updates based on price action.


Example:
  • Trend Strength of 760 → Indicates a high-confidence trend.
  • Trend Strength of 50 → Suggests weak price action, possibly a choppy market.


Highest Trend Score
  • Tracks the strongest trend score recorded during the session.
  • Helps traders identify the most dominant trend observed in the timeframe.
  • This metric is useful for analyzing historical trend strength and comparing it with current conditions.


Example:
  • Highest Trend Score = 760 → Suggests that at some point, there was a strong trend in play.
  • If the current trend strength is much lower than this value, it could indicate trend exhaustion.


Average Trend Score
  • This is a rolling average of trend strength across the session.
  • Provides a bigger picture of how the trend strength fluctuates over time.
  • If the average trend score is high, the market has had persistent trends.
  • If it's low, the market may have been choppy or sideways.


Example:
  • Average Trend Score of 147 vs. Current Trend Strength of 760 → Indicates that the current trend is significantly stronger than the historical average, meaning a breakout might be occurring.
  • Average Trend Score of 700+ → Suggests a strong trending market overall.

תמונת-בזק


Settings

Dynamic MA Controls
  • Base MA Length – Sets the starting length of the moving average before dynamic adjustments.
  • Max Dynamic Length – Defines the upper limit for how much the moving average can expand.
  • Trend Confirmation Length – The number of bars required to validate an uptrend or downtrend.


Reset & Adaptive Conditions
  • Reset Condition Type – Choose what triggers the moving average reset (Slope, RSI, Volume, MACD, etc.).
  • Trend Smoothing Factor – Adjusts how smoothly the moving average responds to price changes.



-----------------
Disclaimer

The content provided in my scripts, indicators, ideas, algorithms, and systems is for educational and informational purposes only. It does not constitute financial advice, investment recommendations, or a solicitation to buy or sell any financial instruments. I will not accept liability for any loss or damage, including without limitation any loss of profit, which may arise directly or indirectly from the use of or reliance on such information.

All investments involve risk, and the past performance of a security, industry, sector, market, financial product, trading strategy, backtest, or individual's trading does not guarantee future results or returns. Investors are fully responsible for any investment decisions they make. Such decisions should be based solely on an evaluation of their financial circumstances, investment objectives, risk tolerance, and liquidity needs.

כתב ויתור