Library

ImportantLevelsLinesLabels_UtilitiesLevelsLinesLabels_Utilities is a shared Pine v6 utility library for scripts that already resolve their own level values, source candles, session logic, and visibility conditions, but want a reusable level-output layer.
It centralizes the pieces that tend to get rewritten across level-based scripts:
• line-style and label-size resolvers
• EM-space right-label padding
• compact price / $ difference / % difference formatting
• standardized right-side level label text
• above/below-current-price color routing
• bar-time horizontal level line management
• transparent right-side text label management
• synchronized line / label slot-array helpers
• float / int / line / label array pruning helpers
• newest-first history lookup helpers
• Active Period / Source Window / Source Candle start-time routing
• newest-first rolling highest / lowest helpers
• newest-first rolling highest / lowest helpers with matching source time
The example chart demonstrates how a calling script can use the library to render live close-style levels, previous-day high/low levels, rolling completed-window high/low levels, right-side label stacks, source-aware line starts, and reusable object slots.
This library is intentionally focused on output, formatting, object lifecycle, and history-array utilities.
It does not:
• request higher-timeframe data
• decide regular-session versus extended-session sources
• detect sessions, opens, closes, highs, lows, or pivots
• calculate candle levels, VWAPs, pivots, trendlines, or envelopes
• decide which levels should be shown
• own script inputs, tooltips, colors, or final visibility logic
• provide trading signals or directional recommendations
Calling scripts remain responsible for:
• the level engine
• the source engine
• session logic
• request.security() calls
• user inputs and tooltips
• final show/hide conditions
• color choices
• interpretation
How to use
Import the library near the top of your script in global scope, before calling its helpers.
Typical placement:
//@version=6
indicator(...)
import MYNAMEISBRANDON/LevelsLinesLabels_Utilities/1 as LVL
Replace /1 with the latest published version if a newer version is available.
This library expects the calling script to already know the level value, source time, window time, active period start, display state, colors, and label text it wants to use. The library then handles the reusable formatting, line, label, object-slot, pruning, lookup, and rolling-window utility layer.
➖Style Helpers➖
These helpers convert simple user-facing strings into Pine style enums and route colors based on whether price is above or below a level.
levelLineStyle(styleIn)
Converts user-facing line-style text into a Pine line-style enum.
Parameters:
styleIn (simple string): Solid, Dashed, or Dotted
Returns:
Pine line style
levelLabelSize(sizeIn)
Converts user-facing label-size text into a Pine label-size enum.
Parameters:
sizeIn (simple string): Tiny, Small, Normal, Large, or Huge
Returns:
Pine label size
levelColor(level, currentPrice, aboveColor, belowColor)
Routes a level to the above-color or below-color based on the current/reference price.
Parameters:
level (float): Level price
currentPrice (float): Current/reference price
aboveColor (color): Color used when currentPrice is greater than or equal to level
belowColor (color): Color used when currentPrice is below level
Returns:
Resolved color
➖Text Formatting Helpers➖
These helpers keep level labels compact and readable across high-priced stocks, low-priced stocks, crypto pairs, futures-style symbols, and other price scales.
levelSpacer(pad)
Builds EM-space padding for right-side text labels.
levelTrimTrailingZeros(txt)
Removes unnecessary trailing zeros and trailing decimal points.
levelStripLeadingZero(txt)
Removes leading decimal zeroes such as 0.42 → .42 and -0.42 → -.42.
levelSigFig(value, figs)
Rounds a number to a requested number of significant figures.
levelNumberText(value, pattern)
Formats a number with a Pine pattern and then trims unnecessary zeros.
levelPriceText(value, sigFigs)
Formats a level price using significant figures and compact decimal trimming.
levelAbsMoneyText(absValue)
Formats an absolute money value rounded to two decimals.
levelAbsPctText(absValue)
Formats an absolute percent value rounded to two decimals.
levelMoneyChangeText(currentPrice, level)
Formats current price minus level as a signed $ difference.
levelPctChangeText(currentPrice, level)
Formats current price minus level as a signed % difference.
➖Level Label Text Helpers➖
levelLabelText(tag, level, currentPrice, pad, showPrice, showMoneyDiff, showPctDiff, sigFigs)
Builds a standardized right-side level label block.
The label model is:
• optional price row
• optional $ difference row
• optional % difference row
• required level tag row supplied by the calling script
Example output:
741.82
-$22.16
-2.90%
D Hi
EM-space padding is applied to every row. This lets scripts visually stagger labels to the right while keeping the actual label pinned to the current bar_index.
➖Object Sync Helpers➖
These helpers create an object when enabled, update it in place while enabled, and delete it when the caller’s condition turns false.
syncTextLabel(lbl, show, y, txt, txtColor, sizeIn)
Creates, updates, or deletes a transparent right-side text label at the current bar_index.
syncBarTimeLevelLine(ln, show, t1, t2, y, lineColor, lineWidth, styleIn)
Creates, updates, or deletes a horizontal bar-time level line using xloc.bar_time.
This is useful for level scripts that want line starts based on a real timestamp instead of deep bar-index offsets.
➖Slot Array Helpers➖
These helpers let scripts store many repeated level lines and labels in fixed array slots instead of declaring one separate variable per object.
syncLineSlot(lines, slot, show, t1, t2, y, lineColor, lineWidth, styleIn)
Creates, updates, or deletes a bar-time level line stored in a fixed array slot.
syncLabelSlot(labels, slot, show, y, txt, txtColor, sizeIn)
Creates, updates, or deletes a transparent right-side text label stored in a fixed array slot.
Typical use:
const int SLOT_HI = 0
const int SLOT_LO = 1
const int SLOT_CL = 2
var array rowLines = array.new_line(3, na)
var array rowLabels = array.new_label(3, na)
LVL.syncLineSlot(rowLines, SLOT_HI, showHi, hiStartTime, time, hiLevel, hiColor, 2, "Dotted")
LVL.syncLabelSlot(rowLabels, SLOT_HI, showHiLabel, hiLevel, hiText, hiColor, "Normal")
This is especially useful for scripts with repeated rows such as:
• Previous Day High / Low / Close
• Weekly High / Low / Close
• Monthly High / Low / Close
• VWAP bands
• ATR levels
• rolling window levels
• trendline or envelope companion levels
➖History Array Helpers➖
These helpers support scripts that store completed records in arrays, especially newest-first arrays populated with array.unshift().
pruneFloat(arr, maxKeep)
Prunes a float array by popping old records from the end.
pruneInt(arr, maxKeep)
Prunes an int array by popping old records from the end.
pruneLineObjects(arr, maxKeep)
Prunes a line array and deletes removed line objects.
pruneLabelObjects(arr, maxKeep)
Prunes a label array and deletes removed label objects.
pruneHiLoHistory(highs, lows, highTimes, lowTimes, windowTimes, maxKeep)
Prunes synchronized high / low / high-time / low-time / window-time arrays.
pruneHlcHistory(highs, lows, closes, highTimes, lowTimes, closeTimes, windowTimes, maxKeep)
Prunes synchronized high / low / close / source-time / window-time arrays.
histFloat(arr, idx)
Returns a float history value at an array index, or na if unavailable.
histInt(arr, idx)
Returns an int history value at an array index, or na if unavailable.
requestOrManual(requestValue, manualValue)
Returns a requested value when available, otherwise the manual value.
manualOrRequest(manualValue, requestValue)
Returns a manual value when available, otherwise the requested value.
manualSourceTime(manualValue, times, idx)
Returns a matching manual source time only when the matching manual value exists.
➖Source Start-Time Helpers➖
These helpers route line-start timestamps using a common level-script model.
sourceLineStartTime(mode, sourceTime, activeTime)
Resolves Active Period versus Source Candle / Source Close Candle starts.
windowSourceLineStartTime(mode, windowTime, sourceTime, activeTime)
Resolves Active Period, Source Window, Source Candle, or Source Close Candle starts.
Start-time model:
Active Period:
Uses the active period start supplied by the calling script.
Source Window:
Uses the completed source window start supplied by the calling script.
Source Candle / Source Close Candle:
Uses the exact source candle time supplied by the calling script when available. If the exact source candle time is not available, it falls back to Source Window when available, then Active Period.
This keeps the library generic while allowing calling scripts to decide what a “source candle” means in their own context.
➖Newest-First Rolling Extreme Helpers➖
These helpers are built for arrays where index 0 is the most recent completed record.
Newest-first history model:
• index 0 = most recent completed record
• index 1 = one completed record back
• index 2 = two completed records back
• index 3 = three completed records back
• index 4 = four completed records back
A 5-record rolling high scans indexes 0 through 4 when available.
highestNewestFirst(values, lookback)
Returns the highest value and matching array index from a newest-first array window.
lowestNewestFirst(values, lookback)
Returns the lowest value and matching array index from a newest-first array window.
highestNewestFirstWithTime(values, times, lookback)
Returns the highest value, matching array index, and matching source time from synchronized newest-first arrays.
lowestNewestFirstWithTime(values, times, lookback)
Returns the lowest value, matching array index, and matching source time from synchronized newest-first arrays.
Important note:
The returned index is an array index, not a bar offset. If the calling script stores synchronized time arrays, the “with time” helpers can also return the matching source timestamp.
Example:
// Newest-first arrays populated with array.unshift().
= LVL.highestNewestFirstWithTime(
dailyHighHistory,
dailyHighTimeHistory,
5)
= LVL.lowestNewestFirstWithTime(
dailyLowHistory,
dailyLowTimeHistory,
5)
➖Recommended Usage➖
This library works best when the calling script follows this workflow:
1. Resolve the level value in the script.
2. Resolve the source candle time or source window time in the script.
3. Resolve the final visibility condition in the script.
4. Use this library to format the label, route color, choose start time, and manage the line/label object.
This keeps source logic and interpretation script-level while making the reusable output layer cleaner and easier to maintain.
➖Important Notes➖
This library is a utility layer only.
It does not:
• request data
• detect sessions
• choose RTH or EXT behavior
• calculate previous-day levels
• calculate VWAP
• calculate pivots
• calculate trendlines
• decide trade direction
• generate signals
Calling scripts remain responsible for their own engine logic and interpretation.
The included demo script is meant to show how the library can be used to manage live levels, previous-day levels, rolling completed-record levels, label padding, object slots, and start-time routing.
Library

