OPEN-SOURCE SCRIPT
Linear Regression Market State Index

Standard Deviation Market Structure Indicator
A Comprehensive Multi-Timeframe Market Analysis Tool
🎯 Overview
The Standard Deviation Market Structure (SDMS) indicator is a sophisticated technical analysis tool that integrates multiple proven methodologies to identify market structure, trend direction, and potential reversal zones. By combining price action, statistical analysis, and momentum indicators across multiple timeframes, SDMS provides traders with a comprehensive view of market dynamics.
✨ Key Features
Multi-Timeframe Integration
Primary analysis on current timeframe
1-hour statistical confirmation for support/resistance levels
Order block extension across 500 future bars
Comprehensive Technical Suite
RSI with Deviation Analysis
Dynamic Order Block Detection
Gaussian Filter Channels
Linear Regression with Statistical Bands
Standard deviation to detect price outliers
Directional Movement Index (DMI/ADX)
Bollinger Band % Analysis
Support/Resistance Line System
Visual Clarity
Color-coded signals and zones
Automatic level management
Clean, intuitive display
📊 Core Components Explained
1. Order Block System
What Are Order Blocks?
Order blocks are price zones where institutional activity has occurred, creating future support or resistance levels. SDMS automatically detects these critical zones.
Detection Logic:
Bullish Order Blocks: Form when price breaks above recent highs following bearish candles
Bearish Order Blocks: Form when price breaks below recent lows following bullish candles
Visual Identification:
Green boxes with "BuOB" labels (support zones)
Red boxes with "BeOB" labels (resistance zones)
Each block shows its boundary price for easy reference
Dynamic Management:
Automatically extends 300 bars into the future
Self-cleaning: removes blocks when price breaches their boundaries
Real-time adjustment to changing market structure
2. Statistical Support/Resistance System
How It Works:
SDMS creates support and resistance lines based on statistical extremes confirmed on the 1-hour timeframe.
Trigger Conditions:
Support Lines (Green): Trigger when 1H Bollinger Band % crosses above 0 and bearish momentum subsides.
Resistance Lines (Red): Trigger when 1H Bollinger Band % crosses below 1 and bullish momentum subsides
The Science Behind BB%:
BB% = (Price - Lower Band) / (Upper Band - Lower Band)
BB% <= 0: Price at statistical oversold extreme; also indicated by white candles.
BB% > 1: Price at statistical overbought extreme; also indicated by white candles.
Line Management:
Maximum of 15 active lines
Oldest lines automatically removed
Lines extend across chart for ongoing reference
3. Trend Analysis Suite
Hull Moving Average (HMA):
55-period smoothed trend indicator
Color-coded: Green = bullish, Red = bearish
Visual band shows trend acceleration/deceleration
Gaussian Channel:
Advanced filtering of market noise
Dynamic channel based on true range volatility
Helps identify mean reversion opportunities
Form a yellow band when price is overbought or oversold zones.
Linear Regression System:
Statistical price modeling
Multiple standard deviation bands (up to 3SD)
Regression-based candlestick visualization
Candles turn white when in overbought zones. Yellow candles indicate extremely overbought zones. Blue candles indicate a bullish trend with high volume.
Bearish candles are bluish-purple when volume is high and red when the volume is within normal ranges or low.
4. Momentum & Oscillator Integration
RSI with Deviation Tracking:
21-period RSI with 30-period smoothing
Tracks deviation from moving average based off linear regression
Identifies momentum divergences
Directional Movement Index:
Multi-period DMI/ADX analysis
Used to detect overbought and oversold zones within the indicator calculations.
Combines with RSI for enhanced signals
Momentum confirmation for all entries/exits
🎯 Trading Signals & Alerts
Buy Signals (Yellow "Buy" Labels)
Multi-Condition Confirmation Required:
RSI Oversold Reversal: RSI crosses above 30
Trend Alignment: HMA showing bullish structure
Momentum Confirmation: DMI alignment
Statistical Support: Price at or near support zones
Risk Management: Multiple confirming indicators
Strong Buy Conditions:
Confluence of order block support + BB% support line
Multiple timeframe alignment
Volume confirmation at key levels
Sell Signals (Red/Yellow "Sell" Labels)
Multi-Condition Confirmation Required:
RSI Overbought Reversal: RSI crosses below 70
Trend Exhaustion: HMA showing bearish structure
Momentum Divergence: DMI bearish alignment
Statistical Resistance: Price at or near resistance zones
Timeframe Confirmation: 1H BB% bearish signals
Strong Sell Conditions:
Confluence of order block resistance + BB% resistance line
Multiple timeframe distribution
Volume surge at resistance
Additional Alerts
RSI Divergence Signals: Triangles showing momentum shifts
Extreme Price Alerts: Circles at statistical extremes
Structure Breaks: Visual cues for order block violations
🎨 Visual System Guide
Color Coding System
Green: Bullish conditions, support zones, rising trends
Red: Bearish conditions, resistance zones, falling trends
Blue: Statistical channels, neutral zones
Yellow: Alert conditions, extreme signals
White: Transition zones, neutral signals
Zone Identification
Buying Pressure Zones: Green/blue tinted areas below price or white candles with white dots within the moving average center line
Selling Pressure Zones: Red tinted areas above price with white dots within the moving average center line
Standard Deviation Zones: Gradient colors showing statistical extremes
⚙️ Customization Options
Adjustable Parameters
RSI Settings: Period, oversold/overbought levels, sensitivity
Order Block Detection: Lookback period, ATR multiplier, extension
Statistical Settings: Gaussian filter poles, regression periods
Support/Resistance: Maximum lines, BB% settings
Visual Preferences: Colors, band displays, alert styles
Input Groups
RSI Trading Strategy
Order Block Configuration
Gaussian Channel Settings
Linear Regression Parameters
DMI/ADX Configuration
Bollinger Band % Settings
📈 Practical Trading Applications
For Swing Traders
Identify Key Levels: Use order blocks + BB% lines for entry/exit planning
Trend Confirmation: HMA + Gaussian channel for trend direction
Risk Management: Standard deviation bands for stop placement
Timing Entries: RSI/DMI alignment for optimal entry timing
For Day Traders
Intraday Levels: Order blocks provide immediate S/R for day trading
Momentum Signals: Real-time RSI/DMI signals for quick moves
Statistical Edges: Gaussian channel for mean reversion plays
Breakout Confirmation: Order block breaks with volume
For Position Traders
Higher Timeframe Structure: 1H BB% lines for major levels
Trend Persistence: HMA for long-term trend identification
Accumulation/Distribution Zones: Order blocks show institutional activity
Multi-Timeframe Alignment: Confirmation across timeframes
🔍 How to Use SDMS Effectively
Step 1: Market Structure Assessment
Identify active order blocks (green/red boxes)
Note BB% support/resistance lines (horizontal lines)
Assess HMA and moving average trend direction (color)
Check Gaussian channel position (preferably outside 2SD)
Step 2: Signal Confirmation
Wait for multiple indicator alignment
look for doji candles.
Confirm with green (bullish) or red (bearish) candles
Confirm with volume if available
Check for confluence of levels
Assess risk/reward based on nearby levels
Step 3: Trade Management
Enter at confirmed support/resistance
Place stops beyond opposite levels
Take profits at next statistical level
Monitor for structure changes
Step 4: Risk Management
Use standard deviation bands for volatility assessment
Never risk more than 1-2% per trade
Adjust position size based on confluence strength
Have predefined exit rules
💡 Advanced Strategies
Strategy 1: Confluence Trading
Setup: Order block + BB% line at same level
Entry: Price tests confluence zone with RSI signal
Stop: Beyond the confluence zone
Target: Next statistical level
Strategy 2: Breakout Trading
Setup: Price approaching order block boundary
Entry: Break with volume + RSI/DMI confirmation
Stop: Re-entry into order block
Target: Next BB% line extension
Strategy 3: Mean Reversion
Setup: Price at Gaussian channel extremes
Entry: RSI reversal signal at channel boundary
Stop: Beyond channel extreme
Target: Channel midline or opposite boundary
⚠️ Important Considerations
Best Market Conditions
Trending Markets: Excellent performance in clear trends
Breakout Scenarios: Strong identification of break levels
Range Markets: Works well with defined ranges
Limitations
Choppy Markets: May give false signals in consolidation
News Events: Fundamental shocks can override technical levels
Timeframe Specific: Optimal on 15-minute to daily charts
Risk Management Rules
Always use stops
Never rely on single signals
Consider market context
Adjust for volatility changes
Keep position sizes consistent
🔧 Technical Specifications
Maximum Lines: 500
Maximum Bars Back: 1000
Maximum Boxes: 500
Calculation Efficiency: Optimized for real-time use
🏆 Why SDMS Stands Out
Unique Advantages
Integrated Approach: Combines multiple methodologies into one tool
Self-Adjusting: Automatically adapts to market changes
Multi-Timeframe: Provides both immediate and higher timeframe context
Visual Clarity: Clean, intuitive display of complex data
Professional Grade: Institutional-level analysis accessible to all traders
Educational Value: Learn how different indicators interact
Understand market structure development
See institutional order flow patterns
Develop disciplined trading habits
📚 Learning Resources
Recommended Study Approach
Start Simple: Focus on order blocks and BB% lines first
Add Complexity: Gradually incorporate other indicators
Paper Trade: Practice without risk
Keep Journal: Document setups and outcomes
Review Regularly: Analyze both wins and losses
Common Pitfalls to Avoid
Overtrading: Wait for high-quality setups
Ignoring Context: Consider overall market conditions
Chasing Signals: Enter at planned levels, not after moves
Risk Mismanagement: Always know your risk before entering
Confirmation Bias: Be objective about signals
🤝 Community & Support
Getting the Most from SDMS
Start with Defaults: Use default settings initially
Adjust Gradually: Make small changes as you understand the tool
Combine with Fundamentals: Use for timing within fundamental context
Stay Disciplined: Follow your trading plan consistently
Continuous Improvement
SDMS is designed for continuous learning. As you use the indicator, you'll develop insights into:
Market microstructure
Institutional trading patterns
Statistical edge identification
Risk management optimization
Risk management is more important than signal accuracy
Patience is required for high-quality setups
Success Factors
Discipline: Following your plan consistently
Patience: Waiting for proper setups
Risk Management: Protecting your capital
Continuous Learning: Improving your skills over time
🌟 Final Thoughts
The Standard Deviation Market Structure indicator represents a sophisticated approach to technical analysis, combining the best elements of price action, statistical analysis, and momentum indicators. While powerful, remember that no indicator guarantees success. SDMS is a tool – your skill, discipline, and risk management determine your trading results.
Use SDMS as part of a comprehensive trading plan, combine it with proper risk management, and continue developing your trading skills. The markets are always teaching – stay humble, stay disciplined, and trade well.
Disclaimer: This indicator is for educational purposes only. Past performance does not guarantee future results. Trading involves risk of loss. Always consult with a qualified financial professional before making investment decisions.
A Comprehensive Multi-Timeframe Market Analysis Tool
🎯 Overview
The Standard Deviation Market Structure (SDMS) indicator is a sophisticated technical analysis tool that integrates multiple proven methodologies to identify market structure, trend direction, and potential reversal zones. By combining price action, statistical analysis, and momentum indicators across multiple timeframes, SDMS provides traders with a comprehensive view of market dynamics.
✨ Key Features
Multi-Timeframe Integration
Primary analysis on current timeframe
1-hour statistical confirmation for support/resistance levels
Order block extension across 500 future bars
Comprehensive Technical Suite
RSI with Deviation Analysis
Dynamic Order Block Detection
Gaussian Filter Channels
Linear Regression with Statistical Bands
Standard deviation to detect price outliers
Directional Movement Index (DMI/ADX)
Bollinger Band % Analysis
Support/Resistance Line System
Visual Clarity
Color-coded signals and zones
Automatic level management
Clean, intuitive display
📊 Core Components Explained
1. Order Block System
What Are Order Blocks?
Order blocks are price zones where institutional activity has occurred, creating future support or resistance levels. SDMS automatically detects these critical zones.
Detection Logic:
Bullish Order Blocks: Form when price breaks above recent highs following bearish candles
Bearish Order Blocks: Form when price breaks below recent lows following bullish candles
Visual Identification:
Green boxes with "BuOB" labels (support zones)
Red boxes with "BeOB" labels (resistance zones)
Each block shows its boundary price for easy reference
Dynamic Management:
Automatically extends 300 bars into the future
Self-cleaning: removes blocks when price breaches their boundaries
Real-time adjustment to changing market structure
2. Statistical Support/Resistance System
How It Works:
SDMS creates support and resistance lines based on statistical extremes confirmed on the 1-hour timeframe.
Trigger Conditions:
Support Lines (Green): Trigger when 1H Bollinger Band % crosses above 0 and bearish momentum subsides.
Resistance Lines (Red): Trigger when 1H Bollinger Band % crosses below 1 and bullish momentum subsides
The Science Behind BB%:
BB% = (Price - Lower Band) / (Upper Band - Lower Band)
BB% <= 0: Price at statistical oversold extreme; also indicated by white candles.
BB% > 1: Price at statistical overbought extreme; also indicated by white candles.
Line Management:
Maximum of 15 active lines
Oldest lines automatically removed
Lines extend across chart for ongoing reference
3. Trend Analysis Suite
Hull Moving Average (HMA):
55-period smoothed trend indicator
Color-coded: Green = bullish, Red = bearish
Visual band shows trend acceleration/deceleration
Gaussian Channel:
Advanced filtering of market noise
Dynamic channel based on true range volatility
Helps identify mean reversion opportunities
Form a yellow band when price is overbought or oversold zones.
Linear Regression System:
Statistical price modeling
Multiple standard deviation bands (up to 3SD)
Regression-based candlestick visualization
Candles turn white when in overbought zones. Yellow candles indicate extremely overbought zones. Blue candles indicate a bullish trend with high volume.
Bearish candles are bluish-purple when volume is high and red when the volume is within normal ranges or low.
4. Momentum & Oscillator Integration
RSI with Deviation Tracking:
21-period RSI with 30-period smoothing
Tracks deviation from moving average based off linear regression
Identifies momentum divergences
Directional Movement Index:
Multi-period DMI/ADX analysis
Used to detect overbought and oversold zones within the indicator calculations.
Combines with RSI for enhanced signals
Momentum confirmation for all entries/exits
🎯 Trading Signals & Alerts
Buy Signals (Yellow "Buy" Labels)
Multi-Condition Confirmation Required:
RSI Oversold Reversal: RSI crosses above 30
Trend Alignment: HMA showing bullish structure
Momentum Confirmation: DMI alignment
Statistical Support: Price at or near support zones
Risk Management: Multiple confirming indicators
Strong Buy Conditions:
Confluence of order block support + BB% support line
Multiple timeframe alignment
Volume confirmation at key levels
Sell Signals (Red/Yellow "Sell" Labels)
Multi-Condition Confirmation Required:
RSI Overbought Reversal: RSI crosses below 70
Trend Exhaustion: HMA showing bearish structure
Momentum Divergence: DMI bearish alignment
Statistical Resistance: Price at or near resistance zones
Timeframe Confirmation: 1H BB% bearish signals
Strong Sell Conditions:
Confluence of order block resistance + BB% resistance line
Multiple timeframe distribution
Volume surge at resistance
Additional Alerts
RSI Divergence Signals: Triangles showing momentum shifts
Extreme Price Alerts: Circles at statistical extremes
Structure Breaks: Visual cues for order block violations
🎨 Visual System Guide
Color Coding System
Green: Bullish conditions, support zones, rising trends
Red: Bearish conditions, resistance zones, falling trends
Blue: Statistical channels, neutral zones
Yellow: Alert conditions, extreme signals
White: Transition zones, neutral signals
Zone Identification
Buying Pressure Zones: Green/blue tinted areas below price or white candles with white dots within the moving average center line
Selling Pressure Zones: Red tinted areas above price with white dots within the moving average center line
Standard Deviation Zones: Gradient colors showing statistical extremes
⚙️ Customization Options
Adjustable Parameters
RSI Settings: Period, oversold/overbought levels, sensitivity
Order Block Detection: Lookback period, ATR multiplier, extension
Statistical Settings: Gaussian filter poles, regression periods
Support/Resistance: Maximum lines, BB% settings
Visual Preferences: Colors, band displays, alert styles
Input Groups
RSI Trading Strategy
Order Block Configuration
Gaussian Channel Settings
Linear Regression Parameters
DMI/ADX Configuration
Bollinger Band % Settings
📈 Practical Trading Applications
For Swing Traders
Identify Key Levels: Use order blocks + BB% lines for entry/exit planning
Trend Confirmation: HMA + Gaussian channel for trend direction
Risk Management: Standard deviation bands for stop placement
Timing Entries: RSI/DMI alignment for optimal entry timing
For Day Traders
Intraday Levels: Order blocks provide immediate S/R for day trading
Momentum Signals: Real-time RSI/DMI signals for quick moves
Statistical Edges: Gaussian channel for mean reversion plays
Breakout Confirmation: Order block breaks with volume
For Position Traders
Higher Timeframe Structure: 1H BB% lines for major levels
Trend Persistence: HMA for long-term trend identification
Accumulation/Distribution Zones: Order blocks show institutional activity
Multi-Timeframe Alignment: Confirmation across timeframes
🔍 How to Use SDMS Effectively
Step 1: Market Structure Assessment
Identify active order blocks (green/red boxes)
Note BB% support/resistance lines (horizontal lines)
Assess HMA and moving average trend direction (color)
Check Gaussian channel position (preferably outside 2SD)
Step 2: Signal Confirmation
Wait for multiple indicator alignment
look for doji candles.
Confirm with green (bullish) or red (bearish) candles
Confirm with volume if available
Check for confluence of levels
Assess risk/reward based on nearby levels
Step 3: Trade Management
Enter at confirmed support/resistance
Place stops beyond opposite levels
Take profits at next statistical level
Monitor for structure changes
Step 4: Risk Management
Use standard deviation bands for volatility assessment
Never risk more than 1-2% per trade
Adjust position size based on confluence strength
Have predefined exit rules
💡 Advanced Strategies
Strategy 1: Confluence Trading
Setup: Order block + BB% line at same level
Entry: Price tests confluence zone with RSI signal
Stop: Beyond the confluence zone
Target: Next statistical level
Strategy 2: Breakout Trading
Setup: Price approaching order block boundary
Entry: Break with volume + RSI/DMI confirmation
Stop: Re-entry into order block
Target: Next BB% line extension
Strategy 3: Mean Reversion
Setup: Price at Gaussian channel extremes
Entry: RSI reversal signal at channel boundary
Stop: Beyond channel extreme
Target: Channel midline or opposite boundary
⚠️ Important Considerations
Best Market Conditions
Trending Markets: Excellent performance in clear trends
Breakout Scenarios: Strong identification of break levels
Range Markets: Works well with defined ranges
Limitations
Choppy Markets: May give false signals in consolidation
News Events: Fundamental shocks can override technical levels
Timeframe Specific: Optimal on 15-minute to daily charts
Risk Management Rules
Always use stops
Never rely on single signals
Consider market context
Adjust for volatility changes
Keep position sizes consistent
🔧 Technical Specifications
Maximum Lines: 500
Maximum Bars Back: 1000
Maximum Boxes: 500
Calculation Efficiency: Optimized for real-time use
🏆 Why SDMS Stands Out
Unique Advantages
Integrated Approach: Combines multiple methodologies into one tool
Self-Adjusting: Automatically adapts to market changes
Multi-Timeframe: Provides both immediate and higher timeframe context
Visual Clarity: Clean, intuitive display of complex data
Professional Grade: Institutional-level analysis accessible to all traders
Educational Value: Learn how different indicators interact
Understand market structure development
See institutional order flow patterns
Develop disciplined trading habits
📚 Learning Resources
Recommended Study Approach
Start Simple: Focus on order blocks and BB% lines first
Add Complexity: Gradually incorporate other indicators
Paper Trade: Practice without risk
Keep Journal: Document setups and outcomes
Review Regularly: Analyze both wins and losses
Common Pitfalls to Avoid
Overtrading: Wait for high-quality setups
Ignoring Context: Consider overall market conditions
Chasing Signals: Enter at planned levels, not after moves
Risk Mismanagement: Always know your risk before entering
Confirmation Bias: Be objective about signals
🤝 Community & Support
Getting the Most from SDMS
Start with Defaults: Use default settings initially
Adjust Gradually: Make small changes as you understand the tool
Combine with Fundamentals: Use for timing within fundamental context
Stay Disciplined: Follow your trading plan consistently
Continuous Improvement
SDMS is designed for continuous learning. As you use the indicator, you'll develop insights into:
Market microstructure
Institutional trading patterns
Statistical edge identification
Risk management optimization
Risk management is more important than signal accuracy
Patience is required for high-quality setups
Success Factors
Discipline: Following your plan consistently
Patience: Waiting for proper setups
Risk Management: Protecting your capital
Continuous Learning: Improving your skills over time
🌟 Final Thoughts
The Standard Deviation Market Structure indicator represents a sophisticated approach to technical analysis, combining the best elements of price action, statistical analysis, and momentum indicators. While powerful, remember that no indicator guarantees success. SDMS is a tool – your skill, discipline, and risk management determine your trading results.
Use SDMS as part of a comprehensive trading plan, combine it with proper risk management, and continue developing your trading skills. The markets are always teaching – stay humble, stay disciplined, and trade well.
Disclaimer: This indicator is for educational purposes only. Past performance does not guarantee future results. Trading involves risk of loss. Always consult with a qualified financial professional before making investment decisions.
Open-source script
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.
Disclaimer
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.
Open-source script
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.
Disclaimer
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.