PINE LIBRARY
Market Structure Report Library [TradingFinder]

🔵Introduction
Market Structure is one of the most fundamental concepts in Price Action and Smart Money theory. In simple terms, it represents how price moves between highs and lows and reveals which phase of the market cycle we are currently in uptrend, downtrend, or transition.
Each structure in the market is formed by a combination of Breaks of Structure (BoS) and Changes of Character (CHoCH):

Since price movement is inherently fractal, market structure can be analyzed on two distinct levels:
🔵Library Purpose
The “Market Structure Report Library” is designed to automatically detect the current market structure type in real time.
Without drawing or displaying any visuals, it analyzes raw price data and returns a series of logical and textual outputs (Return Values) that describe the current structural state of the market.
It provides the following information:
Trend Type:
Structure Type:
Consecutive BoS Counter: Measures trend strength on both Major and Minor levels.
Candle Type: Returns the current candle’s condition(Bullish, Bearish, Doji)
This library is specifically designed for use in Smart Money–based screeners, indicators, and algorithmic strategies.
It can analyze multiple symbols and timeframes simultaneously and return the exact structure type (BoS or CHoCH) and trend direction for each.
🔵Function Outputs
The function MS() processes the price data and returns seven key outputs,
each representing a distinct structural state of the market. These values can be used in indicators, strategies, or multi-symbol screeners.
🟣ExternalTrend
Type: string
Description: Represents the direction of the Major (External) market structure.
Possible values:
This is determined based on the behavior of Major Pivots (swing highs/lows).
🟣InternalTrend
Type: string
Description: Represents the direction of the Minor (Internal) market structure.
Possible values:
🟣M_State
Type: string
Description: Specifies the type of the latest Major Structure event.
Possible values:
🟣m_State
Type: string
Description: Specifies the type of the latest Minor Structure event.
Possible values:
🟣MBoS_Counter
Type: integer
Description: Counts the number of consecutive structural breaks (BoS) in the Major structure.
Useful for evaluating trend strength:
🟣mBoS_Counter
Type: integer
Description: Counts the number of consecutive structural breaks in the Minor structure.
Helps analyze the micro structure of the market on lower timeframes.
Higher value: strong internal trend.
Reset: indicates a minor pullback or reversal.
🟣Candle_Type
Type: string
Description: Represents the type of the current candle.
Possible values:
Pine Script®
Market Structure is one of the most fundamental concepts in Price Action and Smart Money theory. In simple terms, it represents how price moves between highs and lows and reveals which phase of the market cycle we are currently in uptrend, downtrend, or transition.
Each structure in the market is formed by a combination of Breaks of Structure (BoS) and Changes of Character (CHoCH):
- BoS occurs when the market breaks a previous high or low, confirming the continuation of the current trend.
- CHoCH occurs when price breaks in the opposite direction for the first time, signaling a potential trend reversal.
Since price movement is inherently fractal, market structure can be analyzed on two distinct levels:
- Major / External Structure: represents the dominant macro trend.
- Minor / Internal Structure: represents corrective or smaller-scale movements within the larger trend.
🔵Library Purpose
The “Market Structure Report Library” is designed to automatically detect the current market structure type in real time.
Without drawing or displaying any visuals, it analyzes raw price data and returns a series of logical and textual outputs (Return Values) that describe the current structural state of the market.
It provides the following information:
Trend Type:
- External Trend (Major): Up Trend, Down Trend, No Trend
- Internal Trend (Minor): Up Trend, Down Trend, No Trend
Structure Type:
- BoS: Confirms trend continuation
- CHoCH: Indicates a potential trend reversal
Consecutive BoS Counter: Measures trend strength on both Major and Minor levels.
Candle Type: Returns the current candle’s condition(Bullish, Bearish, Doji)
This library is specifically designed for use in Smart Money–based screeners, indicators, and algorithmic strategies.
It can analyze multiple symbols and timeframes simultaneously and return the exact structure type (BoS or CHoCH) and trend direction for each.
🔵Function Outputs
The function MS() processes the price data and returns seven key outputs,
each representing a distinct structural state of the market. These values can be used in indicators, strategies, or multi-symbol screeners.
🟣ExternalTrend
Type: string
Description: Represents the direction of the Major (External) market structure.
Possible values:
- Up Trend
- Down Trend
- No Trend
This is determined based on the behavior of Major Pivots (swing highs/lows).
🟣InternalTrend
Type: string
Description: Represents the direction of the Minor (Internal) market structure.
Possible values:
- Up Trend
- Down Trend
- No Trend
🟣M_State
Type: string
Description: Specifies the type of the latest Major Structure event.
Possible values:
- BoS
- CHoCH
🟣m_State
Type: string
Description: Specifies the type of the latest Minor Structure event.
Possible values:
- BoS
- CHoCH
🟣MBoS_Counter
Type: integer
Description: Counts the number of consecutive structural breaks (BoS) in the Major structure.
Useful for evaluating trend strength:
- Increasing count: indicates trend continuation.
- Reset to zero: typically occurs after a CHoCH.
🟣mBoS_Counter
Type: integer
Description: Counts the number of consecutive structural breaks in the Minor structure.
Helps analyze the micro structure of the market on lower timeframes.
Higher value: strong internal trend.
Reset: indicates a minor pullback or reversal.
🟣Candle_Type
Type: string
Description: Represents the type of the current candle.
Possible values:
- Bullish
- Bearish
- Doji
import TFlab/Market_Structure_Report_Library_TradingFinder/1 as MSS
PP = input.int (5 , 'Market Structure Pivot Period' , group = 'Symbol 1' )
[ExternalTrend, InternalTrend, M_State, m_State, MBoS_Counter, mBoS_Counter, Candle_Type] = MSS.MS(PP)
파인 라이브러리
진정한 트레이딩뷰 정신에 따라 작성자는 이 파인 코드를 오픈 소스 라이브러리로 공개하여 커뮤니티의 다른 파인 프로그래머들이 재사용할 수 있도록 했습니다. 작성자에게 건배! 이 라이브러리는 개인적으로 또는 다른 오픈 소스 출판물에서 사용할 수 있지만, 출판물에서 이 코드를 재사용하는 것은 하우스 룰의 적용을 받습니다.
💎Get instant (Demo/Vip) access here: tradingFinder.com/
✅Get access to our support team: t.me/TFLABS
🧠Free Forex, Crypto & Stock Trading tutorial, same as ICT, Smart Money & Price Action:
tradingfinder.com/education/forex/
✅Get access to our support team: t.me/TFLABS
🧠Free Forex, Crypto & Stock Trading tutorial, same as ICT, Smart Money & Price Action:
tradingfinder.com/education/forex/
면책사항
이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.
파인 라이브러리
진정한 트레이딩뷰 정신에 따라 작성자는 이 파인 코드를 오픈 소스 라이브러리로 공개하여 커뮤니티의 다른 파인 프로그래머들이 재사용할 수 있도록 했습니다. 작성자에게 건배! 이 라이브러리는 개인적으로 또는 다른 오픈 소스 출판물에서 사용할 수 있지만, 출판물에서 이 코드를 재사용하는 것은 하우스 룰의 적용을 받습니다.
💎Get instant (Demo/Vip) access here: tradingFinder.com/
✅Get access to our support team: t.me/TFLABS
🧠Free Forex, Crypto & Stock Trading tutorial, same as ICT, Smart Money & Price Action:
tradingfinder.com/education/forex/
✅Get access to our support team: t.me/TFLABS
🧠Free Forex, Crypto & Stock Trading tutorial, same as ICT, Smart Money & Price Action:
tradingfinder.com/education/forex/
면책사항
이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.