OhMyHtfLibraryLibrary "OhMyHtfLibrary"
HTF candle platform: timeframe alignment, profiles, and (future) packed OHLC / draw helpers. Import as `import daggerok/OhMyHtfLibrary/1 as omhl`. Sweep/OB domain → future `OhMyHtfSweepLibrary` (`omhsl`).
resolveHtfContext(chart_tf_seconds, default_htf, default_candle_count, align_ctf_max_seconds, align_htf, align_enabled, profile_ctf_exact_seconds, profile_htf, profile_enabled, profile_candle_counts)
Resolves HTF string, enable flag, and candle count from Timeframes Alignment + Profiles.
TFA: first alignment row where `chart_tf_seconds <= align_ctf_max_seconds ` wins.
Profiles: first enabled row where `chart_tf_seconds == profile_ctf_exact_seconds ` overrides TFA.
Parameters:
chart_tf_seconds (int) : Chart timeframe in seconds.
default_htf (string) : Fallback HTF when no alignment rule matches.
default_candle_count (int) : Default HTF candle count (HTF Candles input).
align_ctf_max_seconds (array) : Upper-bound CTF seconds per TFA row (length 14).
align_htf (array) : HTF string per TFA row.
align_enabled (array) : Enabled flag per TFA row.
profile_ctf_exact_seconds (array) : Exact chart TF seconds per profile row (length 12).
profile_htf (array) : HTF string per profile row.
profile_enabled (array) : Profile row enabled flags.
profile_candle_counts (array) : Candle count per profile row.
Returns: `HtfContext` with resolved settings.
HtfContext
Resolved HTF timeframe settings for the current chart.
Fields:
htf (series string) : Higher timeframe string for `request.security` and draw logic.
is_enabled (series bool) : Whether HTF features are active for this chart TF (TFA enable flag or profile override).
candle_count (series int) : Number of HTF candles to display (profile may override default).
profile_override (series bool) : True when a profile row matched (exact CTF). Library

AIUnifiedCoreLibrary "AIUnifiedCore"
Core signal engine for the AI Learning Trader Bot unified system.
This library contains reusable logic only. Inputs, plots, labels, strategy orders,
and alerts belong in the wrapper scripts that import this library.
clampFloat(value, minValue, maxValue)
Clamps a number between a minimum and maximum.
Parameters:
value (float) : Number to clamp.
minValue (float) : Minimum allowed value.
maxValue (float) : Maximum allowed value.
Returns: Clamped value.
trendEngine(source, fastLen, midLen, slowLen)
Calculates the EMA/VWAP trend engine.
Parameters:
source (float) : Source price.
fastLen (simple int) : Fast EMA length.
midLen (simple int) : Middle EMA length.
slowLen (simple int) : Slow EMA length.
Returns: Fast EMA, middle EMA, slow EMA, VWAP, bullish trend, bearish trend.
momentumEngine(source, rsiLen)
Calculates RSI/MACD momentum engine.
Parameters:
source (float) : Source price.
rsiLen (simple int) : RSI length.
Returns: RSI, MACD line, MACD signal, MACD histogram, bullish momentum, bearish momentum.
volumeEngine(volumeLen)
Calculates volume confirmation.
Parameters:
volumeLen (simple int) : Volume average length.
Returns: Volume average, high volume, bullish volume, bearish volume.
priceActionEngine(swingLen)
Calculates price action breakout and candle direction.
Parameters:
swingLen (simple int) : Swing lookback length.
Returns: Swing high, swing low, bullish break, bearish break, bullish candle, bearish candle.
chopEngine(diLen, adxSmooth, minAdx, atrLen, minAtrPercent, minEmaSpreadPercent, votesNeeded, emaFast, emaSlow)
Calculates the chop/no-trade filter.
Parameters:
diLen (simple int) : DMI DI length.
adxSmooth (simple int) : ADX smoothing.
minAdx (float) : Minimum ADX trend strength.
atrLen (simple int) : ATR length.
minAtrPercent (float) : Minimum ATR percent.
minEmaSpreadPercent (float) : Minimum EMA spread percent.
votesNeeded (simple int) : Number of chop votes needed.
emaFast (float) : Fast EMA.
emaSlow (float) : Slow EMA.
Returns: DI+, DI-, ADX, ATR, ATR percent, EMA spread percent, chop votes, chop market.
probabilityEngine(bullTrend, bearTrend, bullMomentum, bearMomentum, bullVolume, bearVolume, bullBreak, bearBreak, bullCandle, bearCandle, mtfLongOk, mtfShortOk)
Calculates long/short probability scores.
Parameters:
bullTrend (bool) : Bullish trend.
bearTrend (bool) : Bearish trend.
bullMomentum (bool) : Bullish momentum.
bearMomentum (bool) : Bearish momentum.
bullVolume (bool) : Bullish volume.
bearVolume (bool) : Bearish volume.
bullBreak (bool) : Bullish breakout.
bearBreak (bool) : Bearish breakout.
bullCandle (bool) : Bullish candle.
bearCandle (bool) : Bearish candle.
mtfLongOk (bool) : Higher-timeframe long confirmation.
mtfShortOk (bool) : Higher-timeframe short confirmation.
Returns: Long probability and short probability.
superEngine(emaFast, emaMid, rsiValue, macdHist)
Calculates premium super-aggressive pressure scores.
Parameters:
emaFast (float) : Fast EMA.
emaMid (float) : Middle EMA.
rsiValue (float) : RSI value.
macdHist (float) : MACD histogram.
Returns: Super long probability, super short probability.
likelyRevEngine(showSignals, aggression, minVotes, realtimeOnly, chopOk, cooldownUpOk, cooldownDownOk, longProbability, shortProbability, superLongProbability, superShortProbability, bullTrend, bearTrend, emaFast, rsiValue, macdHist, superSensitivity, minEntryProbability)
Calculates early likely reversal votes/signals.
Parameters:
showSignals (bool) : Master toggle.
aggression (simple string) : Aggression text: Balanced, Aggressive, or Hyper.
minVotes (simple int) : Minimum votes.
realtimeOnly (bool) : Only allow before candle closes.
chopOk (bool) : Whether chop filter allows signal.
cooldownUpOk (bool)
cooldownDownOk (bool)
longProbability (float) : Long probability.
shortProbability (float) : Short probability.
superLongProbability (float) : Super long probability.
superShortProbability (float) : Super short probability.
bullTrend (bool) : Bull trend.
bearTrend (bool) : Bear trend.
emaFast (float) : Fast EMA.
rsiValue (float) : RSI value.
macdHist (float) : MACD histogram.
superSensitivity (simple int) : Super aggressive threshold.
minEntryProbability (simple int) : Minimum entry probability.
Returns: Up votes, down votes, votes needed, likely rev up, likely rev down.
easyQuality(trendOk, momentumOk, mtfOk, volumeOk, breakOk, chopMarket, oppositeLikelyRev, probability)
Calculates Easy Mode trade quality score.
Parameters:
trendOk (bool) : Trend agreement.
momentumOk (bool) : Momentum agreement.
mtfOk (bool) : Higher-timeframe agreement.
volumeOk (bool) : Volume agreement.
breakOk (bool) : Breakout agreement.
chopMarket (bool) : No-trade/chop state.
oppositeLikelyRev (bool) : Opposite likely reversal warning.
probability (float) : Direction probability.
Returns: Easy Mode quality score.
actionCode(chopMarket, masterLong, masterShort, exitLong, exitShort, flipLong, flipShort, likelyRevUp, likelyRevDown)
Final unified action code.
Parameters:
chopMarket (bool) : No-trade market.
masterLong (bool) : Master long.
masterShort (bool) : Master short.
exitLong (bool) : Exit long.
exitShort (bool) : Exit short.
flipLong (bool) : Flip to long.
flipShort (bool) : Flip to short.
likelyRevUp (bool) : Likely reversal up.
likelyRevDown (bool) : Likely reversal down.
Returns: Integer action code.
actionText(action)
Converts an action code into text.
Parameters:
action (int) : Action code.
Returns: Action text.
trendText(bullTrend, bearTrend)
Converts trend states into text.
Parameters:
bullTrend (bool) : Bull trend.
bearTrend (bool) : Bear trend.
Returns: Trend text.
topStackPrice(highValue, atrValue, gapAtr, slot)
Returns stacked label price above the candle.
Parameters:
highValue (float) : Candle high.
atrValue (float) : ATR.
gapAtr (float) : Gap in ATR multiples.
slot (int) : Stack slot, starting at 1.
Returns: Label price.
bottomStackPrice(lowValue, atrValue, gapAtr, slot)
Returns stacked label price below the candle.
Parameters:
lowValue (float) : Candle low.
atrValue (float) : ATR.
gapAtr (float) : Gap in ATR multiples.
slot (int) : Stack slot, starting at 1.
Returns: Label price. Library

BitLangLangData08Library "BitLangLangData08"
contains(pair)
Parameters:
pair (string)
loadSummary(pair, aSym, aSeq, aDir, aLev, aOpenT, aCloseT, aOpenP, aCloseP, aRet, aPnl, aMargin)
Parameters:
pair (string)
aSym (array)
aSeq (array)
aDir (array)
aLev (array)
aOpenT (array)
aCloseT (array)
aOpenP (array)
aCloseP (array)
aRet (array)
aPnl (array)
aMargin (array)
loadDetails(pair, aFillStart, aFillCount, aFillT, aFillP, aFillQ, aFillAction)
Parameters:
pair (string)
aFillStart (array)
aFillCount (array)
aFillT (array)
aFillP (array)
aFillQ (array)
aFillAction (array) Library

BitLangLangData07Library "BitLangLangData07"
contains(pair)
Parameters:
pair (string)
loadSummary(pair, aSym, aSeq, aDir, aLev, aOpenT, aCloseT, aOpenP, aCloseP, aRet, aPnl, aMargin)
Parameters:
pair (string)
aSym (array)
aSeq (array)
aDir (array)
aLev (array)
aOpenT (array)
aCloseT (array)
aOpenP (array)
aCloseP (array)
aRet (array)
aPnl (array)
aMargin (array)
loadDetails(pair, aFillStart, aFillCount, aFillT, aFillP, aFillQ, aFillAction)
Parameters:
pair (string)
aFillStart (array)
aFillCount (array)
aFillT (array)
aFillP (array)
aFillQ (array)
aFillAction (array) Library

