OPEN-SOURCE SCRIPT
Sequential Pattern Strength [QuantAlgo]

🟢 Overview
The Sequential Pattern Strength indicator measures the power and sustainability of consecutive price movements by tracking unbroken sequences of up or down closes. It incorporates sequence quality assessment, price extension analysis, and automatic exhaustion detection to help traders identify when strong trends are losing momentum and approaching potential reversal or continuation points.

🟢 How It Works
The indicator's key insight lies in its sequential pattern tracking system, where pattern strength is measured by analyzing consecutive price movements and their sustainability:
Pine Script®
The system calculates sequence quality by measuring how "perfect" the consecutive moves are:
Pine Script®
First, it tracks price extension from the sequence starting point:
Pine Script®
Then, pattern exhaustion is identified when sequences become overextended:
Pine Script®
Finally, the pattern strength combines sequence length, quality, and price movement with momentum enhancement:
Pine Script®
This creates a sequence-based momentum indicator that combines consecutive movement analysis with pattern sustainability assessment, providing traders with both directional signals and exhaustion insights for entry/exit timing.

🟢 Signal Interpretation

The Sequential Pattern Strength indicator measures the power and sustainability of consecutive price movements by tracking unbroken sequences of up or down closes. It incorporates sequence quality assessment, price extension analysis, and automatic exhaustion detection to help traders identify when strong trends are losing momentum and approaching potential reversal or continuation points.
🟢 How It Works
The indicator's key insight lies in its sequential pattern tracking system, where pattern strength is measured by analyzing consecutive price movements and their sustainability:
if close > close[1]
upSequence := upSequence + 1
downSequence := 0
else if close < close[1]
downSequence := downSequence + 1
upSequence := 0
The system calculates sequence quality by measuring how "perfect" the consecutive moves are:
perfectMoves = math.max(upSequence, downSequence)
totalMoves = math.abs(bar_index - ta.valuewhen(upSequence == 1 or downSequence == 1, bar_index, 0))
sequenceQuality = totalMoves > 0 ? perfectMoves / totalMoves : 1.0
First, it tracks price extension from the sequence starting point:
priceExtension = (close - sequenceStartPrice) / sequenceStartPrice * 100
Then, pattern exhaustion is identified when sequences become overextended:
isExhausted = math.abs(currentSequence) >= maxSequence or
math.abs(priceExtension) > resetThreshold * math.abs(currentSequence)
Finally, the pattern strength combines sequence length, quality, and price movement with momentum enhancement:
patternStrength = currentSequence * sequenceQuality * (1 + math.abs(priceExtension) / 10)
enhancedSignal = patternStrength + momentum * 10
signal = ta.ema(enhancedSignal, smooth)
This creates a sequence-based momentum indicator that combines consecutive movement analysis with pattern sustainability assessment, providing traders with both directional signals and exhaustion insights for entry/exit timing.
🟢 Signal Interpretation
- Positive Values (Above Zero): Sequential pattern strength indicating bullish momentum with consecutive upward price movements and sustained buying pressure = Long/Buy opportunities
- Negative Values (Below Zero): Sequential pattern strength indicating bearish momentum with consecutive downward price movements and sustained selling pressure = Short/Sell opportunities
- Zero Line Crosses: Pattern transitions between bullish and bearish regimes, indicating potential trend changes or momentum shifts when sequences break
- Upper Threshold Zone: Area above maximum sequence threshold (2x maxSequence) indicating extremely strong bullish patterns approaching exhaustion levels
- Lower Threshold Zone: Area below negative threshold (-2x maxSequence) indicating extremely strong bearish patterns approaching exhaustion levels
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
👉 Access the best tools for trading & investing here (3-day FREE trial): joinquantalgo.com/
📩 DM if you need any custom-built indicators.
📩 DM if you need any custom-built indicators.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
👉 Access the best tools for trading & investing here (3-day FREE trial): joinquantalgo.com/
📩 DM if you need any custom-built indicators.
📩 DM if you need any custom-built indicators.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.