PINE LIBRARY
업데이트됨 biasHelper

biasHelpers: Core Engine for Bias Analytics against a set of Benchmarks
Overview
The `biasHelper` library is a highly optimized backend engine designed specifically for evaluating, tracking, and aggregating bias analytics across timeframes.
Built on strict Model-View-Controller (MVC) software architecture principles, this library encapsulates all complex mathematical processing, state caching, and string formatting. By offloading these responsibilities, it allows front-end indicators to remain exceptionally lightweight, mathematically pure, and dedicated entirely to UI visualization.
This library features built-in anti-repainting guardrails, deterministic pseudo-random evaluations, and dynamic memory allocation through User-Defined Types (UDTs).
---
Core Architecture & Design Philosophy
This library operates using two primary User-Defined Types (UDTs) that track the lifecycle of a trading session:
1. `SessionInfo`: The primary memory matrix. It tracks OHLC data, prevailing directional bias, Heikin-Ashi extensions, and cumulative hit/close counts.
2. `SessionLines`: The visual array tracker. It orchestrates the projection of structural support/resistance levels and evaluates live price touches against them.
By maintaining state inside these objects rather than utilizing global arrays, the library ensures O(1) time complexity during bar evaluation, resulting in lightning-fast execution even on dense chart histories.
---
Exported Types (UDTs)
`SessionInfo`
The core data structure for tracking session metrics and bias execution.
* **Price Tracking**: `prevHigh`, `prevLow`, `currentHigh`, `currentLow`, `currentOpen`.
* **Heikin-Ashi Anchors**: `prevHaOpen`, `prevHaClose`.
* **State Trackers**: `pushedUp` (bool), `currentBias` (int: 1 = Bullish, -1 = Bearish, 0 = Neutral).
* **Metric Accumulators**: `bullishCount`, `bearishCount`, `hitHighCount`, `hitLowCount`, `closeHighCount`, `closeLowCount`.
`SessionLines`
The spatial data structure for tracking visual levels and live touches.
* Lines: `highLine`, `lowLine`.
* Touch Booleans: `hitHighLine`, `hitLowLine`.
---
Data & State Management
`updateData(infoObj, isNew, pClose, cOpen, cHigh, cLow)`
The standard market structure logic handler. It evaluates historical structural breaks against the previous close to determine the prevailing directional bias without repainting.
* Parameters: Evaluates state using standard OHLC inputs and strictly anchors to `close[1]` (`pClose`) to guarantee real-time parity with historical states.
`updateBenchmarkData(infoObj, isNew, pClose, cOpen, cHigh, cLow, bType, tfSeconds)`
A dynamic routing matrix for alternative bias benchmarks.
* Supported `bType` Routing:
* `"MOM"`: Pure Candlestick Momentum (Close vs. Open).
* `"HA"`: Synthetic Heikin-Ashi Momentum evaluated securely within standard chart data.
* `"ABULL"` / `"ABEAR"`: Static directional evaluations (Always Bullish / Always Bearish).
* `"COIN"`: Deterministic pseudo-random generation. Generates a perfect 50/50 randomized output anchored mathematically to the timestamp and previous close, guaranteeing it never repaints or flickers on live ticks.
* `"DTD"`: Day-to-Day alternating parity based on absolute time intervals.
`processLines(linesObj, infoObj, isNew, tRight, lStyle, currHigh, currLow)`
Draws historical support/resistance barriers and evaluates current price action (`currHigh`, `currLow`) to register touches and successful close-throughs.
---
Math & Aggregation
`calcTrueRate(biasCount, hitCount, closeCount)`
Calculates the *True Close-Through Rate* (Success Rate × Close-Through Rate) while safely handling zero-division scenarios. Returns a standardized float coefficient.
`getTotals(infoObj)`
Extracts aggregated cross-directional totals for condensed dashboard views.
* Returns: A tuple `[totalBias, totalHit, totalClose]`.
---
UI Formatting Utilities
`getTablePos(pos)` & `getTableSize(size)`
Translates string-based user inputs (e.g., `"Top Right"`, `"Normal"`) into native Pine Script structural variables (`position.top_right`, `size.normal`).
`formatResult(hit, biasCount)`
Converts raw integers into a cleanly formatted fractional percentage string (e.g., `"45.2%"`).
`formatPercent(value)`
Converts a raw floating-point coefficient into a polished percentage string.
---
Implementation Example
To utilize this library in your indicator, instantiate the UDTs and pass them through the update loops securely:
Pine Script®
Note to Developers
This library adheres strictly to TradingView's anti-repainting guidelines. When feeding inputs into `updateData` or `updateBenchmarkData`, always utilize the previous bar's close (`close[1]`) for the `pClose` parameter. Live data (`high`, `low`) should exclusively be passed into the `processLines` method to allow real-time touch detection.
Overview
The `biasHelper` library is a highly optimized backend engine designed specifically for evaluating, tracking, and aggregating bias analytics across timeframes.
Built on strict Model-View-Controller (MVC) software architecture principles, this library encapsulates all complex mathematical processing, state caching, and string formatting. By offloading these responsibilities, it allows front-end indicators to remain exceptionally lightweight, mathematically pure, and dedicated entirely to UI visualization.
This library features built-in anti-repainting guardrails, deterministic pseudo-random evaluations, and dynamic memory allocation through User-Defined Types (UDTs).
---
Core Architecture & Design Philosophy
This library operates using two primary User-Defined Types (UDTs) that track the lifecycle of a trading session:
1. `SessionInfo`: The primary memory matrix. It tracks OHLC data, prevailing directional bias, Heikin-Ashi extensions, and cumulative hit/close counts.
2. `SessionLines`: The visual array tracker. It orchestrates the projection of structural support/resistance levels and evaluates live price touches against them.
By maintaining state inside these objects rather than utilizing global arrays, the library ensures O(1) time complexity during bar evaluation, resulting in lightning-fast execution even on dense chart histories.
---
Exported Types (UDTs)
`SessionInfo`
The core data structure for tracking session metrics and bias execution.
* **Price Tracking**: `prevHigh`, `prevLow`, `currentHigh`, `currentLow`, `currentOpen`.
* **Heikin-Ashi Anchors**: `prevHaOpen`, `prevHaClose`.
* **State Trackers**: `pushedUp` (bool), `currentBias` (int: 1 = Bullish, -1 = Bearish, 0 = Neutral).
* **Metric Accumulators**: `bullishCount`, `bearishCount`, `hitHighCount`, `hitLowCount`, `closeHighCount`, `closeLowCount`.
`SessionLines`
The spatial data structure for tracking visual levels and live touches.
* Lines: `highLine`, `lowLine`.
* Touch Booleans: `hitHighLine`, `hitLowLine`.
---
Data & State Management
`updateData(infoObj, isNew, pClose, cOpen, cHigh, cLow)`
The standard market structure logic handler. It evaluates historical structural breaks against the previous close to determine the prevailing directional bias without repainting.
* Parameters: Evaluates state using standard OHLC inputs and strictly anchors to `close[1]` (`pClose`) to guarantee real-time parity with historical states.
`updateBenchmarkData(infoObj, isNew, pClose, cOpen, cHigh, cLow, bType, tfSeconds)`
A dynamic routing matrix for alternative bias benchmarks.
* Supported `bType` Routing:
* `"MOM"`: Pure Candlestick Momentum (Close vs. Open).
* `"HA"`: Synthetic Heikin-Ashi Momentum evaluated securely within standard chart data.
* `"ABULL"` / `"ABEAR"`: Static directional evaluations (Always Bullish / Always Bearish).
* `"COIN"`: Deterministic pseudo-random generation. Generates a perfect 50/50 randomized output anchored mathematically to the timestamp and previous close, guaranteeing it never repaints or flickers on live ticks.
* `"DTD"`: Day-to-Day alternating parity based on absolute time intervals.
`processLines(linesObj, infoObj, isNew, tRight, lStyle, currHigh, currLow)`
Draws historical support/resistance barriers and evaluates current price action (`currHigh`, `currLow`) to register touches and successful close-throughs.
---
Math & Aggregation
`calcTrueRate(biasCount, hitCount, closeCount)`
Calculates the *True Close-Through Rate* (Success Rate × Close-Through Rate) while safely handling zero-division scenarios. Returns a standardized float coefficient.
`getTotals(infoObj)`
Extracts aggregated cross-directional totals for condensed dashboard views.
* Returns: A tuple `[totalBias, totalHit, totalClose]`.
---
UI Formatting Utilities
`getTablePos(pos)` & `getTableSize(size)`
Translates string-based user inputs (e.g., `"Top Right"`, `"Normal"`) into native Pine Script structural variables (`position.top_right`, `size.normal`).
`formatResult(hit, biasCount)`
Converts raw integers into a cleanly formatted fractional percentage string (e.g., `"45.2%"`).
`formatPercent(value)`
Converts a raw floating-point coefficient into a polished percentage string.
---
Implementation Example
To utilize this library in your indicator, instantiate the UDTs and pass them through the update loops securely:
Note to Developers
This library adheres strictly to TradingView's anti-repainting guidelines. When feeding inputs into `updateData` or `updateBenchmarkData`, always utilize the previous bar's close (`close[1]`) for the `pClose` parameter. Live data (`high`, `low`) should exclusively be passed into the `processLines` method to allow real-time touch detection.
릴리즈 노트
The `biasHelper` library is a highly optimized backend engine designed specifically for evaluating, tracking, and aggregating bias analytics across timeframes.Built on strict Model-View-Controller (MVC) software architecture principles, this library encapsulates all complex mathematical processing, state caching, and string formatting. By offloading these responsibilities, it allows front-end indicators to remain exceptionally lightweight, mathematically pure, and dedicated entirely to UI visualization.
This library features built-in anti-repainting guardrails, deterministic pseudo-random evaluations, and dynamic memory allocation through User-Defined Types (UDTs).
---
Core Architecture & Design Philosophy
This library operates using two primary User-Defined Types (UDTs) that track the lifecycle of a trading session:
1. `SessionInfo`: The primary memory matrix. It tracks OHLC data, prevailing directional bias, Heikin-Ashi extensions, and cumulative hit/close counts.
2. `SessionLines`: The visual array tracker. It orchestrates the projection of structural support/resistance levels and evaluates live price touches against them.
By maintaining state inside these objects rather than utilizing global arrays, the library ensures O(1) time complexity during bar evaluation, resulting in lightning-fast execution even on dense chart histories.
---
Exported Types (UDTs)
`SessionInfo`
The core data structure for tracking session metrics and bias execution.
* Price Tracking: `prevHigh`, `prevLow`, `currentHigh`, `currentLow`, `currentOpen`.
* Heikin-Ashi Anchors: `prevHaOpen`, `prevHaClose`.
* State Trackers: `pushedUp` (bool), `currentBias` (int: 1 = Bullish, -1 = Bearish, 0 = Neutral).
* Metric Accumulators: `bullishCount`, `bearishCount`, `hitHighCount`, `hitLowCount`, `closeHighCount`, `closeLowCount`.
`SessionLines`
The spatial data structure for tracking visual levels and live touches.
* Lines: `highLine`, `lowLine`.
* Touch Booleans: `hitHighLine`, `hitLowLine`.
---
Data & State Management
`updateData(infoObj, isNew, pClose, cOpen, cHigh, cLow)`
The standard market structure logic handler. It evaluates historical structural breaks against the previous close to determine the prevailing directional bias without repainting.
* Parameters: Evaluates state using standard OHLC inputs and strictly anchors to `close[1]` (`pClose`) to guarantee real-time parity with historical states.
`updateBenchmarkData(infoObj, isNew, pClose, cOpen, cHigh, cLow, bType, tfSeconds)`
A dynamic routing matrix for alternative bias benchmarks.
* Supported `bType` Routing:
* `"MOM"`: Pure Candlestick Momentum (Close vs. Open).
* `"HA"`: Synthetic Heikin-Ashi Momentum evaluated securely within standard chart data.
* `"ABULL"` / `"ABEAR"`: Static directional evaluations (Always Bullish / Always Bearish).
* `"COIN"`: Deterministic pseudo-random generation. Generates a perfect 50/50 randomized output anchored mathematically to the timestamp and previous close, guaranteeing it never repaints or flickers on live ticks.
* `"DTD"`: Day-to-Day alternating parity based on absolute time intervals.
`processLines(linesObj, infoObj, isNew, tRight, lStyle, currHigh, currLow)`
Draws historical support/resistance barriers and evaluates current price action (`currHigh`, `currLow`) to register touches and successful close-throughs.
---
Math & Aggregation
`calcTrueRate(biasCount, hitCount, closeCount)`
Calculates the True Close-Through Rate (Success Rate × Close-Through Rate) while safely handling zero-division scenarios. Returns a standardized float coefficient.
`getTotals(infoObj)`
Extracts aggregated cross-directional totals for condensed dashboard views.
* Returns: A tuple `[totalBias, totalHit, totalClose]`.
---
UI Formatting Utilities
`getTablePos(pos)` & `getTableSize(size)`
Translates string-based user inputs (e.g., `"Top Right"`, `"Normal"`) into native Pine Script structural variables (`position.top_right`, `size.normal`).
`formatResult(hit, biasCount)`
Converts raw integers into a cleanly formatted fractional percentage string (e.g., `"45.2%"`).
`formatPercent(value)`
Converts a raw floating-point coefficient into a polished percentage string.
---
Implementation Example
To utilize this library in your indicator, instantiate the UDTs and pass them through the update loops securely:
Note to Developers
This library adheres strictly to TradingView's anti-repainting guidelines. When feeding inputs into `updateData` or `updateBenchmarkData`, always utilize the previous bar's close (`close[1]`) for the `pClose` parameter. Live data (`high`, `low`) should exclusively be passed into the `processLines` method to allow real-time touch detection.
파인 라이브러리
트레이딩뷰의 진정한 정신에 따라, 작성자는 이 파인 코드를 오픈소스 라이브러리로 게시하여 커뮤니티의 다른 파인 프로그래머들이 재사용할 수 있도록 했습니다. 작성자에게 경의를 표합니다! 이 라이브러리는 개인적으로 사용하거나 다른 오픈소스 게시물에서 사용할 수 있지만, 이 코드의 게시물 내 재사용은 하우스 룰에 따라 규제됩니다.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
파인 라이브러리
트레이딩뷰의 진정한 정신에 따라, 작성자는 이 파인 코드를 오픈소스 라이브러리로 게시하여 커뮤니티의 다른 파인 프로그래머들이 재사용할 수 있도록 했습니다. 작성자에게 경의를 표합니다! 이 라이브러리는 개인적으로 사용하거나 다른 오픈소스 게시물에서 사용할 수 있지만, 이 코드의 게시물 내 재사용은 하우스 룰에 따라 규제됩니다.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.