BitLangLangData06Library "BitLangLangData06"
contains(pair)
Parameters:
pair (string)
loadSummary(pair, aSym, aSeq, aDir, aLev, aOpenT, aCloseT, aOpenP, aCloseP, aRet, aPnl, aMargin)
Parameters:
pair (string)
aSym (array)
aSeq (array)
aDir (array)
aLev (array)
aOpenT (array)
aCloseT (array)
aOpenP (array)
aCloseP (array)
aRet (array)
aPnl (array)
aMargin (array)
loadDetails(pair, aFillStart, aFillCount, aFillT, aFillP, aFillQ, aFillAction)
Parameters:
pair (string)
aFillStart (array)
aFillCount (array)
aFillT (array)
aFillP (array)
aFillQ (array)
aFillAction (array) Library

BitLangLangData05Library "BitLangLangData05"
contains(pair)
Parameters:
pair (string)
loadSummary(pair, aSym, aSeq, aDir, aLev, aOpenT, aCloseT, aOpenP, aCloseP, aRet, aPnl, aMargin)
Parameters:
pair (string)
aSym (array)
aSeq (array)
aDir (array)
aLev (array)
aOpenT (array)
aCloseT (array)
aOpenP (array)
aCloseP (array)
aRet (array)
aPnl (array)
aMargin (array)
loadDetails(pair, aFillStart, aFillCount, aFillT, aFillP, aFillQ, aFillAction)
Parameters:
pair (string)
aFillStart (array)
aFillCount (array)
aFillT (array)
aFillP (array)
aFillQ (array)
aFillAction (array) Library

BitLangLangData04Library "BitLangLangData04"
contains(pair)
Parameters:
pair (string)
loadSummary(pair, aSym, aSeq, aDir, aLev, aOpenT, aCloseT, aOpenP, aCloseP, aRet, aPnl, aMargin)
Parameters:
pair (string)
aSym (array)
aSeq (array)
aDir (array)
aLev (array)
aOpenT (array)
aCloseT (array)
aOpenP (array)
aCloseP (array)
aRet (array)
aPnl (array)
aMargin (array)
loadDetails(pair, aFillStart, aFillCount, aFillT, aFillP, aFillQ, aFillAction)
Parameters:
pair (string)
aFillStart (array)
aFillCount (array)
aFillT (array)
aFillP (array)
aFillQ (array)
aFillAction (array) Library

BitLangLangData03Library "BitLangLangData03"
contains(pair)
Parameters:
pair (string)
loadSummary(pair, aSym, aSeq, aDir, aLev, aOpenT, aCloseT, aOpenP, aCloseP, aRet, aPnl, aMargin)
Parameters:
pair (string)
aSym (array)
aSeq (array)
aDir (array)
aLev (array)
aOpenT (array)
aCloseT (array)
aOpenP (array)
aCloseP (array)
aRet (array)
aPnl (array)
aMargin (array)
loadDetails(pair, aFillStart, aFillCount, aFillT, aFillP, aFillQ, aFillAction)
Parameters:
pair (string)
aFillStart (array)
aFillCount (array)
aFillT (array)
aFillP (array)
aFillQ (array)
aFillAction (array) Library

BitLangLangData02Library "BitLangLangData02"
contains(pair)
Parameters:
pair (string)
loadSummary(pair, aSym, aSeq, aDir, aLev, aOpenT, aCloseT, aOpenP, aCloseP, aRet, aPnl, aMargin)
Parameters:
pair (string)
aSym (array)
aSeq (array)
aDir (array)
aLev (array)
aOpenT (array)
aCloseT (array)
aOpenP (array)
aCloseP (array)
aRet (array)
aPnl (array)
aMargin (array)
loadDetails(pair, aFillStart, aFillCount, aFillT, aFillP, aFillQ, aFillAction)
Parameters:
pair (string)
aFillStart (array)
aFillCount (array)
aFillT (array)
aFillP (array)
aFillQ (array)
aFillAction (array) Library

BitLangLangData01Library "BitLangLangData01"
contains(pair)
Parameters:
pair (string)
loadSummary(pair, aSym, aSeq, aDir, aLev, aOpenT, aCloseT, aOpenP, aCloseP, aRet, aPnl, aMargin)
Parameters:
pair (string)
aSym (array)
aSeq (array)
aDir (array)
aLev (array)
aOpenT (array)
aCloseT (array)
aOpenP (array)
aCloseP (array)
aRet (array)
aPnl (array)
aMargin (array)
loadDetails(pair, aFillStart, aFillCount, aFillT, aFillP, aFillQ, aFillAction)
Parameters:
pair (string)
aFillStart (array)
aFillCount (array)
aFillT (array)
aFillP (array)
aFillQ (array)
aFillAction (array) Library

Library

ICE_CRT_AuditLibrary "ICE_CRT_Audit"
renderRRAudit(t, tradeEntries, tradeStops, tradeRisks, tradeTp1s, tradeTp1Need, tradeTp1Delta, tradeRRs, tradeDistEs, tradeDistEt1, tradeMissRew, tradeDirs, tradeReasons, minRR, failTotal, avgRR, avgNeedReward, avgMissingRew, avgEntry, avgStop, avgRisk, avgTp1, avgDistStop, avgDistTp1)
Parameters:
t (table)
tradeEntries (array)
tradeStops (array)
tradeRisks (array)
tradeTp1s (array)
tradeTp1Need (array)
tradeTp1Delta (array)
tradeRRs (array)
tradeDistEs (array)
tradeDistEt1 (array)
tradeMissRew (array)
tradeDirs (array)
tradeReasons (array)
minRR (float)
failTotal (int)
avgRR (float)
avgNeedReward (float)
avgMissingRew (float)
avgEntry (float)
avgStop (float)
avgRisk (float)
avgTp1 (float)
avgDistStop (float)
avgDistTp1 (float)
renderTp1FormulaAudit(t, tradeDirs, tradeCrtRanges, tradeRatios, tradeDistEt1, tradeDistEs, tradeRRs, tradeNeedRatios, tradeGapRatios, tradeFixAt1, tradeTp1AtRR, minRR, curTp1CrtRatio, auditFixAt1, auditTotal, fixAt1Pct, auditUnfixable, needRatioMax, avgNeedRatio, avgGapRatio)
Parameters:
t (table)
tradeDirs (array)
tradeCrtRanges (array)
tradeRatios (array)
tradeDistEt1 (array)
tradeDistEs (array)
tradeRRs (array)
tradeNeedRatios (array)
tradeGapRatios (array)
tradeFixAt1 (array)
tradeTp1AtRR (array)
minRR (float)
curTp1CrtRatio (float)
auditFixAt1 (int)
auditTotal (int)
fixAt1Pct (float)
auditUnfixable (int)
needRatioMax (float)
avgNeedRatio (float)
avgGapRatio (float) Library

ContractResolverLibrary "ContractResolver"
Classify a PulseWire symbol (stock / crypto / future / etc.) and, for
continuous futures, resolve the real front-month contract ticker with a
4-digit year (e.g. "MNQ1!" -> "MNQU2026"). Prefers the built-in
syminfo.current_contract (authoritative, roll-aware) and falls back to a
calendar estimate only when current_contract is na.
monthCode(m)
Month number (1-12) -> futures month-code letter. Returns na if out of range.
Parameters:
m (int) : Month number, 1-12.
Returns: Single-letter month code, or na.
monthNumber(code)
Month-code letter -> month number (1-12). Returns na if not a valid code.
Parameters:
code (string) : Single-letter month code (case-insensitive).
Returns: Month number 1-12, or na.
resolve(ticker, exchange, symType, currentContract, refTime, rollDay)
Resolve a symbol into its asset class and, for continuous futures, the
front-month contract ticker. Pass syminfo.current_contract for an exact,
roll-aware result; if it is na, a calendar estimate is used (approximated=true).
Parameters:
ticker (string) : Symbol without exchange prefix (e.g. syminfo.ticker).
exchange (string) : Exchange / prefix (e.g. syminfo.prefix).
symType (string) : syminfo.type ("stock","crypto","futures","forex","fund","index","dr"...).
currentContract (string) : syminfo.current_contract (na when chart is not a continuous future).
refTime (int) : Reference time (ms) for the estimate fallback; 0 -> use timenow.
rollDay (int) : Day-of-month threshold for rolling to the next contract in the fallback.
Returns: A Contract object.
resolveChart(rollDay)
Convenience wrapper: resolve the chart's own symbol from its syminfo.* fields.
Parameters:
rollDay (int) : Day-of-month threshold used only by the estimate fallback.
Returns: A Contract object for the current chart symbol.
format(c, pattern)
Build a custom string from a resolved Contract using a placeholder pattern.
Placeholders: {root} {mc} {m} {mm} {yyyy} {yy} {ticker} {exch} {class}
e.g. format(c, "{exch}:{root}{mc}{yyyy}") -> "CME_MINI:MNQU2026"
Parameters:
c (Contract) : A Contract (typically from resolve / resolveChart).
pattern (string) : Template string containing any of the placeholders above.
Returns: The pattern with placeholders substituted (missing fields -> "").
Contract
Parsed/resolved symbol.
Fields:
ticker (series string) : Original ticker without exchange prefix (e.g. "MNQ1!").
exchange (series string) : Exchange / prefix (e.g. "CME_MINI").
assetClass (series string) : "stock" | "crypto" | "future" | "forex" | "index" | "fund" | "other".
isContinuous (series bool) : True when the ticker is a continuous future (ends with "!").
root (series string) : Futures root (e.g. "MNQ"); na for non-futures.
monthCode (series string) : Futures month letter (F,G,H,J,K,M,N,Q,U,V,X,Z); na for non-futures.
contractMonth (series int) : Contract month 1-12; na for non-futures.
contractYear (series int) : 4-digit contract year; na for non-futures.
resolved (series string) : Final ticker: real contract for futures, unchanged for stock/crypto/other.
approximated (series bool) : True when month/year were estimated by calendar (not from current_contract). Library

