OPEN-SOURCE SCRIPT
Avg Leg Duration (Single Value + Unit)

Avg Leg Duration (Bars + Time)
Avg Leg Duration is a market rhythm and trend behavior indicator designed to measure how long directional price movements typically persist before changing direction.
Instead of focusing only on price magnitude, this indicator analyzes the duration of completed directional "legs" and calculates the average length of recent movements. The objective is to provide insight into the natural pacing and behavior of the current market environment.
Understanding how long trends and directional moves typically last can help traders better evaluate trend maturity, timing expectations, and overall market behavior.
Features:
• Measures completed directional price legs
• Calculates average duration across recent legs
• Customizable averaging period
• Optional ATR-based movement threshold filtering
• Optional directional carry-through for flat bars
• Multiple output units:
• Bars
• Seconds
• Minutes
• Hours
• Days
• Weeks
• Multiple rounding methods:
• None
• Round
• Ceiling
• Floor
• Simple on-chart display showing current average leg duration
Potential use cases:
• Estimate how long directional moves typically last
• Identify potentially extended or immature trends
• Compare market rhythm across different instruments
• Study changing market conditions
• Add timing context to existing strategies
• Evaluate whether price movements are becoming more compressed or extended
Interpretation:
Lower Average Duration
Directional moves are changing more frequently and may indicate increased choppiness or shorter-term market behavior.
Higher Average Duration
Directional moves are persisting longer and may indicate stronger directional behavior or longer trend cycles.
Changing Average Duration
Expanding or contracting values can suggest shifts in market participation and behavior.
Unlike traditional momentum indicators that focus primarily on price movement itself, Avg Leg Duration focuses on the time component of market behavior and attempts to provide additional context into how markets naturally move and cycle.
About TrendGenY Indicators
TrendGenY indicators are built from market experience, creative concepts, and a constant pursuit of unique perspectives. Rather than following conventional ideas, the focus is on uncovering alternative insights and viewing market behavior through different angles to reveal information that traditional tools may overlook and help traders build a more meaningful edge in the market.
Avg Leg Duration is a market rhythm and trend behavior indicator designed to measure how long directional price movements typically persist before changing direction.
Instead of focusing only on price magnitude, this indicator analyzes the duration of completed directional "legs" and calculates the average length of recent movements. The objective is to provide insight into the natural pacing and behavior of the current market environment.
Understanding how long trends and directional moves typically last can help traders better evaluate trend maturity, timing expectations, and overall market behavior.
Features:
• Measures completed directional price legs
• Calculates average duration across recent legs
• Customizable averaging period
• Optional ATR-based movement threshold filtering
• Optional directional carry-through for flat bars
• Multiple output units:
• Bars
• Seconds
• Minutes
• Hours
• Days
• Weeks
• Multiple rounding methods:
• None
• Round
• Ceiling
• Floor
• Simple on-chart display showing current average leg duration
Potential use cases:
• Estimate how long directional moves typically last
• Identify potentially extended or immature trends
• Compare market rhythm across different instruments
• Study changing market conditions
• Add timing context to existing strategies
• Evaluate whether price movements are becoming more compressed or extended
Interpretation:
Lower Average Duration
Directional moves are changing more frequently and may indicate increased choppiness or shorter-term market behavior.
Higher Average Duration
Directional moves are persisting longer and may indicate stronger directional behavior or longer trend cycles.
Changing Average Duration
Expanding or contracting values can suggest shifts in market participation and behavior.
Unlike traditional momentum indicators that focus primarily on price movement itself, Avg Leg Duration focuses on the time component of market behavior and attempts to provide additional context into how markets naturally move and cycle.
About TrendGenY Indicators
TrendGenY indicators are built from market experience, creative concepts, and a constant pursuit of unique perspectives. Rather than following conventional ideas, the focus is on uncovering alternative insights and viewing market behavior through different angles to reveal information that traditional tools may overlook and help traders build a more meaningful edge in the market.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.