PINE LIBRARY
SMCNexusFactsCoreV2

SMCNexusFactsCoreV2 is an open-source, non-visual Pine Script library that maintains confirmed and bounded Smart Money Concepts market facts for use by importing indicators.
The library provides a stateful market-facts engine for swing structure, BOS, CHoCH, MSS, Fair Value Gaps, Order Blocks, liquidity pools, liquidity sweeps, Premium/Discount context and EMA-based context.
It does not draw chart objects, create inputs, request other timeframes, generate alerts, transmit data, calculate trade recommendations or place orders. The importing indicator supplies all chart series and decides how the returned facts are displayed or used.
ORIGINAL CONCEPT AND PURPOSE
The library maintains one consistent, confirmed market-state model instead of calculating unrelated labels independently.
Confirmed swing points become the shared source for:
• HH, HL, LH and LL classification,
• market bias,
• Break of Structure,
• Change of Character,
• Market Structure Shift,
• buy-side and sell-side liquidity pools,
• Premium and Discount dealing ranges.
Fair Value Gaps and Order Blocks use bounded lifecycle records. The library retains only a limited number of objects for each type and direction, preventing unbounded array growth.
Visual settings are not part of this library. An importing indicator can hide or show its own presentation without changing the underlying facts maintained by Facts Core.
CONFIRMED-ONLY PROCESSING
The importing indicator explicitly tells the library whether the current bar is confirmed.
Canonical state changes occur only when confirmed data is supplied. This includes:
• new swing confirmation,
• BOS or CHoCH confirmation,
• MSS confirmation,
• creation of FVG and Order Block facts,
• zone tests and mitigation,
• liquidity-pool creation and collection,
• sweep confirmation.
The library does not use future chart data, negative visual offsets to rewrite history or hidden lookahead requests.
MARKET STRUCTURE
The stateful swing engine stores the latest and previous confirmed swing highs and lows.
It classifies confirmed swings as:
• HH — Higher High
• HL — Higher Low
• LH — Lower High
• LL — Lower Low
The structure model tracks:
• latest swing prices,
• origin bars,
• swing types,
• current market bias,
• consumed structure levels,
• latest break type and direction,
• latest MSS direction and bar.
BOS AND CHOCH
A confirmed break can require a candle close beyond the structure level, depending on the supplied configuration.
The current market bias and the direction of the broken swing determine whether the event represents continuation or a Change of Character.
The library preserves the confirmed event level, direction, origin and confirmation bar in the returned snapshot.
MARKET STRUCTURE SHIFT
MSS can require:
• a confirmed close through structure,
• a previous opposite bias,
• a displacement candle,
• a minimum ATR-based displacement.
These requirements are provided through FactsConfiguration. The library does not silently relax a missing requirement.
FAIR VALUE GAPS
The library detects bullish and bearish three-candle imbalances from caller-supplied OHLC data.
Optional ATR filtering can require a minimum imbalance size.
Each FVG fact can contain:
• direction,
• upper and lower boundaries,
• origin bar and time,
• confirmation bar,
• mitigation state,
• invalidation state,
• test count,
• fill percentage,
• latest test bar,
• origin volume,
• origin average volume,
• origin Premium/Discount location,
• bounded strength,
• displacement confirmation.
ORDER BLOCKS
Order Block facts are created from a bounded lookback and can require a confirmed BOS or MSS.
The configuration controls whether candle bodies or full candle ranges define the zone.
Each Order Block uses the same auditable lifecycle metadata as an FVG, including origin, tests, fill, mitigation, invalidation, volume, relative volume context, strength and displacement confirmation.
ZONE LIFECYCLE
A zone can be:
• available,
• tested,
• partially filled,
• mitigated,
• invalidated.
The test counter and fill percentage are updated from confirmed interaction with the stored zone boundaries.
The library does not invent missing origin metadata. If a fact cannot be associated with a valid source, the unavailable value remains unavailable.
LIQUIDITY
The library maintains bounded arrays of confirmed swing-high and swing-low liquidity references.
It derives:
• BSL — Buy-Side Liquidity,
• SSL — Sell-Side Liquidity,
• EQH — Equal Highs,
• EQL — Equal Lows.
Equal-level classification uses the supplied ATR-based tolerance rather than exact floating-point equality.
Liquidity metadata includes:
• side and type,
• level,
• origin bar,
• collection state,
• collection time,
• sweep type and level.
A pool origin is preserved only when its price is genuinely associated with the originating swing. The library does not transfer unrelated swing metadata to a new liquidity level.
LIQUIDITY SWEEPS
Depending on configuration, a sweep can require price to move beyond the stored pool and close back inside it.
The returned snapshot distinguishes BSL and SSL sweep facts. A sweep is a confirmed market fact, not a BUY or SELL recommendation.
PREMIUM AND DISCOUNT
The library can build a dealing range from confirmed swing extremes.
The returned context can contain:
• range high,
• range low,
• equilibrium,
• current Premium, Discount or Equilibrium classification.
An unavailable or invalid range remains unavailable rather than using a synthetic fallback.
EMA AND CONTEXT FACTS
The importing indicator supplies the configured fast, medium and slow EMA values together with available higher-timeframe context.
Facts Core returns bounded contextual facts such as:
• EMA trend state,
• price relation to EMA values,
• available higher-timeframe trend and bias context.
The library does not request higher-timeframe data itself. This keeps data ownership and confirmation timing inside the importing indicator.
BOUNDED STATE
The implementation uses explicit limits:
• maximum six zones for each kind and direction,
• maximum eight swing references for each side.
This prevents unlimited state growth and makes runtime behavior predictable.
PUBLIC API
Exported records:
• FactsConfiguration
• ZoneFact
• FactsState
• StructureFacts
• ZoneFacts
• LiquidityFacts
• ContextFacts
• FactsSnapshot
Exported functions:
• contractVersion()
• defaultConfiguration()
• newState()
• advance(...)
• snapshotValid(...)
TYPICAL USAGE
An importing indicator should:
1. Create one persistent FactsState.
2. Create or resolve a FactsConfiguration.
3. Supply confirmed OHLCV, ATR, EMA and available context values to advance().
4. Store the returned state.
5. Read the returned FactsSnapshot.
6. Validate the snapshot with snapshotValid().
7. Present or transport only facts that are actually available.
Conceptual example:
```pine
import AreXoN_/SMCNexusFactsCoreV2/1 as facts
var facts.FactsState state = facts.newState()
facts.FactsConfiguration configuration =
facts.defaultConfiguration()
[stateNext, snapshot] = facts.advance(
state,
configuration,
barstate.isconfirmed,
bar_index,
time,
open,
high,
low,
close,
volume,
atr14,
emaFast,
emaMedium,
emaSlow,
higherTimeframeTrend,
higherTimeframeBias,
localContext)
state := stateNext
bool validSnapshot = facts.snapshotValid(snapshot)
```
The example is conceptual. The exact function signature in the published source is authoritative. Replace the example import with the exact path assigned by PulseWire.
WHY THE CHART IS CLEAN
This is a non-visual market-facts library. It intentionally creates no plots, labels, boxes, lines, tables or chart drawings.
The publication chart is therefore intentionally clean and contains no other indicators or unexplained visual elements. An importing indicator is responsible for visual presentation.
LIMITATIONS
• Facts are based on the chart OHLCV series supplied by the importer.
• Swing confirmation necessarily occurs after the configured right-side bars.
• The library does not provide native bid/ask data, footprint or real order flow.
• Chart volume may be broker tick volume rather than centralized exchange volume.
• It does not verify spread, slippage or broker execution.
• It does not request macroeconomic information.
• It does not produce trading signals or recommendations.
• It does not place, modify or close orders.
• It produces no visual chart output by itself.
Contract version: 1.0.0.
This library is an analytical and software-development component. It is not investment advice, a trading recommendation or an automated trading system.
The library provides a stateful market-facts engine for swing structure, BOS, CHoCH, MSS, Fair Value Gaps, Order Blocks, liquidity pools, liquidity sweeps, Premium/Discount context and EMA-based context.
It does not draw chart objects, create inputs, request other timeframes, generate alerts, transmit data, calculate trade recommendations or place orders. The importing indicator supplies all chart series and decides how the returned facts are displayed or used.
ORIGINAL CONCEPT AND PURPOSE
The library maintains one consistent, confirmed market-state model instead of calculating unrelated labels independently.
Confirmed swing points become the shared source for:
• HH, HL, LH and LL classification,
• market bias,
• Break of Structure,
• Change of Character,
• Market Structure Shift,
• buy-side and sell-side liquidity pools,
• Premium and Discount dealing ranges.
Fair Value Gaps and Order Blocks use bounded lifecycle records. The library retains only a limited number of objects for each type and direction, preventing unbounded array growth.
Visual settings are not part of this library. An importing indicator can hide or show its own presentation without changing the underlying facts maintained by Facts Core.
CONFIRMED-ONLY PROCESSING
The importing indicator explicitly tells the library whether the current bar is confirmed.
Canonical state changes occur only when confirmed data is supplied. This includes:
• new swing confirmation,
• BOS or CHoCH confirmation,
• MSS confirmation,
• creation of FVG and Order Block facts,
• zone tests and mitigation,
• liquidity-pool creation and collection,
• sweep confirmation.
The library does not use future chart data, negative visual offsets to rewrite history or hidden lookahead requests.
MARKET STRUCTURE
The stateful swing engine stores the latest and previous confirmed swing highs and lows.
It classifies confirmed swings as:
• HH — Higher High
• HL — Higher Low
• LH — Lower High
• LL — Lower Low
The structure model tracks:
• latest swing prices,
• origin bars,
• swing types,
• current market bias,
• consumed structure levels,
• latest break type and direction,
• latest MSS direction and bar.
BOS AND CHOCH
A confirmed break can require a candle close beyond the structure level, depending on the supplied configuration.
The current market bias and the direction of the broken swing determine whether the event represents continuation or a Change of Character.
The library preserves the confirmed event level, direction, origin and confirmation bar in the returned snapshot.
MARKET STRUCTURE SHIFT
MSS can require:
• a confirmed close through structure,
• a previous opposite bias,
• a displacement candle,
• a minimum ATR-based displacement.
These requirements are provided through FactsConfiguration. The library does not silently relax a missing requirement.
FAIR VALUE GAPS
The library detects bullish and bearish three-candle imbalances from caller-supplied OHLC data.
Optional ATR filtering can require a minimum imbalance size.
Each FVG fact can contain:
• direction,
• upper and lower boundaries,
• origin bar and time,
• confirmation bar,
• mitigation state,
• invalidation state,
• test count,
• fill percentage,
• latest test bar,
• origin volume,
• origin average volume,
• origin Premium/Discount location,
• bounded strength,
• displacement confirmation.
ORDER BLOCKS
Order Block facts are created from a bounded lookback and can require a confirmed BOS or MSS.
The configuration controls whether candle bodies or full candle ranges define the zone.
Each Order Block uses the same auditable lifecycle metadata as an FVG, including origin, tests, fill, mitigation, invalidation, volume, relative volume context, strength and displacement confirmation.
ZONE LIFECYCLE
A zone can be:
• available,
• tested,
• partially filled,
• mitigated,
• invalidated.
The test counter and fill percentage are updated from confirmed interaction with the stored zone boundaries.
The library does not invent missing origin metadata. If a fact cannot be associated with a valid source, the unavailable value remains unavailable.
LIQUIDITY
The library maintains bounded arrays of confirmed swing-high and swing-low liquidity references.
It derives:
• BSL — Buy-Side Liquidity,
• SSL — Sell-Side Liquidity,
• EQH — Equal Highs,
• EQL — Equal Lows.
Equal-level classification uses the supplied ATR-based tolerance rather than exact floating-point equality.
Liquidity metadata includes:
• side and type,
• level,
• origin bar,
• collection state,
• collection time,
• sweep type and level.
A pool origin is preserved only when its price is genuinely associated with the originating swing. The library does not transfer unrelated swing metadata to a new liquidity level.
LIQUIDITY SWEEPS
Depending on configuration, a sweep can require price to move beyond the stored pool and close back inside it.
The returned snapshot distinguishes BSL and SSL sweep facts. A sweep is a confirmed market fact, not a BUY or SELL recommendation.
PREMIUM AND DISCOUNT
The library can build a dealing range from confirmed swing extremes.
The returned context can contain:
• range high,
• range low,
• equilibrium,
• current Premium, Discount or Equilibrium classification.
An unavailable or invalid range remains unavailable rather than using a synthetic fallback.
EMA AND CONTEXT FACTS
The importing indicator supplies the configured fast, medium and slow EMA values together with available higher-timeframe context.
Facts Core returns bounded contextual facts such as:
• EMA trend state,
• price relation to EMA values,
• available higher-timeframe trend and bias context.
The library does not request higher-timeframe data itself. This keeps data ownership and confirmation timing inside the importing indicator.
BOUNDED STATE
The implementation uses explicit limits:
• maximum six zones for each kind and direction,
• maximum eight swing references for each side.
This prevents unlimited state growth and makes runtime behavior predictable.
PUBLIC API
Exported records:
• FactsConfiguration
• ZoneFact
• FactsState
• StructureFacts
• ZoneFacts
• LiquidityFacts
• ContextFacts
• FactsSnapshot
Exported functions:
• contractVersion()
• defaultConfiguration()
• newState()
• advance(...)
• snapshotValid(...)
TYPICAL USAGE
An importing indicator should:
1. Create one persistent FactsState.
2. Create or resolve a FactsConfiguration.
3. Supply confirmed OHLCV, ATR, EMA and available context values to advance().
4. Store the returned state.
5. Read the returned FactsSnapshot.
6. Validate the snapshot with snapshotValid().
7. Present or transport only facts that are actually available.
Conceptual example:
```pine
import AreXoN_/SMCNexusFactsCoreV2/1 as facts
var facts.FactsState state = facts.newState()
facts.FactsConfiguration configuration =
facts.defaultConfiguration()
[stateNext, snapshot] = facts.advance(
state,
configuration,
barstate.isconfirmed,
bar_index,
time,
open,
high,
low,
close,
volume,
atr14,
emaFast,
emaMedium,
emaSlow,
higherTimeframeTrend,
higherTimeframeBias,
localContext)
state := stateNext
bool validSnapshot = facts.snapshotValid(snapshot)
```
The example is conceptual. The exact function signature in the published source is authoritative. Replace the example import with the exact path assigned by PulseWire.
WHY THE CHART IS CLEAN
This is a non-visual market-facts library. It intentionally creates no plots, labels, boxes, lines, tables or chart drawings.
The publication chart is therefore intentionally clean and contains no other indicators or unexplained visual elements. An importing indicator is responsible for visual presentation.
LIMITATIONS
• Facts are based on the chart OHLCV series supplied by the importer.
• Swing confirmation necessarily occurs after the configured right-side bars.
• The library does not provide native bid/ask data, footprint or real order flow.
• Chart volume may be broker tick volume rather than centralized exchange volume.
• It does not verify spread, slippage or broker execution.
• It does not request macroeconomic information.
• It does not produce trading signals or recommendations.
• It does not place, modify or close orders.
• It produces no visual chart output by itself.
Contract version: 1.0.0.
This library is an analytical and software-development component. It is not investment advice, a trading recommendation or an automated trading system.
Pine library
In true PulseWire spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in publications is governed by 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 PulseWire. Read more in the Terms of Use.
Pine library
In true PulseWire spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in publications is governed by 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 PulseWire. Read more in the Terms of Use.