ICE_CRT_CoreLibrary "ICE_CRT_Core"
calcBodySize(o, c)
Parameters:
o (float)
c (float)
calcRangeSize(h, l)
Parameters:
h (float)
l (float)
calcUpperWick(h, o, c)
Parameters:
h (float)
o (float)
c (float)
calcLowerWick(l, o, c)
Parameters:
l (float)
o (float)
c (float)
calcBodyRatio(bodySize, rangeSize)
Parameters:
bodySize (float)
rangeSize (float)
validateCRT(o, h, l, c, bodyRatioMinIn, atrValIn, atrMultIn)
Parameters:
o (float)
h (float)
l (float)
c (float)
bodyRatioMinIn (float)
atrValIn (float)
atrMultIn (float)
crtLabelText(isBullish, isBearish)
Parameters:
isBullish (bool)
isBearish (bool)
crtLabelStyle(isBullish, isBearish)
Parameters:
isBullish (bool)
isBearish (bool)
crtLabelColor(isBullish, isBearish, bullishColor, bearishColor, validColor)
Parameters:
isBullish (bool)
isBearish (bool)
bullishColor (color)
bearishColor (color)
validColor (color)
crtLabelPrice(isBullish, isBearish, crtHighIn, crtLowIn, crtMidIn)
Parameters:
isBullish (bool)
isBearish (bool)
crtHighIn (float)
crtLowIn (float)
crtMidIn (float)
isGrabHigh(level, minGrab, h)
Parameters:
level (float)
minGrab (float)
h (float)
isGrabLow(level, minGrab, l)
Parameters:
level (float)
minGrab (float)
l (float)
isAcceptanceHigh(level, buffer, c)
Parameters:
level (float)
buffer (float)
c (float)
isAcceptanceLow(level, buffer, c)
Parameters:
level (float)
buffer (float)
c (float)
isWickRejectionHigh(level, wickMin, o, h, l, c)
Parameters:
level (float)
wickMin (float)
o (float)
h (float)
l (float)
c (float)
isWickRejectionLow(level, wickMin, o, h, l, c)
Parameters:
level (float)
wickMin (float)
o (float)
h (float)
l (float)
c (float)
isNoAcceptanceHigh(level, h, c)
Parameters:
level (float)
h (float)
c (float)
isNoAcceptanceLow(level, l, c)
Parameters:
level (float)
l (float)
c (float)
isFollowThroughRejectionHigh(level, grabBarIn, c, barIdx)
Parameters:
level (float)
grabBarIn (int)
c (float)
barIdx (int)
isFollowThroughRejectionLow(level, grabBarIn, c, barIdx)
Parameters:
level (float)
grabBarIn (int)
c (float)
barIdx (int)
isRejectedHigh(level, grabBarIn, wickMin, acceptBuf, o, h, l, c, barIdx)
Parameters:
level (float)
grabBarIn (int)
wickMin (float)
acceptBuf (float)
o (float)
h (float)
l (float)
c (float)
barIdx (int)
isRejectedLow(level, grabBarIn, wickMin, acceptBuf, o, h, l, c, barIdx)
Parameters:
level (float)
grabBarIn (int)
wickMin (float)
acceptBuf (float)
o (float)
h (float)
l (float)
c (float)
barIdx (int)
eventStateName(state)
Parameters:
state (int)
processHighLevel(level, trackedLevel, eventState, grabBar, grabLevel, minGrab, rejWindow, wickMin, acceptBuf, o, h, l, c, barIdx)
Parameters:
level (float)
trackedLevel (float)
eventState (int)
grabBar (int)
grabLevel (float)
minGrab (float)
rejWindow (int)
wickMin (float)
acceptBuf (float)
o (float)
h (float)
l (float)
c (float)
barIdx (int)
processLowLevel(level, trackedLevel, eventState, grabBar, grabLevel, minGrab, rejWindow, wickMin, acceptBuf, o, h, l, c, barIdx)
Parameters:
level (float)
trackedLevel (float)
eventState (int)
grabBar (int)
grabLevel (float)
minGrab (float)
rejWindow (int)
wickMin (float)
acceptBuf (float)
o (float)
h (float)
l (float)
c (float)
barIdx (int)
returnStateName(state)
Parameters:
state (int)
isInsideCrtRange(crtHighIn, crtLowIn, buffer, c)
Parameters:
crtHighIn (float)
crtLowIn (float)
buffer (float)
c (float)
processReturnLevel(level, trackedLevel, rejectPulseIn, returnStateIn, rejectBarIn, returnBarIn, crtHighIn, crtLowIn, crtReadyIn, retWindowIn, crtBufIn, c, barIdx)
Parameters:
level (float)
trackedLevel (float)
rejectPulseIn (bool)
returnStateIn (int)
rejectBarIn (int)
returnBarIn (int)
crtHighIn (float)
crtLowIn (float)
crtReadyIn (bool)
retWindowIn (int)
crtBufIn (float)
c (float)
barIdx (int)
isLegitGrabOpen(stateBefore, levelChanged)
Parameters:
stateBefore (int)
levelChanged (bool)
isLegitReturnFromReject(rejectPulse, returnStateBefore, rejectBarBefore)
Parameters:
rejectPulse (bool)
returnStateBefore (int)
rejectBarBefore (int)
amdInsideCrtCloseAt(barsBack, crtHighIn, crtLowIn, buffer, cSeries)
Parameters:
barsBack (int)
crtHighIn (float)
crtLowIn (float)
buffer (float)
cSeries (float)
amdCountPreGrabInsideCrt(grabOffsetIn, lookbackIn, crtHighIn, crtLowIn, buffer, cSeries)
Parameters:
grabOffsetIn (int)
lookbackIn (int)
crtHighIn (float)
crtLowIn (float)
buffer (float)
cSeries (float)
amdCountInsideCrtBetweenGrabSweep(grabOffsetIn, crtHighIn, crtLowIn, buffer, cSeries)
Parameters:
grabOffsetIn (int)
crtHighIn (float)
crtLowIn (float)
buffer (float)
cSeries (float)
entryConfirmCandleLong(sweptLevelIn, c, o, insideCrtIn)
Parameters:
sweptLevelIn (float)
c (float)
o (float)
insideCrtIn (bool)
entryConfirmCandleShort(sweptLevelIn, c, o, insideCrtIn)
Parameters:
sweptLevelIn (float)
c (float)
o (float)
insideCrtIn (bool)
tradeStateName(stateIn)
Parameters:
stateIn (int)
tradeStructStopLongPure(entryIn, bufIn, sweepLow, grabLow, tsLow, barLow)
Parameters:
entryIn (float)
bufIn (float)
sweepLow (float)
grabLow (float)
tsLow (float)
barLow (float)
tradeStructStopShortPure(entryIn, bufIn, sweepHigh, grabHigh, tsHigh, barHigh)
Parameters:
entryIn (float)
bufIn (float)
sweepHigh (float)
grabHigh (float)
tsHigh (float)
barHigh (float)
tradeStructTp1Long(entryIn, crtHighIn, crtLowIn, ratioIn)
Parameters:
entryIn (float)
crtHighIn (float)
crtLowIn (float)
ratioIn (float)
tradeStructTp1Short(entryIn, crtHighIn, crtLowIn, ratioIn)
Parameters:
entryIn (float)
crtHighIn (float)
crtLowIn (float)
ratioIn (float)
tradeStructTp2Long(crtHighIn)
Parameters:
crtHighIn (float)
tradeStructTp2Short(crtLowIn)
Parameters:
crtLowIn (float)
tradeStructTp3Long(entryIn, crtHighIn, pdhIn, pwhIn)
Parameters:
entryIn (float)
crtHighIn (float)
pdhIn (float)
pwhIn (float)
tradeStructTp3Short(entryIn, crtLowIn, pdlIn, pwlIn)
Parameters:
entryIn (float)
crtLowIn (float)
pdlIn (float)
pwlIn (float)
tradeCalcRRatio(entryIn, stopIn, targetIn)
Parameters:
entryIn (float)
stopIn (float)
targetIn (float)
tradeValidateLong(entryIn, stopIn, tp1In, tp2In, tp3In, minRRIn)
Parameters:
entryIn (float)
stopIn (float)
tp1In (float)
tp2In (float)
tp3In (float)
minRRIn (float)
tradeValidateShort(entryIn, stopIn, tp1In, tp2In, tp3In, minRRIn)
Parameters:
entryIn (float)
stopIn (float)
tp1In (float)
tp2In (float)
tp3In (float)
minRRIn (float)
tradeAuditInvalidReason(isLongIn, entryIn, stopIn, tp1In, tp2In, tp3In, minRRIn)
Parameters:
isLongIn (bool)
entryIn (float)
stopIn (float)
tp1In (float)
tp2In (float)
tp3In (float)
minRRIn (float)
tradeAuditOrderLongOk(entryIn, tp1In, tp2In, tp3In)
Parameters:
entryIn (float)
tp1In (float)
tp2In (float)
tp3In (float)
tradeAuditOrderShortOk(entryIn, tp1In, tp2In, tp3In)
Parameters:
entryIn (float)
tp1In (float)
tp2In (float)
tp3In (float)
tradeSimTp2OptA(isLongIn, tp1In, crtHighIn, crtLowIn, betaIn)
Parameters:
isLongIn (bool)
tp1In (float)
crtHighIn (float)
crtLowIn (float)
betaIn (float)
tradeSimTp2OptB(isLongIn, entryIn, stopIn, r2In)
Parameters:
isLongIn (bool)
entryIn (float)
stopIn (float)
r2In (float)
tradeSimTp2OptC(isLongIn, tp1In, tp3In, gammaIn)
Parameters:
isLongIn (bool)
tp1In (float)
tp3In (float)
gammaIn (float)
tradeSimFailsTp2(isLongIn, tp1In, tp2In, tp3In)
Parameters:
isLongIn (bool)
tp1In (float)
tp2In (float)
tp3In (float)
tradeSimFailsRR(entryIn, stopIn, tp1In, minRRIn)
Parameters:
entryIn (float)
stopIn (float)
tp1In (float)
minRRIn (float)
tradeAuditRRReason(entryIn, stopIn, tp1In, minRRIn)
Parameters:
entryIn (float)
stopIn (float)
tp1In (float)
minRRIn (float)
tradeAuditRequiredReward(riskIn, minRRIn)
Parameters:
riskIn (float)
minRRIn (float)
tradeAuditMissingReward(riskIn, actualRewardIn, minRRIn)
Parameters:
riskIn (float)
actualRewardIn (float)
minRRIn (float)
tradeAuditTp1ForMinRR(isLongIn, entryIn, stopIn, minRRIn)
Parameters:
isLongIn (bool)
entryIn (float)
stopIn (float)
minRRIn (float)
tradeAuditTp1Delta(tp1ActualIn, tp1NeedIn)
Parameters:
tp1ActualIn (float)
tp1NeedIn (float)
tradeAuditTp1NeedCrtRatio(riskIn, crtRangeIn, minRRIn)
Parameters:
riskIn (float)
crtRangeIn (float)
minRRIn (float)
tradeAuditTp1ActualCrtRatio(distEt1In, crtRangeIn)
Parameters:
distEt1In (float)
crtRangeIn (float) Library

