OPEN-SOURCE SCRIPT
업데이트됨 Market Structure Shift (MSS) [Sword & Shield]

MARKET STRUCTURE SHIFT (MSS) [SWORD & SHIELD]
A clean and focused indicator for identifying Market Structure Shifts in price action.
════════════════════════════════════════════════════════════════════════════════
WHAT IS MARKET STRUCTURE SHIFT (MSS)?
════════════════════════════════════════════════════════════════════════════════
A Market Structure Shift occurs when price breaks a significant swing high or swing low,
indicating a potential change in market direction. This indicator automatically detects
and plots these key levels.
BULLISH MSS: Price breaks above a previous swing high
BEARISH MSS: Price breaks below a previous swing low
════════════════════════════════════════════════════════════════════════════════
FEATURES
════════════════════════════════════════════════════════════════════════════════
CLEAN DISPLAY
- Shows only the last 2 MSS by default (1 bullish + 1 bearish)
- Keeps charts clean and focused on recent structure
- Automatically removes old MSS when new ones appear
CUSTOMIZABLE DETECTION
- Adjustable swing detection (left/right bars)
- Choose break confirmation method (Close or Wick)
- Fixed-length lines (no infinite extension by default)
SMART FILTERING
- Only plots one MSS per direction until opposite MSS occurs
- Prevents duplicate signals in the same direction
- Clear visual distinction between bullish (blue) and bearish (red)
CLEAN LABELS
- Text labels positioned above lines
- No background tooltips for cleaner appearance
- Color-matched to their respective MSS lines
════════════════════════════════════════════════════════════════════════════════
SETTINGS
════════════════════════════════════════════════════════════════════════════════
SWING DETECTION
- Swing Left Bars (default: 2)
- Swing Right Bars (default: 2)
- Higher values = more significant swings detected
BREAK CONFIRMATION
- Close: MSS confirmed when candle closes beyond level
- Wick: MSS confirmed when wick touches beyond level
DISPLAY OPTIONS
- Show Only Last 2 MSS: ON by default (keeps chart clean)
- Extend lines to the right: OFF by default (fixed-length lines)
- Line bars (when not extended): 50 bars (customizable)
════════════════════════════════════════════════════════════════════════════════
HOW IT WORKS
════════════════════════════════════════════════════════════════════════════════
DETECTION LOGIC
1. Identifies swing highs and swing lows using pivot detection
2. Monitors price action for breaks of these levels
3. Confirms break based on selected method (Close or Wick)
4. Plots MSS line at the broken level
FILTERING LOGIC
- Only one MSS per direction is allowed consecutively
- Example: If bullish MSS appears, no new bullish MSS until bearish MSS occurs
- This prevents multiple signals in trending markets
DISPLAY LOGIC
- When "Show Only Last 2 MSS" is enabled:
• Only the most recent bullish MSS is shown
• Only the most recent bearish MSS is shown
• Old MSS are automatically deleted when new ones appear
- When disabled: All historical MSS remain visible
════════════════════════════════════════════════════════════════════════════════
USAGE EXAMPLES
════════════════════════════════════════════════════════════════════════════════
FOR TREND IDENTIFICATION
- Bullish MSS = Potential uptrend beginning
- Bearish MSS = Potential downtrend beginning
- Use in conjunction with other indicators for confirmation
FOR ENTRY SIGNALS
- Wait for MSS to confirm trend change
- Enter on pullback to MSS level
- Use MSS as support/resistance
FOR SCALPING (Lower Timeframes)
- Swing Left/Right Bars: 2-3 (more sensitive)
- Break Confirmation: Close (more reliable)
- Show Only Last 2 MSS: ON (cleaner charts)
FOR SWING TRADING (Higher Timeframes)
- Swing Left/Right Bars: 5-10 (more significant swings)
- Break Confirmation: Close (avoid false breaks)
- Show Only Last 2 MSS: ON or OFF based on preference
════════════════════════════════════════════════════════════════════════════════
VISUAL DESIGN
════════════════════════════════════════════════════════════════════════════════
LINES
- Dashed style for easy identification
- Blue for bullish MSS
- Red for bearish MSS
- Fixed length (50 bars default) for cleaner appearance
LABELS
- "MSS" text positioned above each line
- No background for clean display
- Color-matched to line color
- Small size to avoid chart clutter
════════════════════════════════════════════════════════════════════════════════
CREDITS & LICENSE
════════════════════════════════════════════════════════════════════════════════
© Sword & Shield
This Pine Script code is subject to the terms of the Mozilla Public License 2.0
mozilla.org/MPL/2.0/
A clean and focused indicator for identifying Market Structure Shifts in price action.
════════════════════════════════════════════════════════════════════════════════
WHAT IS MARKET STRUCTURE SHIFT (MSS)?
════════════════════════════════════════════════════════════════════════════════
A Market Structure Shift occurs when price breaks a significant swing high or swing low,
indicating a potential change in market direction. This indicator automatically detects
and plots these key levels.
BULLISH MSS: Price breaks above a previous swing high
BEARISH MSS: Price breaks below a previous swing low
════════════════════════════════════════════════════════════════════════════════
FEATURES
════════════════════════════════════════════════════════════════════════════════
CLEAN DISPLAY
- Shows only the last 2 MSS by default (1 bullish + 1 bearish)
- Keeps charts clean and focused on recent structure
- Automatically removes old MSS when new ones appear
CUSTOMIZABLE DETECTION
- Adjustable swing detection (left/right bars)
- Choose break confirmation method (Close or Wick)
- Fixed-length lines (no infinite extension by default)
SMART FILTERING
- Only plots one MSS per direction until opposite MSS occurs
- Prevents duplicate signals in the same direction
- Clear visual distinction between bullish (blue) and bearish (red)
CLEAN LABELS
- Text labels positioned above lines
- No background tooltips for cleaner appearance
- Color-matched to their respective MSS lines
════════════════════════════════════════════════════════════════════════════════
SETTINGS
════════════════════════════════════════════════════════════════════════════════
SWING DETECTION
- Swing Left Bars (default: 2)
- Swing Right Bars (default: 2)
- Higher values = more significant swings detected
BREAK CONFIRMATION
- Close: MSS confirmed when candle closes beyond level
- Wick: MSS confirmed when wick touches beyond level
DISPLAY OPTIONS
- Show Only Last 2 MSS: ON by default (keeps chart clean)
- Extend lines to the right: OFF by default (fixed-length lines)
- Line bars (when not extended): 50 bars (customizable)
════════════════════════════════════════════════════════════════════════════════
HOW IT WORKS
════════════════════════════════════════════════════════════════════════════════
DETECTION LOGIC
1. Identifies swing highs and swing lows using pivot detection
2. Monitors price action for breaks of these levels
3. Confirms break based on selected method (Close or Wick)
4. Plots MSS line at the broken level
FILTERING LOGIC
- Only one MSS per direction is allowed consecutively
- Example: If bullish MSS appears, no new bullish MSS until bearish MSS occurs
- This prevents multiple signals in trending markets
DISPLAY LOGIC
- When "Show Only Last 2 MSS" is enabled:
• Only the most recent bullish MSS is shown
• Only the most recent bearish MSS is shown
• Old MSS are automatically deleted when new ones appear
- When disabled: All historical MSS remain visible
════════════════════════════════════════════════════════════════════════════════
USAGE EXAMPLES
════════════════════════════════════════════════════════════════════════════════
FOR TREND IDENTIFICATION
- Bullish MSS = Potential uptrend beginning
- Bearish MSS = Potential downtrend beginning
- Use in conjunction with other indicators for confirmation
FOR ENTRY SIGNALS
- Wait for MSS to confirm trend change
- Enter on pullback to MSS level
- Use MSS as support/resistance
FOR SCALPING (Lower Timeframes)
- Swing Left/Right Bars: 2-3 (more sensitive)
- Break Confirmation: Close (more reliable)
- Show Only Last 2 MSS: ON (cleaner charts)
FOR SWING TRADING (Higher Timeframes)
- Swing Left/Right Bars: 5-10 (more significant swings)
- Break Confirmation: Close (avoid false breaks)
- Show Only Last 2 MSS: ON or OFF based on preference
════════════════════════════════════════════════════════════════════════════════
VISUAL DESIGN
════════════════════════════════════════════════════════════════════════════════
LINES
- Dashed style for easy identification
- Blue for bullish MSS
- Red for bearish MSS
- Fixed length (50 bars default) for cleaner appearance
LABELS
- "MSS" text positioned above each line
- No background for clean display
- Color-matched to line color
- Small size to avoid chart clutter
════════════════════════════════════════════════════════════════════════════════
CREDITS & LICENSE
════════════════════════════════════════════════════════════════════════════════
© Sword & Shield
This Pine Script code is subject to the terms of the Mozilla Public License 2.0
mozilla.org/MPL/2.0/
릴리즈 노트
minor changes오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.