TR Utility Library v6 ForkTR Utility Helpers v6 Fork is an open-source Pine Script v6 compatibility fork based on the publicly available Traders_Reality_Lib originally published by TradersReality.
This publication is not the original Traders Reality library and is not presented as an official update from the original author. All original concept credit, authorship credit, and recognition for the underlying Traders Reality workflow belong to TradersReality and the original creator(s).
Original source reference:
Traders_Reality_Lib by TradersReality.
Purpose of this publication:
The purpose of this fork is to provide a Pine Script v6-compatible utility library structure for scripts that require reusable helper functions related to PVSRA-style candle classification, ADR/range calculations, session handling, labels, lines, pivots, vector candle zones, psychological levels, and market-session countdown utilities.
This is a developer utility library. It is not a standalone trading indicator, not a signal system, and not a strategy.
Main function groups:
1. PVSRA-style candle classification
The library includes helper functions for classifying candles using volume and candle-spread behavior. These functions can return candle colors, alert flags, average volume, volume-spread values, and related classification data.
2. ADR and range helpers
The library includes Average Daily Range helper functions and ADR-based high/low projection functions. These can support scripts that need daily range reference levels or range-based chart tools.
3. Session calculation utilities
The library includes functions for parsing session strings, calculating session start and end timestamps, and handling sessions that cross midnight.
4. Session drawing helpers
The library includes reusable drawing helpers for opening ranges, session highs/lows, midpoint lines, labels, and shaded session boxes.
5. Daily open and timeframe utilities
The library includes helper functions for detecting new bars on selected resolutions, retrieving the daily open, and converting price movement into pips.
6. Label, line, and pivot helpers
The library contains reusable functions for right-aligned labels, last-bar labels, dynamic horizontal lines, daily-open lines, and pivot-style chart levels.
7. Vector candle zone helpers
The library includes helper functions for creating, updating, trimming, and cleaning vector candle zone boxes.
8. Psychological level helpers
The library includes functions for calculating psychological high/low reference levels based on selected timing logic and market type.
9. Session countdown helpers
The library includes functions for formatting milliseconds into readable time strings and calculating countdown text for market-session timing.
How to use this library:
This library is intended for Pine developers who want to import reusable helper functions into their own open-source or private scripts.
Example use cases include:
* PVSRA-style candle tools
* ADR and daily range tools
* Session high/low indicators
* Opening range indicators
* Pivot and level drawing tools
* Vector candle zone tools
* Market-session countdown panels
This library does not generate buy or sell signals by itself. Any trading logic, alerts, entries, exits, or visual systems must be implemented in the script that imports this library.
Originality and reuse clarification:
This publication is primarily a compatibility fork and utility organization resource. It is not presented as a new original trading methodology.
The underlying Traders Reality concepts and original library work are credited to the original creator(s). This fork is published open-source so users can inspect the code and verify the changes.
Limitations:
This library is a developer utility and should not be interpreted as financial advice. It does not provide buy or sell recommendations, does not execute trades, and does not guarantee any trading result.
Users and developers are responsible for testing any script that imports this library and for verifying that all calculations, visual outputs, and trading decisions fit their own requirements.
Library

AmendLogic Performance - Dynamic Matrix and Heatmap EngineOverview
AmendLogic_perf is a high-performance analytics utility library designed for Pine Script v6 strategy scripts. It automates the calculation, compounding, and visual rendering of closed and rolling equity structures into a clean, institutional-grade monthly and yearly return matrix.By separating performance rendering from your core entry/exit logic, your scripts remain lean, scannable, and modular.
Key Features
Real-Time Compounding Engine: Continuously tracks equity variations bar-by-bar, automatically computing exact monthly and yearly percentage returns ($P\&L$) alongside raw monetary value gains.
Smart History Reconstruction: Uses dynamic accumulators and arrays to handle historical lookback state tracking. It dynamically pushes and corrects current-period metrics on the final live bar (barstate.islast) without missing real-time fractional ticks.
Proportional Heatmap Scaling (f_getAlpha): Evaluates overall strategic history to locate relative historical maximums and minimums. The library automatically calibrates color transparency to match performance weight: highly profitable months or deep drawdowns receive intense color depth, while neutral periods gracefully fade into a subtle tint.
Native Ecosystem Visual Integration: Deeply integrated with the AmendLogic_css_SEC layout library. The matrix auto-adjusts its borders, cell text, and deep-space canvas framing to remain readable across both light and dark chart layouts.
How to Use (Quick Start)
To append this performance reporting dashboard directly to your strategy, reference the library at the top of your script and pass your live equity array at the final execution layer:
//@version=6
strategy("My Custom Quant Strategy", overlay=true, initial_capital=10000)
// 1. Import the performance matrix library
import Kevinroku/AmendLogic_perf_SEC/1 as perf
// ── ──
longCondition = ta.crossover(ta.sma(close, 14), ta.sma(close, 50))
if (longCondition)
strategy.entry("Long", strategy.long)
// 2. Pass the strategy equity into the engine at the very end
perf.ProfitTable(strategy.equity)
Interface Layout & Output MetricsPosition: Fixed to the bottom_right quadrant of your workstation screen to maintain unobstructed viewing of historical price bars.
Row Headers: Dynamically maps out historical years discovered within your dataset profile.
Column Tracks: Standardized 12-month sequence (Jan – Dec) completed by a bolded cumulative "Year" metrics tracking column.
Color Schemes: Standardizes emerald-green zones for expansion sequences and crimson-red highlights for contraction drawdowns.
Library

AmendLogic CSS - Brand and Semantic Color LibraryOverview
AmendLogic_CSS is a centralized style and theme utility library for Pine Script v6. It provides a standardized color palette designed to maintain visual consistency across indicators, strategies, and UI components. By shifting color management to a library, scripts stay clean, modular, and easy to maintain.
Key Features
Unified Brand Identity: Access core AmendLogic brand colors ("blue", "cyan", "purple", etc.) instantly via a single wrapper function.
Semantic Trade Layering: Includes a pre-graded 5-tier Take-Profit color matrix ("tp1" to "tp5") to design clean, incremental scaling visuals on your charts.
Adaptive Theme Detection ("colorVar"): Features a built-in environment check. It analyzes the user's current chart background on the fly, dynamically switching text/line elements between light and dark modes to guarantee perfect contrast and readability.
Inline Alpha Control: The getColor() function supports a native transparency parameter ($0$ to $100$), removing the need to wrap color outputs in separate color.new() calls manually.
How to Use (Quick Start)
To implement this design framework into your own indicators or strategies, simply import the library at the top of your script and query your desired color string:
//@version=6
indicator("My Custom Indicator", overlay=true)
// 1. Import the library
import Kevinroku/AmendLogic_css_SEC/1 as css
// 2. Fetch semantic or adaptive colors with custom transparency
brandBlue = css.getColor("blue")
stopLossRed = css.getColor("red", t = 50)
uiText = css.getColor("colorVar") // Automatically flips based on dark/light mode
// 3. Apply to your plots, lines, or boxes
plot(close, color=brandBlue)
Available Color IDs:
Brand: "blue", "cyan", "purple", "gray", "black"
UI Semantics: "green", "red", "yellow"
Targets: "tp1", "tp2", "tp3", "tp4", "tp5"
Adaptive: "colorVar" (Dynamic contrast toggle)
Library

lib_fvgLibrary "lib_fvg"
Fair Value Gap engine — detection, testing/inversion lifecycle, HTF nesting filters, entry-candidate selection, stop-loss derivation, and FVG drawing — extracted 1:1 from rewrite_strategy.pine.
method equals(this, other)
Namespace types: FVG
Parameters:
this (FVG)
other (FVG)
method remove(this, item)
Namespace types: array
Parameters:
this (array)
item (FVG)
method check_nested_in(this, htf_fvg, check_nested, check_untested, check_nearby, nearby_threshold, check_newer_ltf)
Namespace types: FVG
Parameters:
this (FVG)
htf_fvg (FVG)
check_nested (bool)
check_untested (bool)
check_nearby (bool)
nearby_threshold (float)
check_newer_ltf (bool)
method distance_to_price_post_inverse(this, price)
Namespace types: FVG
Parameters:
this (FVG)
price (float)
method is_higher_tf_or_closer_to_price_than(this, other)
Namespace types: FVG
Parameters:
this (FVG)
other (FVG)
method get_stop_loss(this, entry_price, session_extreme, enable_sl_at_fvg_created_swing_point, trail_session_level_tight_threshold)
Namespace types: FVG
Parameters:
this (FVG)
entry_price (float)
session_extreme (float)
enable_sl_at_fvg_created_swing_point (bool)
trail_session_level_tight_threshold (float)
method delete_bar(this)
Namespace types: Bar
Parameters:
this (Bar)
method delete_fvg(this)
Namespace types: FVG
Parameters:
this (FVG)
log_entry_rejection(enable_log, fvg, reason, smt, note)
Parameters:
enable_log (bool)
fvg (FVG)
reason (series EntryFilterReason)
smt (SMT type from Danieltrade29292/lib_smt/1)
note (string)
method invalidate_fvg(this, fvg, reason, entry_block_reason, lifecycle)
Namespace types: FVGBuffer
Parameters:
this (FVGBuffer)
fvg (FVG)
reason (series FVGFilterReason)
entry_block_reason (series EntryFilterReason)
lifecycle (series FVGLifecycle)
method add_fvg(this, fvg, enable_single_fvg_per_tf)
Namespace types: FVGBuffer
Parameters:
this (FVGBuffer)
fvg (FVG)
enable_single_fvg_per_tf (bool)
method detect_fvg(this, tf, tf_id, t2, h2, l2, h1, l1, h0, l0, min_gap_size, fvg_deprecation_period, enable_single_fvg_per_tf)
Namespace types: FVGBuffer
Parameters:
this (FVGBuffer)
tf (string)
tf_id (int)
t2 (int)
h2 (float)
l2 (float)
h1 (float)
l1 (float)
h0 (float)
l0 (float)
min_gap_size (float)
fvg_deprecation_period (int)
enable_single_fvg_per_tf (bool)
method invalidate_all_of_direction(this, fvg_is_bullish, reason)
Namespace types: FVGBuffer
Parameters:
this (FVGBuffer)
fvg_is_bullish (bool)
reason (series FVGFilterReason)
method invalidate_fvgs_inversed_pre_smt(this, smt_buffer, enable_log)
Namespace types: FVGBuffer
Parameters:
this (FVGBuffer)
smt_buffer (SMTBuffer type from Danieltrade29292/lib_smt/1)
enable_log (bool)
method try_park_in(this, htf_pool, check_nested, check_untested, check_nearby, nearby_threshold, check_newer_ltf)
Namespace types: FVG
Parameters:
this (FVG)
htf_pool (array)
check_nested (bool)
check_untested (bool)
check_nearby (bool)
nearby_threshold (float)
check_newer_ltf (bool)
method update_htf_relations(this, enable_filter_by_full_nest_in_HTF_fvg, enable_filter_by_untested, enable_filter_by_edge_nearby_HTF_fvg, nearby_HTF_threshold, enable_filter_by_newer_LTF_fvg)
Namespace types: FVGBuffer
Parameters:
this (FVGBuffer)
enable_filter_by_full_nest_in_HTF_fvg (bool)
enable_filter_by_untested (bool)
enable_filter_by_edge_nearby_HTF_fvg (bool)
nearby_HTF_threshold (float)
enable_filter_by_newer_LTF_fvg (bool)
method update_fvgs(this, tf2, tf2_updated, fvg2_o, fvg2_h, fvg2_l, fvg2_c, tf3, tf3_updated, fvg3_o, fvg3_h, fvg3_l, fvg3_c, tf4, tf4_updated, fvg4_o, fvg4_h, fvg4_l, fvg4_c, min_inversion_distance, max_inversion_distance, tested_by_mode, max_tests_before_inverse)
Namespace types: FVGBuffer
Parameters:
this (FVGBuffer)
tf2 (string)
tf2_updated (bool)
fvg2_o (float)
fvg2_h (float)
fvg2_l (float)
fvg2_c (float)
tf3 (string)
tf3_updated (bool)
fvg3_o (float)
fvg3_h (float)
fvg3_l (float)
fvg3_c (float)
tf4 (string)
tf4_updated (bool)
fvg4_o (float)
fvg4_h (float)
fvg4_l (float)
fvg4_c (float)
min_inversion_distance (float)
max_inversion_distance (float)
tested_by_mode (series FVGTestedByMode)
max_tests_before_inverse (int)
method find_next_best_waiting_fvgs(this, smt_buffer)
Namespace types: FVGBuffer
Parameters:
this (FVGBuffer)
smt_buffer (SMTBuffer type from Danieltrade29292/lib_smt/1)
method find_entry_candidate_fvg(this, smt_buffer, enable_filter_by_inversion_bar_close_in_untested_HTF_fvg, enable_log)
Namespace types: FVGBuffer
Parameters:
this (FVGBuffer)
smt_buffer (SMTBuffer type from Danieltrade29292/lib_smt/1)
enable_filter_by_inversion_bar_close_in_untested_HTF_fvg (bool)
enable_log (bool)
method draw_bar(this, is_bullish, bgcolor, border_color, labelcolor, txt, show_box)
Namespace types: Bar
Parameters:
this (Bar)
is_bullish (bool)
bgcolor (color)
border_color (color)
labelcolor (color)
txt (string)
show_box (bool)
method draw_fvg(this, color_bull, color_bear, debug)
Namespace types: FVG
Parameters:
this (FVG)
color_bull (color)
color_bear (color)
debug (bool)
method draw_fvgs(this, color_bull, color_bear, debug)
Namespace types: array
Parameters:
this (array)
color_bull (color)
color_bear (color)
debug (bool)
method draw_entry_fvg(this, color_bull, color_bear, debug)
Namespace types: FVG
Parameters:
this (FVG)
color_bull (simple color)
color_bear (simple color)
debug (bool)
method delete_fvgs(this)
Namespace types: array
Parameters:
this (array)
Bar
Fields:
o (series float)
h (series float)
l (series float)
c (series float)
top (series float)
btm (series float)
t_open (series int)
i_open (series int)
t_close (series int)
i_close (series int)
bar_box (series box)
bar_label (series label)
FVG
Fields:
is_bullish_original (series bool)
is_bullish_post_inverse (series bool)
tf (series string)
tf_id (series int)
top_left (chart.point)
bottom_right (chart.point)
hh (series float)
ll (series float)
deprecate_at (series int)
sl_level (series float)
is_active (series bool)
test_count (series int)
first_test_idx (series int)
is_inversed (series bool)
has_touched (series bool)
fvg_box (series box)
tooltip_label (series label)
hidden (series bool)
draw_signal_inversed (series bool)
draw_signal_text (series bool)
draw_signal_highlight (series bool)
draw_signal_set_candidate (series bool)
draw_signal_reset_candidate (series bool)
fill_state (series FVGFillState)
lifecycle (series FVGLifecycle)
filter_reason (series FVGFilterReason)
entry_filter_reason (series EntryFilterReason)
tf_inversion_bar (Bar)
inversion_idx (series int)
FVGBuffer
Fields:
items (array)
inversed (array)
invalidated (array) Library

lib_smtLibrary "lib_smt"
SMT divergence + session detection/lifecycle, SMT buffers, premium/discount zones, and their on-chart drawing — extracted 1:1 from rewrite_strategy.pine.
method equals(this, other)
Namespace types: SMT
Parameters:
this (SMT)
other (SMT)
method delete_smt(this)
Namespace types: SMT
Parameters:
this (SMT)
method delete_smts(this)
Namespace types: array
Parameters:
this (array)
method replace(this, value)
Namespace types: array
Parameters:
this (array)
value (Session)
method replace(sess, idx, value, remove_buffer)
Namespace types: array
Parameters:
sess (array)
idx (int)
value (Session)
remove_buffer (array)
method reset(this)
Namespace types: SessionSignals
Parameters:
this (SessionSignals)
method reset(this)
Namespace types: SessionLevel
Parameters:
this (SessionLevel)
method reset(this)
Namespace types: Session
Parameters:
this (Session)
method invalidate_smt(this, smt, reason)
Namespace types: SMTBuffer
Parameters:
this (SMTBuffer)
smt (SMT)
reason (series SMTFilterReason)
method invalidate_session(this, sess, reason)
Namespace types: SMTBuffer
Parameters:
this (SMTBuffer)
sess (Session)
reason (series SMTFilterReason)
method set_intra(this, smt)
Namespace types: SMTBuffer
Parameters:
this (SMTBuffer)
smt (SMT)
method reset_intra(this, reason, sess, reset_bull, reset_bear)
Namespace types: SMTBuffer
Parameters:
this (SMTBuffer)
reason (series SMTFilterReason)
sess (Session)
reset_bull (bool)
reset_bear (bool)
method invalidate_all_daily_smts(this, reason)
Namespace types: SMTBuffer
Parameters:
this (SMTBuffer)
reason (series SMTFilterReason)
method invalidate_all_session_smts(this, is_bullish, reason)
Namespace types: SMTBuffer
Parameters:
this (SMTBuffer)
is_bullish (bool)
reason (series SMTFilterReason)
method invalidate_entry_daily_smt(this, entry_smt, reason)
Namespace types: SMTBuffer
Parameters:
this (SMTBuffer)
entry_smt (SMT)
reason (series SMTFilterReason)
method invalidate_by_detected_session_id(this, id, reason)
Namespace types: SMTBuffer
Parameters:
this (SMTBuffer)
id (int)
reason (series SMTFilterReason)
method invalidate_swept_sessions(this, session_signals, overflow_buffer)
Namespace types: SMTBuffer
Parameters:
this (SMTBuffer)
session_signals (SessionSignals)
overflow_buffer (array)
method add_smt(this, smt)
Namespace types: SMTBuffer
Parameters:
this (SMTBuffer)
smt (SMT)
method update_smt(this, other_high, other_low, smt_buffer, enable_invalidation_by_distance, invalidation_dist_chart_led, invalidation_dist_other_led)
Namespace types: SMT
Parameters:
this (SMT)
other_high (float)
other_low (float)
smt_buffer (SMTBuffer)
enable_invalidation_by_distance (bool)
invalidation_dist_chart_led (float)
invalidation_dist_other_led (float)
method update_smts(this, other_high, other_low, enable_invalidation_by_distance, invalidation_dist_chart_led, invalidation_dist_other_led)
Namespace types: SMTBuffer
Parameters:
this (SMTBuffer)
other_high (float)
other_low (float)
enable_invalidation_by_distance (bool)
invalidation_dist_chart_led (float)
invalidation_dist_other_led (float)
method update_session_level_sweeps(this, other_high, other_low)
Namespace types: Session
Parameters:
this (Session)
other_high (float)
other_low (float)
method detect_smt(this, smt_h1, smt_l1, smt_c1, smt_other_h1, smt_other_l1, is_smt_tf_new_bar, smt_buffer, active_session_id, smt_min_age, is_intra, is_blocked_intra_smt_bull, is_blocked_intra_smt_bear, timeout_intra, touch_tolerance, intra_min_swing_age)
─────────────────────────────────────────────────────────────────────────────
session.detect_smt — check if chart/other has swept H or L
§2.2.1 Level SMT Detection / §2.2.2 Daily SMT Detection / §2.2.3 Intra SMT Detection
is_intra=true → called on live active session (§2.2.3); uses running H/L, equal high/low counts
is_intra=false → called on archived session (§2.2.1/§2.2.2); levels are fixed at capture time
active_session_id: session currently open, stored as detected_session_id on new SMTs
so §2.3.2 London-detected invalidation can filter correctly on NY open
─────────────────────────────────────────────────────────────────────────────
Namespace types: Session
Parameters:
this (Session)
smt_h1 (float)
smt_l1 (float)
smt_c1 (float)
smt_other_h1 (float)
smt_other_l1 (float)
is_smt_tf_new_bar (bool)
smt_buffer (SMTBuffer)
active_session_id (int)
smt_min_age (int)
is_intra (bool)
is_blocked_intra_smt_bull (bool)
is_blocked_intra_smt_bear (bool)
timeout_intra (int)
touch_tolerance (float)
intra_min_swing_age (int)
method detect_smts(this, signals, smt_h1, smt_l1, smt_c1, smt_other_h1, smt_other_l1, is_smt_tf_new_bar, smt_buffer, active_session_id, smt_min_age, touch_tolerance)
Namespace types: array
Parameters:
this (array)
signals (SessionSignals)
smt_h1 (float)
smt_l1 (float)
smt_c1 (float)
smt_other_h1 (float)
smt_other_l1 (float)
is_smt_tf_new_bar (bool)
smt_buffer (SMTBuffer)
active_session_id (int)
smt_min_age (int)
touch_tolerance (float)
method has_active_daily_smt(this, seeks_bullish)
Namespace types: SMTBuffer
Parameters:
this (SMTBuffer)
seeks_bullish (bool)
method find_best_smt_by_prio(this, minimum_prio, seeks_bullish)
Namespace types: array
Parameters:
this (array)
minimum_prio (int)
seeks_bullish (bool)
method find_best_smt_by_direction(this, intra_smts_enabled, seeks_bullish)
Namespace types: SMTBuffer
Parameters:
this (SMTBuffer)
intra_smts_enabled (bool)
seeks_bullish (bool)
method update_best_smts(this, pd_zone, intra_smts_enabled, allow_bullish_intra_smt_post_cutoff_if_has_daily_smt_active, allow_bearish_intra_smt_post_cutoff_if_has_daily_smt_active)
Namespace types: SMTBuffer
Parameters:
this (SMTBuffer)
pd_zone (int)
intra_smts_enabled (bool)
allow_bullish_intra_smt_post_cutoff_if_has_daily_smt_active (bool)
allow_bearish_intra_smt_post_cutoff_if_has_daily_smt_active (bool)
method rotate(this, sess, max)
Namespace types: array
Parameters:
this (array)
sess (Session)
max (int)
method add_session(this, sess, overflow_buffer)
Namespace types: SMTBuffer
Parameters:
this (SMTBuffer)
sess (Session)
overflow_buffer (array)
method evict_consumed_days(this, overflow_buffer, max_history_days)
Namespace types: SMTBuffer
Parameters:
this (SMTBuffer)
overflow_buffer (array)
max_history_days (simple int)
method clear_invalidated_smts(this, keep_level, keep_intra, keep_reason)
Namespace types: SMTBuffer
Parameters:
this (SMTBuffer)
keep_level (bool)
keep_intra (bool)
keep_reason (bool)
method archive(this)
Namespace types: SessionLevel
Parameters:
this (SessionLevel)
method archive(this)
Namespace types: Session
Parameters:
this (Session)
method update_levels(this, is_smt_tf_new_bar, other_high, other_low, smt_t1, smt_h1, smt_l1, smt_other_h1, smt_other_l1)
Namespace types: Session
Parameters:
this (Session)
is_smt_tf_new_bar (bool)
other_high (float)
other_low (float)
smt_t1 (int)
smt_h1 (float)
smt_l1 (float)
smt_other_h1 (float)
smt_other_l1 (float)
method update_session(this, signals, smt_buffer, new_day, other_high, other_low, smt_t1, smt_h1, smt_l1, smt_c1, smt_other_h1, smt_other_l1, is_smt_tf_new_bar, smt_min_age, timeout_intra, in_any_no_intra_smt_zone, enable_block_intra_smts_pre_high_prio_sweep, previous_session, intra_min_swing_age)
Namespace types: Session
Parameters:
this (Session)
signals (SessionSignals)
smt_buffer (SMTBuffer)
new_day (bool)
other_high (float)
other_low (float)
smt_t1 (int)
smt_h1 (float)
smt_l1 (float)
smt_c1 (float)
smt_other_h1 (float)
smt_other_l1 (float)
is_smt_tf_new_bar (bool)
smt_min_age (int)
timeout_intra (int)
in_any_no_intra_smt_zone (bool)
enable_block_intra_smts_pre_high_prio_sweep (bool)
previous_session (Session)
intra_min_swing_age (int)
method draw_session(this, show_chart, show_panel)
Namespace types: Session
Parameters:
this (Session)
show_chart (bool)
show_panel (bool)
method draw_session_consumed(this)
Namespace types: Session
Parameters:
this (Session)
method delete(this)
Namespace types: Session
Parameters:
this (Session)
method delete(this)
Namespace types: array
Parameters:
this (array)
method register(this, enabled, session, _fill_color, _text, _text_color, _border_color, prio, id, is_daily, is_session, enable_intra_smts, is_no_intra_smt_zone, smt_timeout, strategy_config)
Namespace types: array
Parameters:
this (array)
enabled (bool)
session (string)
_fill_color (color)
_text (string)
_text_color (color)
_border_color (color)
prio (int)
id (int)
is_daily (bool)
is_session (bool)
enable_intra_smts (bool)
is_no_intra_smt_zone (bool)
smt_timeout (int)
strategy_config (StrategyConfig)
method short_id(this)
Namespace types: SMT
Parameters:
this (SMT)
method label_text(this, other_ticker, include_filter_reason, is_leader)
Namespace types: SMT
Parameters:
this (SMT)
other_ticker (string)
include_filter_reason (bool)
is_leader (bool)
method draw_smt(this, other_ticker, show_label_leader, show_label_follower, verbose)
Namespace types: SMT
Parameters:
this (SMT)
other_ticker (string)
show_label_leader (bool)
show_label_follower (bool)
verbose (bool)
method draw_smts(this, other_ticker, show_label_leader, show_label_follower, show_filter_reason)
Namespace types: array
Parameters:
this (array)
other_ticker (string)
show_label_leader (bool)
show_label_follower (bool)
show_filter_reason (bool)
get_pd_range(enable, bars_lookback, new_hour)
Parameters:
enable (simple bool)
bars_lookback (int)
new_hour (bool)
draw_pd(new_hour, pd_start, pd_high, pd_equilibrium, pd_low)
Parameters:
new_hour (bool)
pd_start (int)
pd_high (float)
pd_equilibrium (float)
pd_low (float)
SMT
Fields:
detected_session_id (series int)
leader (series int)
leader_level (chart.point)
sweep (chart.point)
follow_level (chart.point)
session_id (series int)
prio (series int)
is_bullish (series bool)
deprecate_at (series int)
detection_bar (series int)
detection_close (series float)
valid_from (series int)
invalidated (series bool)
filter_reason (series SMTFilterReason)
leader_line (series line)
leader_label (series label)
follow_line (series line)
follow_intermediate_line (series line)
follow_label (series label)
smt_color (series color)
draw_remove_highlight (series bool)
used_for_trade (series bool)
trade_end_time (series int)
SessionLevel
tracks session H/L
Fields:
chart (chart.point)
other (chart.point)
chart_smt_tf (chart.point)
other_smt_tf (chart.point)
is_consumed (series bool)
smt (SMT)
StrategyConfig
Fields:
big_win_threshold (series float)
cutoff_hour (series int)
cutoff_tz (series string)
cutoff_mode (series SessionCutoffMode)
max_losses (series int)
max_wins (series int)
Session
Fields:
id (series int)
prio (series int)
timeout (series int)
session (series string)
h (SessionLevel)
l (SessionLevel)
_fill_color (series color)
_text (series string)
_text_color (series color)
_border_color (series color)
is_daily (series bool)
is_session (series bool)
is_no_intra_smt_zone (series bool)
enable_intra_smts (series bool)
strategy_config (StrategyConfig)
start_time (series int)
end_time (series int)
cutoff_at (series int)
is_active (series bool)
is_consumed (series bool)
box_chart (series box)
box_other (series box)
mean_sum (series float)
mean_count (series float)
mean (series float)
is_any_low_swept (series bool)
is_any_high_swept (series bool)
draw_signal_consumed (series bool)
tooltip_chart (series label)
tooltip_other (series label)
SessionSignals
Fields:
signal_session_started (series int)
signal_session_ending (series int)
signal_session_ended (series int)
signal_no_intra_smt_zone_started (series int)
signal_no_intra_smt_zone_ending (series int)
signal_no_intra_smt_zone_ended (series int)
signal_intra_smt_h (series int)
signal_intra_smt_l (series int)
signal_session_consumed (series bool)
SMTBuffer
Fields:
session_smts (array)
daily_smts (array)
intra_smts (array)
invalidated (array)
delete_buffer (array)
monitored_sessions (array)
monitored_days (array)
consumed_days (array)
max_days (series int)
best_bull_smt (SMT)
best_bear_smt (SMT) Library

AuditProtocolAuditProtocol
Every indicator makes claims. "This signal has edge." "Price stays inside these bands." Almost none of them keep score. I built this library so keeping score becomes a three line habit: import it, register your claims, and let the tape settle them. Any indicator can wear a live, lookahead free audit of itself.
What's inside
Prequal is a prequential tracker for probability forecasts. You register a probability before the outcome and resolve it after the outcome is real, never the other way around. It tracks hit rate and the Brier score, the proper scoring rule for probability forecasts, plus Brier skill against a coin flip.
Coverage is for bands and intervals. If your band claims 90% containment, this tracks what it actually delivered, target next to realized, recent and lifetime.
Conformal learns the width multiplier that makes any band honest. Feed it your normalized residuals and ask it for k(). Your band, resized until the coverage is real. This is the split conformal quantile method, applied to whatever band you already draw.
Barrier settles setups by first touch: target barrier or stop barrier, whichever the tape hits first. A nod to triple barrier labeling. Ties inside a single bar go to the stop, conservative by design.
The Audit Score compresses it into one 0 to 100 number. Calibration earns up to 50 points. Demonstrated skill earns the other 50. So an honest indicator with zero edge sits near 50. That's the anchor: 50 is sea level, everything above it is earned, and anything well below it is miscalibrated.
The Receipt is the standard panel. Claims on the left, reality on the right.
How to use it
import YOUR_HANDLE/AuditProtocol/1 as ap
var pq = ap.newPrequal()
var c90 = ap.newCoverage(90)
if barstate.isconfirmed
ap.resolve(pq, close > close ) // settle yesterday's call
ap.resolveInterval(c90, close) // settle yesterday's band
ap.predict(pq, myProbabilityUp) // register today's call
ap.setInterval(c90, myLo, myHi) // register today's band
ap.panel(pq, c90, na, position.top_right)
//////////////////////////////////////////////////////////////////////
Library "AuditProtocol"
newPrequal(emaAlpha)
Creates a prequential tracker.
Parameters:
emaAlpha (float) : EMA rate for the live (recent) readings. Default 0.02.
Returns: A fresh Prequal tracker.
method predict(this, p)
Registers a probability forecast (P of the outcome being TRUE) for the NEXT resolution. Call AFTER resolve() in the same confirmed-bar block.
Namespace types: Prequal
Parameters:
this (Prequal)
p (float)
method resolve(this, outcome)
Resolves the pending forecast against the realized outcome. Call once per confirmed bar BEFORE registering the next forecast.
Namespace types: Prequal
Parameters:
this (Prequal)
outcome (bool)
method hitRate(this)
Lifetime hit rate in percent, or na before any resolution.
Namespace types: Prequal
Parameters:
this (Prequal)
method skill(this)
Brier skill score vs the coin-flip baseline: 1 - Brier/0.25. 0 = no skill, 1 = perfect, negative = worse than guessing.
Namespace types: Prequal
Parameters:
this (Prequal)
newCoverage(targetPct, emaAlpha)
Creates a coverage tracker for a band claiming `targetPct` percent containment.
Parameters:
targetPct (float)
emaAlpha (float)
method setInterval(this, lo, hi)
Registers the band that should contain the NEXT observation.
Namespace types: Coverage
Parameters:
this (Coverage)
lo (float)
hi (float)
method resolveInterval(this, x)
Resolves the pending band against the realized value.
Namespace types: Coverage
Parameters:
this (Coverage)
x (float)
method realized(this)
Lifetime realized coverage in percent, or na before any resolution.
Namespace types: Coverage
Parameters:
this (Coverage)
method covError(this)
Absolute calibration error in percentage points: |realized - target|. na before any resolution.
Namespace types: Coverage
Parameters:
this (Coverage)
newConformal(targetPct, window, warmup)
Creates a conformal scaler. Feed it |realized error| / your band's unit width; ask it for k().
Parameters:
targetPct (float)
window (int)
warmup (int)
method observe(this, normResid)
Records one realized normalized residual (e.g. |close - center| / sigma).
Namespace types: Conformal
Parameters:
this (Conformal)
normResid (float)
method k(this, fallback)
The learned width multiplier: the target-quantile of observed residuals. Returns `fallback` until warm. Band = center ± k() * unitWidth delivers ~target coverage.
Namespace types: Conformal
Parameters:
this (Conformal)
fallback (float)
newBarrier()
Creates a barrier tracker for first-touch setup outcomes.
method arm(this, target, stop)
Arms a setup: which barrier must be touched first for a win (tgt) vs a loss (stp).
Namespace types: Barrier
Parameters:
this (Barrier)
target (float)
stop (float)
method check(this, barHigh, barLow)
Checks the current bar. Returns +1 (target first), -1 (stop first), 0 (still open). If both are inside one bar, the stop wins: conservative by design.
Namespace types: Barrier
Parameters:
this (Barrier)
barHigh (float)
barLow (float)
method winRate(this)
Lifetime win rate of resolved setups in percent, or na.
Namespace types: Barrier
Parameters:
this (Barrier)
score(pq, cA, cB, minN)
The composite 0-100 audit score. Calibration earns up to 50 points
(25 per coverage tracker; pass the same tracker twice if you only
have one band). Skill earns up to 50 (Brier skill vs coin flip).
Returns na until minN resolutions on the prequential tracker.
Parameters:
pq (Prequal)
cA (Coverage)
cB (Coverage)
minN (int)
panel(pq, cA, cB, pos)
Renders the Receipt, the standard audit panel. Pass na for trackers you don't use.
Parameters:
pq (Prequal)
cA (Coverage)
cB (Coverage)
pos (string)
Prequal
Fields:
pPend (series float)
accEma (series float)
brierEma (series float)
hits (series int)
n (series int)
emaA (series float)
Coverage
Fields:
target (series float)
loPend (series float)
hiPend (series float)
covEma (series float)
hits (series int)
n (series int)
emaA (series float)
Conformal
Fields:
resid (array)
target (series float)
win (series int)
warm (series int)
Barrier
Fields:
tgt (series float)
stp (series float)
live (series bool)
wins (series int)
losses (series int) Library

MarketReactionLibrary "MarketReaction"
Modular library for sessions, Initial Balance, PSY ranges, VWAPs, alerts, and macro sentiment helpers.
getSessionConfig(source)
Returns session config by source name.
Parameters:
source (simple string) : Session source: Tokyo, New York, London, Jerusalem, EU B, US B.
Returns: SessionConfig.
sessionModule(session, timeZone, sessionText, sessionColor, sessionDuration, showVisuals, showLabels, showLines, showMiddleLine, showBg, bgTransp)
Builds session high/low/middle lines, label, background fill and VWAP.
Parameters:
session (simple string) : Session string.
timeZone (simple string) : IANA timezone.
sessionText (simple string) : Label text.
sessionColor (color) : Session color.
sessionDuration (simple int) : Approximate session duration in ms.
showVisuals (bool) : Show this session visuals.
showLabels (bool) : Show labels.
showLines (bool) : Show high/low lines.
showMiddleLine (bool) : Show middle line.
showBg (bool) : Show background fill.
bgTransp (int) : Background transparency.
Returns: SessionResult.
initialBalanceModule(session, ibSession, timeZone, sessionLabel, showDLabels, showWLabels, showMLabels, showPrevD, showPrevW, showPrevM, dColor, wColor, mColor)
Calculates Daily, Weekly, Monthly Initial Balance and W/M IB VWAPs.
Parameters:
session (simple string) : Full session string.
ibSession (simple string) : IB sub-session string.
timeZone (simple string) : IANA timezone.
sessionLabel (simple string) : Session label.
showDLabels (bool) : Show D.IB labels.
showWLabels (bool) : Show W.IB labels.
showMLabels (bool) : Show M.IB labels.
showPrevD (bool) : Calculate previous daily IB.
showPrevW (bool) : Calculate previous weekly IB.
showPrevM (bool) : Calculate previous monthly IB.
dColor (color) : Daily IB label color.
wColor (color) : Weekly IB label color.
mColor (color) : Monthly IB label color.
Returns: IBResult.
psyRangeModule(session, timeZone, showLabels, showPrev, sessionColor)
Calculates PSY high/low, previous PSY levels, labels, and VWAP.
Parameters:
session (simple string) : Session string.
timeZone (simple string) : Timezone.
showLabels (bool) : Show PSY labels.
showPrev (bool) : Show previous PSY levels.
sessionColor (color) : PSY color.
Returns: PSYResult.
rangeSignal(highLevel, lowLevel, price)
Returns enter/exit signals for a range.
Parameters:
highLevel (float) : Range high.
lowLevel (float) : Range low.
price (float) : Price source.
Returns: RangeSignal.
tablePosition(pos)
Converts table position string to Pine position.
Parameters:
pos (simple string) : Position text.
Returns: Pine table position.
SessionConfig
Session configuration.
Fields:
session (series string) : Full session time.
ib (series string) : Initial Balance sub-session time.
tz (series string) : Session timezone.
label (series string) : Session label.
col (series color) : Session color.
duration (series int) : Approximate session duration in milliseconds.
SessionResult
Session result.
Fields:
high (series float) : Session high.
low (series float) : Session low.
mid (series float) : Session middle.
vwap (series float) : Session VWAP.
inSession (series bool) : True if bar is inside session.
firstBar (series bool) : True on first session bar.
highLine (series line) : Session high line.
lowLine (series line) : Session low line.
midLine (series line) : Session middle line.
IBResult
Initial Balance result.
Fields:
dHigh (series float) : Daily IB high.
dLow (series float) : Daily IB low.
pdHigh (series float) : Previous daily IB high.
pdLow (series float) : Previous daily IB low.
wHigh (series float) : Weekly IB high.
wLow (series float) : Weekly IB low.
pwHigh (series float) : Previous weekly IB high.
pwLow (series float) : Previous weekly IB low.
mHigh (series float) : Monthly IB high.
mLow (series float) : Monthly IB low.
pmHigh (series float) : Previous monthly IB high.
pmLow (series float) : Previous monthly IB low.
wVwap (series float) : Weekly IB VWAP.
mVwap (series float) : Monthly IB VWAP.
inSession (series bool) : True if bar is inside selected full session.
inIB (series bool) : True if bar is inside selected IB session.
ibFirstBar (series bool) : True on first IB bar.
sessionFirstBar (series bool) : True on first full-session bar.
PSYResult
PSY range result.
Fields:
high (series float) : Current PSY high.
low (series float) : Current PSY low.
pHigh (series float) : Previous PSY high.
pLow (series float) : Previous PSY low.
vwap (series float) : PSY VWAP.
inSession (series bool) : True if bar is inside PSY range.
firstBar (series bool) : True on first PSY bar.
RangeSignal
Range signal result.
Fields:
enter (series bool) : True when price enters range.
exit (series bool) : True when price exits range.
topDn (series bool) : Crossunder from above high.
topUp (series bool) : Crossover above high.
botUp (series bool) : Crossover from below low.
botDn (series bool) : Crossunder below low. Library
