TargetExcursionQueueLibLibrary "TargetExcursionQueueLib"
helper lib for targetExcursionLib
f_queue_new(horizon)
Construct a fixed ring. Horizon is clamped to the supported 1..198 range.
Parameters:
horizon (int)
method advance(queue, pathHigh, pathLow, pathClose, pathValid, currentBar)
Update every unresolved path with this confirmed chart bar and
resolve the oldest origin exactly H chart bars after it was accepted.
Invalid path bars invalidate the affected target instead of hiding a gap.
Namespace types: PendingQueue
Parameters:
queue (PendingQueue)
pathHigh (float)
pathLow (float)
pathClose (float)
pathValid (bool)
currentBar (int)
method enqueue(queue, direction, origin, scale, currentBar)
Freeze one valid, non-neutral origin after older origins have advanced.
Namespace types: PendingQueue
Parameters:
queue (PendingQueue)
direction (int)
origin (float)
scale (float)
currentBar (int)
PendingOrigin
Fields:
originBar (series int)
resolutionBar (series int)
direction (series int)
origin (series float)
scale (series float)
maxHigh (series float)
minLow (series float)
pathComplete (series bool)
ResolvedExcursion
Fields:
resolved (series bool)
valid (series bool)
timingExact (series bool)
originBar (series int)
resolutionBar (series int)
direction (series int)
origin (series float)
scale (series float)
mae (series float)
mfe (series float)
closeReturn (series float)
directionalCloseReturn (series float)
PendingQueue
Fields:
slots (array)
capacity (series int)
horizon (series int)
readHead (series int)
writeHead (series int)
count (series int)
acceptedCount (series int)
resolvedCount (series int)
invalidResolvedCount (series int)
lastResolvedBar (series int) Libreria

TargetExcursionStatsLibLibrary "TargetExcursionStatsLib"
helper for targetExcursionLib
f_density_new(gridSize, outcomeCap, smoothing, halfLife, familyCode, shrinkageAlpha)
Construct one independent density state.
Parameters:
gridSize (int)
outcomeCap (float)
smoothing (float)
halfLife (float)
familyCode (int)
shrinkageAlpha (float)
method advance(state, currentBar)
Advance all six streams causally to currentBar.
Namespace types: DensityState
Parameters:
state (DensityState)
currentBar (int)
method observe(state, direction, mae, mfe, resolutionBar)
Add one resolved, direction-conditioned excursion observation.
MAE and MFE are normalized, nonnegative values frozen by the queue.
Namespace types: DensityState
Parameters:
state (DensityState)
direction (int)
mae (float)
mfe (float)
resolutionBar (int)
method support(state, direction, isMae)
Effective sample support for a direction and outcome stream.
Namespace types: DensityState
Parameters:
state (DensityState)
direction (int)
isMae (bool)
method directionSupport(state, direction)
Minimum of current direction's MAE/MFE effective supports.
Namespace types: DensityState
Parameters:
state (DensityState)
direction (int)
method estimate(state, direction, isMae)
Quantiles, mode, modal probability and support for one stream.
Namespace types: DensityState
Parameters:
state (DensityState)
direction (int)
isMae (bool)
method probabilityAt(state, direction, isMae, value)
Smoothed probability mass at the bin containing value.
Namespace types: DensityState
Parameters:
state (DensityState)
direction (int)
isMae (bool)
value (float)
Histogram
Fields:
bins (array)
weight (series float)
weightSq (series float)
DensityState
Fields:
pooledMae (Histogram)
pooledMfe (Histogram)
longMae (Histogram)
longMfe (Histogram)
shortMae (Histogram)
shortMfe (Histogram)
gridSize (series int)
outcomeCap (series float)
smoothing (series float)
halfLife (series float)
familyCode (series int)
shrinkageAlpha (series float)
lastDecayBar (series int)
lastResolvedBar (series int)
resolvedCount (series int)
longResolvedCount (series int)
shortResolvedCount (series int)
DensityEstimate
Fields:
q10 (series float)
q50 (series float)
q80 (series float)
q90 (series float)
mode (series float)
modeProbability (series float)
effectiveSupport (series float) Libreria

TargetExcursionLibLibrary "TargetExcursionLib"
Parent supplies origin price/scale, direction, and path high/low/close series.
Library derives no hidden source data.
Returns bands.ready, bands.status, bands.effectiveSupport, and bands.resolvedCount.
Before minimum support: status is exactly "band stats not ready yet" and all band levels are na.
f_input(direction, originPrice, originScale, predictionValid, directionProbability, externalReliability)
Construct a generic target input from series values.
Parameters:
direction (int)
originPrice (float)
originScale (float)
predictionValid (bool)
directionProbability (float)
externalReliability (float)
f_model_new(gridSize, outcomeCap, smoothing, halfLife, family, shrinkageAlpha, minSupport, supportScale, minTransparency, maxTransparency, transparencyGamma)
Construct an independent stateful model instance.
Parameters:
gridSize (int)
outcomeCap (float)
smoothing (float)
halfLife (float)
family (series DensityFamily)
shrinkageAlpha (float)
minSupport (float)
supportScale (float)
minTransparency (int)
maxTransparency (int)
transparencyGamma (float)
f_update(model, signal, pathHigh, pathLow, pathClose, horizon, currentBar, confirmed)
Parameters:
model (TargetModel)
signal (TargetInput)
pathHigh (float)
pathLow (float)
pathClose (float)
horizon (int)
currentBar (int)
confirmed (bool)
TargetInput
Fields:
direction (series int)
originPrice (series float)
originScale (series float)
predictionValid (series bool)
directionProbability (series float)
externalReliability (series float)
TargetBands
Fields:
ready (series bool)
status (series string)
direction (series int)
originPrice (series float)
originScale (series float)
mfeQ10 (series float)
mfeQ50 (series float)
mfeQ80 (series float)
mfeQ90 (series float)
mfeMode (series float)
maeQ10 (series float)
maeQ50 (series float)
maeQ80 (series float)
maeQ90 (series float)
maeMode (series float)
mfePriceQ10 (series float)
mfePriceQ50 (series float)
mfePriceQ80 (series float)
mfePriceQ90 (series float)
mfePriceMode (series float)
maePriceQ10 (series float)
maePriceQ50 (series float)
maePriceQ80 (series float)
maePriceQ90 (series float)
maePriceMode (series float)
effectiveSupport (series float)
intervalCoverageEstimate (series float)
reliability (series float)
transparency (series int)
pendingCount (series int)
resolvedCount (series int)
lastResolvedBar (series int)
PendingTarget
Fields:
originBar (series int)
resolutionBar (series int)
direction (series int)
originPrice (series float)
originScale (series float)
maxHigh (series float)
minLow (series float)
TargetModel
Fields:
pending (array)
pooledMae (array)
pooledMfe (array)
longMae (array)
longMfe (array)
shortMae (array)
shortMfe (array)
pooledMaeWeight (series float)
pooledMaeWeightSq (series float)
pooledMfeWeight (series float)
pooledMfeWeightSq (series float)
longMaeWeight (series float)
longMaeWeightSq (series float)
longMfeWeight (series float)
longMfeWeightSq (series float)
shortMaeWeight (series float)
shortMaeWeightSq (series float)
shortMfeWeight (series float)
shortMfeWeightSq (series float)
gridSize (series int)
outcomeCap (series float)
smoothing (series float)
halfLife (series float)
family (series DensityFamily)
shrinkageAlpha (series float)
minSupport (series float)
supportScale (series float)
minTransparency (series int)
maxTransparency (series int)
transparencyGamma (series float)
lastDecayBar (series int)
lastResolvedBar (series int)
resolvedCount (series int) Libreria

Libreria

Libreria

SMCNexusFactsCoreSMCNexusFactsCore is the confirmed, non-visual market-facts library for SMC Nexus by AreXoN. It provides bounded chart-timeframe facts for swing structure, BOS/CHoCH, MSS, FVG, Order Blocks, liquidity pools, sweeps, premium/discount and market context.
It contains no alerts, drawings, requests, transport, scoring or trade planning.
Contract version: 1.0.0. Libreria

FractalMemoryLib [Jayadev Rana]FractalMemoryLib packages the pattern-memory engine used by the Fractal Memory Projection indicator and the Fractal Memory Strategy so any script can import it.
WHAT IT DOES
The library finds the historical window whose movement shape most resembles the most recent bars (mean squared distance between stdev-normalized log returns), replays what followed that window as a projected close path, and sizes stops and targets adaptively by volatility regime.
EXPORTED FUNCTIONS
logRet(src) - one-bar log return of a series.
bestMatch(src, winLen, scanDepth, gapAhead) - scans up to scanDepth bars back and returns the offset of the most similar window plus a 0-100 similarity score. gapAhead reserves bars after the match for a projection.
analogPath(src, offset, fcLen, scaleF) - array of fcLen projected closes built by replaying the returns that followed the match, rescaled by scaleF (for example current ATR over ATR at the match).
adaptiveR(atrLen, rankLen, base) - volatility-adaptive unit risk: ATR times (base plus its 0-1 percentile rank), plus the rank itself. Call on every bar.
volRegime(volRank) - "Low", "Normal" or "High" label from the rank.
targets(entry, dirSign, unitR, slMult) - stop loss and TP1/TP2/TP3 at 1R, 2R and 3R.
USAGE NOTES
Call adaptiveR on every bar for ta consistency. bestMatch and analogPath are loop-heavy; for display purposes call them on the last bar only, and make sure the chart has at least scanDepth plus gapAhead bars of history. When the library itself is added to a chart it draws a small demo projection line from the best analog.
The analog projection is a statistical reference to a similar past episode, not a prediction, and not financial advice. Libreria

Libreria

Libreria

Libreria

SMCNexusTradePlanCoreSMC Nexus Trade Plan Core is the public Trade Plan library used by SMC Nexus by AreXoN.
It provides deterministic candidate-plan resolution for Entry, direction-valid Stop Loss, real target candidates, bounded target clustering, Risk/Reward, Order Type, Confluence and final geometry validation.
All market structure, zones, liquidity levels, pivots and prices are supplied by the importing indicator. Targets are selected only from real caller-provided levels; the library does not fabricate prices.
This library produces analytical candidate-plan data only. It does not place or manage orders, connect to a broker, simulate fills or make performance claims. Libreria

Libreria

Libreria

Libreria

Libreria

ContextAwarenessEngineLibrary "ContextAwarenessEngine"
Shared "human contextual awareness" engine — structure memory,
zone memory, sequence engine, regime flags. Import this from any indicator
instead of rebuilding these primitives per-script (the bug pattern behind
Kurisko v1/v2's misfires: each indicator invents its own crude, unverified
context logic). FIRST DRAFT — verify every threshold before trusting it.
newStructureMemory(maxAgeBars, minMagnitudeATR)
Creates a new, empty structure memory.
Parameters:
maxAgeBars (int) : bars after which a pivot is forgotten
minMagnitudeATR (float) : minimum swing size (in ATR multiples) to be recorded — filters noise pivots
Returns: a fresh StructureMemory instance
prune(mem)
Prunes pivots older than maxAge. Call once per bar before recording.
Parameters:
mem (StructureMemory) : the StructureMemory to prune
recordWithMagnitude(mem, price, swingMagnitude, atrVal, isLow, touchTolATR)
Preferred entry point: caller supplies the actual swing magnitude
(e.g. abs(pivotPrice - priorOppositePivotPrice)) so "significant vs noise"
reflects real swing size, not just ATR at a point.
Parameters:
mem (StructureMemory) : the StructureMemory to update
price (float) : the pivot price
swingMagnitude (float) : the size of the swing this pivot represents (price units)
atrVal (float) : current ATR — swingMagnitude is measured in ATR multiples against this
isLow (bool) : true if this pivot is a swing LOW (directional override checks
for a genuinely lower low); false for a swing HIGH (checks for higher high).
Without this, a real break beyond an old level gets silently logged as a
mere "touch" of that level instead of a new, more extreme pivot — the exact
bug behind missing the deeper low in the circled BTCUSD chart area.
touchTolATR (float) : tolerance (x ATR) for counting a revisit vs a new pivot
Returns: — isNew true if recorded as a fresh pivot, matchedIndex is the array index touched (-1 if new)
currentExtreme(mem, wantLowest)
Returns the actual current floor/ceiling in memory — lowest low
or highest high still tracked — regardless of its ATR-relative magnitude
at formation. This answers "where is price's real extreme right now,"
which mostSignificant() (magnitude-ranked) does NOT answer.
Parameters:
mem (StructureMemory) : the StructureMemory to search
wantLowest (bool) : true to find the lowest price (support floor), false for highest (ceiling)
Returns: the most extreme Pivot by raw price, or na fields if empty
isStale(p, maxTouches)
A level touched too many times has likely already been consumed —
flag it as stale so callers stop treating it as fresh, reliable liquidity.
Parameters:
p (Pivot) : the Pivot to check
maxTouches (int) : touches beyond this count are considered stale
mostSignificant(mem, maxTouches)
The single most "significant" pivot still in memory — largest
magnitude among NON-STALE pivots (excludes levels already ground through
maxTouches times, since those have likely been consumed already). This is
the closest analogue to "the obvious swing point a human's eye lands on
first" — but a human also discounts a level they've watched fail three
times already, which is what the staleness filter encodes.
Parameters:
mem (StructureMemory) : the StructureMemory to search
maxTouches (int) : touches beyond this exclude a pivot as stale (see isStale)
Returns: the most significant non-stale Pivot, or na fields if none qualify
newZone(top, bottom, validBars, kind)
Creates a new zone.
Parameters:
top (float) : top of the zone
bottom (float) : bottom of the zone
validBars (int) : how many bars the zone stays "live" before expiring unfilled
kind (string) : free-text label for what kind of zone this is
Returns: a fresh Zone
isFresh(z)
Checks whether a zone is still within its validity window.
Parameters:
z (Zone) : the Zone to check
Returns: true if the zone hasn't expired
checkTouch(z, hi, lo)
Checks whether current price has entered the zone, and marks it
touched if so. Call once per bar for each active zone.
Parameters:
z (Zone) : the Zone to check/update
hi (float) : current bar high
lo (float) : current bar low
Returns: true if price is inside the zone on this bar
isActiveReaction(z)
A zone counts as an active, meaningful reaction target only if
it's still fresh AND has actually been touched — "sweep happened, price
came back" not just "gap exists somewhere in memory."
Parameters:
z (Zone) : the Zone to evaluate
entryPrice(z, aggressive)
Horner's two entry modes for an FVG zone: conservative waits for
the FULL gap fill and enters at the edge farthest into the zone (safer,
worse R:R, matches "wait for price to fill the entire gap" from her FVG
video); aggressive enters at the 50% midpoint/equilibrium (better R:R,
needs smaller size since it's a more precise level). Direction-aware via
z.kind so callers don't have to work out which edge is "far" themselves.
Parameters:
z (Zone) : the Zone to compute an entry for (kind must be "FVG_BULL" or "FVG_BEAR")
aggressive (bool) : true for the 50% midpoint entry, false for the far-edge conservative entry
Returns: the entry price, or na if z.kind isn't a recognized FVG type
stopPrice(z, atrVal, bufferATRmult)
The matching stop-loss reference: "beyond the far edge of the
FVG" per both Horner's video and this project's own Confluence Trading
Framework doc. A small ATR buffer is added so the stop isn't sitting
exactly on the boundary (which invites getting picked off by noise).
Parameters:
z (Zone) : the Zone to compute a stop for
atrVal (float) : current ATR, used for the buffer beyond the far edge
bufferATRmult (float) : how far beyond the far edge to place the stop (x ATR)
newSequence(maxBars)
Creates a new idle sequence tracker.
Parameters:
maxBars (int) : how many bars a sequence can sit at one stage before expiring
advance(seq, leg1, leg2, leg3)
Advances or resets a sequence given the state of its three legs.
Call once per bar with the three boolean conditions for THIS bar. Order is
enforced: leg2 only counts if stage is already >=1, leg3 only if stage is
already >=2 — mirrors bar_index-ordering without needing separate `>=` checks
at every call site.
Parameters:
seq (Sequence) : the Sequence to advance
leg1 (bool) : condition for stage 0->1 (e.g. liquidity sweep / zone touch)
leg2 (bool) : condition for stage 1->2 (e.g. extreme / momentum confirmation)
leg3 (bool) : condition for stage 2->3, i.e. the actual fire (e.g. divergence)
Returns: true on the exact bar the full sequence fires
describe(seq)
Human-readable status for a status-table row — this is the direct
answer to "why hasn't it fired yet," visible instead of a black-box boolean.
Parameters:
seq (Sequence) : the Sequence to describe
trendRegime(src)
Trend regime from price vs EMA200 + VWAP, as used across this project.
Parameters:
src (float) : typically `close`
Returns: "UP", "DOWN", or "NEUTRAL"
volRegime(atrVal, atrLookback)
Volatility regime relative to the instrument's own recent history —
avoids hardcoding an absolute number that only makes sense for one asset class.
Parameters:
atrVal (float) : current ATR
atrLookback (int) : bars to compare against for "normal" ATR
Returns: "HIGH", "LOW", or "NORMAL"
inSession(sessSpec, tz)
Parameters:
sessSpec (string)
tz (string)
htfRegime(htf)
Parameters:
htf (string)
newRegimeTracker()
updateRegime(rt, newRegime)
Parameters:
rt (RegimeTracker)
newRegime (string)
justStartedTrending(rt)
Parameters:
rt (RegimeTracker)
brokeStructure(closePrice, refPivot, isBullBreak)
Parameters:
closePrice (float)
refPivot (Pivot)
isBullBreak (bool)
newStructureState()
changeOfCharacter(ss, brokeBull, brokeBear)
Parameters:
ss (StructureState)
brokeBull (bool)
brokeBear (bool)
candleCharacter(o, h, l, c, avgBody)
Parameters:
o (float)
h (float)
l (float)
c (float)
avgBody (float)
confidence(pivotStale, regimeJustShifted, htfCharacter)
Parameters:
pivotStale (bool)
regimeJustShifted (bool)
htfCharacter (string)
pivotRelation(newPrice, priorPrice, isLowType, tol)
Parameters:
newPrice (float)
priorPrice (float)
isLowType (bool)
tol (float)
latestRelation(mem, isLowType, atrVal, maxTouches)
Parameters:
mem (StructureMemory)
isLowType (bool)
atrVal (float)
maxTouches (int)
newStructureTrend()
updateStructureTrend(st, relation, confirmAfter)
Parameters:
st (StructureTrend)
relation (string)
confirmAfter (int)
Pivot
A single tracked swing pivot with magnitude/age/touch context.
Fields:
price (series float)
barIndex (series int)
magnitude (series float)
touchCount (series int)
StructureMemory
A rolling memory of pivots (one instance for highs, one for lows).
Fields:
pivots (array)
maxAge (series int)
minMagATR (series float)
Zone
A price zone with a validity clock (Horner's age x visibility idea).
Fields:
top (series float)
bottom (series float)
createdBar (series int)
validBars (series int)
touched (series bool)
kind (series string)
Sequence
Generic 3-stage sequence tracker.
Fields:
stage (series int)
stageBar (series int)
maxBars (series int)
RegimeTracker
Tracks a regime series over time so a TRANSITION (not just current
Fields:
current (series string)
previous (series string)
barsInCurrent (series int)
StructureState
Tracks the last confirmed structural break direction to detect CHoCH.
Fields:
lastBreakDir (series string)
StructureTrend
Running structure-trend state built from consecutive HH/HL vs LH/LL
Fields:
bias (series string)
consecutiveCount (series int) Libreria

PatternHelpersLibrary "PatternHelpers"
method update(atr, h, l, c, period)
Namespace types: WilderAtr
Parameters:
atr (WilderAtr)
h (float)
l (float)
c (float)
period (int)
method push(buf, o, h, l, c, t, idx, max_len)
Namespace types: CandleBuffer
Parameters:
buf (CandleBuffer)
o (float)
h (float)
l (float)
c (float)
t (int)
idx (int)
max_len (int)
method gap_candles(buf, prev_end_idx, next_start_idx)
Namespace types: CandleBuffer
Parameters:
buf (CandleBuffer)
prev_end_idx (int)
next_start_idx (int)
quantile_rail(vals, upper)
Parameters:
vals (array)
upper (bool)
has_acceptable_coverage(values, upper_bounds, lower_bounds)
Parameters:
values (array)
upper_bounds (array)
lower_bounds (array)
has_acceptable_coverage_const(values, upper, lower)
Parameters:
values (array)
upper (float)
lower (float)
has_low_directional_drift(closes, upper, lower)
Parameters:
closes (array)
upper (float)
lower (float)
has_balanced_rotation(values, shape_width)
Parameters:
values (array)
shape_width (float)
has_no_dominant_run(values, shape_width)
Parameters:
values (array)
shape_width (float)
ols_regression(y, x, origin_x)
Parameters:
y (array)
x (array)
origin_x (int)
residual_rail(highs_or_lows, indices, intercept, slope, origin_idx, upper)
Parameters:
highs_or_lows (array)
indices (array)
intercept (float)
slope (float)
origin_idx (int)
upper (bool)
WilderAtr
Fields:
prev_close (series float)
atr_val (series float)
count (series int)
CandleBuffer
Fields:
opens (array)
highs (array)
lows (array)
closes (array)
times (array)
indices (array)
start_idx (series int) Libreria

CyberRegimeLibCyberRegimeLib - online sssm
GaussianRegime parameter/state UDT
PosteriorHistory ring-buffer UDT
Gaussian cloning and prior-stat capping
Online EM accumulation and M-step
Hamilton forward filtering
One-step smoothing
Fixed-horizon Kim smoothing
Active-state hysteresis
Library "CyberRegimeLib"
f_regime_new(dimensions)
Parameters:
dimensions (int)
method clone(source)
Namespace types: GaussianRegime
Parameters:
source (GaussianRegime)
f_clone_regimes(source)
Parameters:
source (array)
f_n_eff_at(regimes, index)
Parameters:
regimes (array)
index (int)
f_cap_prior_stats(regimes, total_cap)
Parameters:
regimes (array)
total_cap (float)
method initialize_stats(regime, regime_count, active_dims)
Namespace types: GaussianRegime
Parameters:
regime (GaussianRegime)
regime_count (int)
active_dims (array)
f_accumulate_stats(regimes, responsibilities, observation, lambda_eff, admission_weight, count, prior_weighted, full_cov_dims)
Parameters:
regimes (array)
responsibilities (array)
observation (array)
lambda_eff (float)
admission_weight (float)
count (int)
prior_weighted (bool)
full_cov_dims (int)
method mstep(regime, active_dims, ridge_main, ridge_aux, shrinkage, min_n_eff, anchor)
Namespace types: GaussianRegime
Parameters:
regime (GaussianRegime)
active_dims (array)
ridge_main (float)
ridge_aux (float)
shrinkage (float)
min_n_eff (float)
anchor (float)
f_hamilton_step(transition, filtered, log_likelihoods, count)
Parameters:
transition (matrix)
filtered (array)
log_likelihoods (array)
count (int)
f_history_new(capacity, state_count)
Parameters:
capacity (int)
state_count (int)
method push(history, filtered, predicted)
Namespace types: PosteriorHistory
Parameters:
history (PosteriorHistory)
filtered (array)
predicted (array)
method smooth_one(history, transition, fallback_index, fallback_probability)
Namespace types: PosteriorHistory
Parameters:
history (PosteriorHistory)
transition (matrix)
fallback_index (int)
fallback_probability (float)
method smooth_fixed(history, transition, horizon)
Namespace types: PosteriorHistory
Parameters:
history (PosteriorHistory)
transition (matrix)
horizon (int)
f_hysteresis_state(current, active_since, candidate, best, second, minimum_margin, minimum_bars, current_bar)
Parameters:
current (int)
active_since (int)
candidate (int)
best (float)
second (float)
minimum_margin (float)
minimum_bars (int)
current_bar (int)
GaussianRegime
Fields:
mu (array)
mu_seed (array)
Sigma (matrix)
Sigma_inv (matrix)
F (matrix)
Q_diag (array)
prior (series float)
n_eff (series float)
sum_x (array)
sum_xx (matrix)
PosteriorHistory
Fields:
filtered_flat (array)
predicted_flat (array)
write_idx (series int)
count (series int)
capacity (series int)
state_count (series int) Libreria

Arbor_Gradient_Boosting_GainzAlgoGainzAlgo is excited to bring the ability to perform gradient boosting and feature importance selection to Pine Script. Currently, there are no native capabilities within Pine Script for gradient boosting or feature importance selection. Arbor fills this significant gap by introducing a from-scratch Gradient Boosting Machine (GBM) engineered with XGBoost-style mechanics.
Designed to support both classification and regression tasks, and building on our Random Forest approach to Pinescript, Arbor utilizes depth-1 stumps, meaning it performs one split per round without column subsampling.
Because TradingView automatically lists the exported types and function parameters, the following outlines the core mechanics and capabilities you unlock by importing Arbor.
Core Mechanics
Arbor brings advanced machine-learning concepts directly into your Pine Script workflows:Advanced Training: Utilizes Newton leaf steps (second-order hessian weighting) and the exact XGBoost gain formula.
Regularization & Pruning: Integrates L2 regularization (lambda), minimum gain pruning (gamma), and minimum child weight checks to manage model complexity and prevent overfitting.
Stochasticity: Implements Fisher-Yates row subsampling to provide genuine round-to-round stochasticity matching XGBoost's subsample behavior.
Reproducibility: You can pass an optional seed to any fit function to ensure reproducible training runs across reloads.
Model Tiers
The library supports models scaled across three specific feature tiers:
GBM (1 Feature): Built for rapid classification or regression implementations.
GBM3 (3 Features): Purpose-built specifically for classification tasks.
GBM4 (4 Features): Supports both classification and regression, and uniquely offers XGBoost-style, gain-based feature importance evaluation.
Library "Arbor_Gradient_Boosting_GainzAlgo"
Arbor — gradient boosting for Pine Script. From-scratch GBM v2
with XGBoost-style mechanics: Fisher-Yates row subsampling, Newton leaf steps
(second-order hessian weighting), exact XGBoost gain formula with L2
regularization (lambda), minimum gain pruning (gamma), and minimum child
weight. Trees are depth-1 stumps (one split per round) and there is no
column (feature) subsampling — this is an XGBoost-style boosting scheme,
not a full XGBoost reimplementation. Supports classification and regression
across three feature tiers:
- GBM (1 feature) : gbm_fit / gbm_predict
classification or regression via is_classifier
- GBM3 (3 features) : gbm3_fit / gbm3_predict
classification only
- GBM4 (4 features) : gbm4_fit / gbm4_predict / gbm4_importance_pct
classification or regression with XGBoost-style
gain-based feature importance
All variants use Newton leaf steps, exact gain formula, L2 regularization,
Fisher-Yates shuffle subsampling, and gamma/min_child_weight pruning. Pass
an optional seed to any fit function for reproducible training runs.
gbm_fit(feat, target, n_rounds, lr, n_thresh, is_classifier, lambda, gamma, min_child_w, subsample, seed)
Fits a single-feature gradient-boosted stump ensemble using
XGBoost-style mechanics: Newton leaf steps (second-order hessian weighting),
exact gain formula with L2 regularization, gamma pruning, minimum child
weight, and Fisher-Yates row subsampling. Each round fits one depth-1 stump
(this is not a full multi-level tree, and there is no column subsampling).
Supports both binary classification (log-odds + sigmoid) and regression (MSE).
Parameters:
feat (array) : Array of feature values, one per training row
target (array) : Array of targets — 0.0/1.0 for classification, continuous for regression
n_rounds (int) : Number of boosting rounds / stumps to fit
lr (float) : Learning rate / shrinkage applied to each round's leaf contribution
n_thresh (int) : Candidate split thresholds to scan per round
is_classifier (bool) : True = binary classification, False = squared-error regression
lambda (float) : L2 leaf regularization — Ridge-style shrinkage toward zero (XGBoost default: 1.0)
gamma (float) : Minimum gain required to accept a split — prunes weak splits (XGBoost default: 0.0)
min_child_w (float) : Minimum hessian sum per child node — prevents tiny noisy splits (XGBoost default: 1.0)
subsample (float) : Fraction of rows randomly sampled per round via Fisher-Yates (default: 1.0 = all rows)
seed (int) : Optional seed for the row-subsampling shuffle — pass a fixed value for reproducible fits across reloads (default: na = unseeded/random each time)
Returns: Fitted GBM object ready for gbm_predict()
gbm_predict(model, x)
Scores a single feature value against a fitted GBM ensemble.
Parameters:
model (GBM) : A GBM object previously returned by gbm_fit()
x (float) : Feature value to score (same feature definition used in training)
Returns: Predicted probability if classifier, raw predicted value if regressor
gbm3_fit(feat1, feat2, feat3, target, n_rounds, lr, n_thresh, lambda, gamma, min_child_w, subsample, seed)
Fits a 3-feature gradient-boosted classifier using XGBoost-style
mechanics: Newton leaf steps, exact gain formula, L2 regularization, gamma
pruning, minimum child weight, and Fisher-Yates row subsampling. Selects the
best (feature, threshold) pair each round and boosts in log-odds space.
Each round fits a single depth-1 stump; there is no column subsampling.
Parameters:
feat1 (array) : Array of feature 1 values, one per training row
feat2 (array) : Array of feature 2 values, one per training row
feat3 (array) : Array of feature 3 values, one per training row
target (array) : Array of binary targets (0.0 or 1.0), one per training row
n_rounds (int) : Number of boosting rounds
lr (float) : Learning rate / shrinkage
n_thresh (int) : Candidate thresholds scanned per feature per round
lambda (float) : L2 leaf regularization (Ridge shrinkage, XGBoost default: 1.0)
gamma (float) : Minimum gain to accept a split (XGBoost default: 0.0)
min_child_w (float) : Minimum hessian sum per child node (XGBoost default: 1.0)
subsample (float) : Row sampling fraction per round via Fisher-Yates (default: 1.0)
seed (int) : Optional seed for the row-subsampling shuffle — pass a fixed value for reproducible fits across reloads (default: na = unseeded/random each time)
Returns: Fitted GBM3 object ready for gbm3_predict()
gbm3_predict(model, x1, x2, x3)
Scores 3 feature values against a fitted GBM3 classifier.
Parameters:
model (GBM3) : GBM3 object from gbm3_fit()
x1 (float) : Current value of feature 1
x2 (float) : Current value of feature 2
x3 (float) : Current value of feature 3
Returns: Predicted probability
gbm4_fit(feat1, feat2, feat3, feat4, target, n_rounds, lr, n_thresh, is_classifier, lambda, gamma, min_child_w, subsample, seed)
Fits a 4-feature gradient-boosted ensemble with Newton steps, exact gain
formula, L2 regularization, gamma pruning, minimum child weight, Fisher-Yates
row subsampling, and gain-based feature importance tracking.
Supports both binary classification and regression. Each round fits a single
depth-1 stump; there is no column subsampling.
Parameters:
feat1 (array) : Array of feature 1 values, one per training row
feat2 (array) : Array of feature 2 values, one per training row
feat3 (array) : Array of feature 3 values, one per training row
feat4 (array) : Array of feature 4 values, one per training row
target (array) : Array of targets — 0.0/1.0 for classification, continuous for regression
n_rounds (int) : Number of boosting rounds
lr (float) : Learning rate / shrinkage
n_thresh (int) : Candidate thresholds scanned per feature per round
is_classifier (bool) : True = binary classification, False = regression
lambda (float) : L2 leaf regularization (Ridge shrinkage, XGBoost default: 1.0)
gamma (float) : Minimum gain to accept a split (XGBoost default: 0.0)
min_child_w (float) : Minimum hessian sum per child node (XGBoost default: 1.0)
subsample (float) : Row sampling fraction per round via Fisher-Yates (default: 1.0)
seed (int) : Optional seed for the row-subsampling shuffle — pass a fixed value for reproducible fits across reloads (default: na = unseeded/random each time)
Returns: Fitted GBM4 object with importance scores, ready for gbm4_predict() / gbm4_importance_pct()
gbm4_predict(model, x1, x2, x3, x4)
Scores 4 feature values against a fitted GBM4 ensemble.
Parameters:
model (GBM4) : GBM4 object from gbm4_fit()
x1 (float) : Current value of feature 1
x2 (float) : Current value of feature 2
x3 (float) : Current value of feature 3
x4 (float) : Current value of feature 4
Returns: Predicted probability if classifier, raw predicted value if regressor
gbm4_importance_pct(model, feat_idx)
Returns normalized feature importance as % of total gain for one feature.
Importance = accumulated gain credited to this feature across all boosting rounds,
matching XGBoost's xgb.importance() Gain column definition.
Parameters:
model (GBM4) : GBM4 object from gbm4_fit()
feat_idx (int) : Feature index to query (0-3)
Returns: Percentage of total ensemble gain attributed to this feature (0.0–100.0)
GBM
Holds a fitted gradient-boosted stump ensemble (1 feature).
Fields:
thresh (array) : Split threshold for each round's stump
left_val (array) : Newton leaf value when feature < threshold
right_val (array) : Newton leaf value when feature >= threshold
base_score (series float) : Log-odds of training mean (classifier) or mean (regressor)
lr (series float) : Learning rate stored for inference
is_classifier (series bool) : True = sigmoid probability output, False = raw regression output
GBM3
Holds a fitted 3-feature gradient-boosted stump ensemble (classification only).
Fields:
stump_feat (array) : Which feature index (0-2) each round's stump split on
thresh (array) : Split threshold for each round's stump
left_val (array) : Newton leaf value when feature < threshold
right_val (array) : Newton leaf value when feature >= threshold
base_score (series float) : Log-odds of training mean
lr (series float) : Learning rate stored for inference
GBM4
Holds a fitted 4-feature gradient-boosted ensemble with gain-based importance.
Fields:
stump_feat (array) : Which feature index (0-3) each round's stump split on
thresh (array) : Split threshold for each round's stump
left_val (array) : Newton leaf value when feature < threshold
right_val (array) : Newton leaf value when feature >= threshold
importance (array) : Accumulated gain per feature (indices 0-3), raw — normalize via gbm4_importance_pct()
base_score (series float) : Log-odds (classifier) or mean (regressor)
lr (series float) : Learning rate stored for inference
is_classifier (series bool) : True = sigmoid probability output, False = raw regression output Libreria

SNIFOFF_51_Lang3Library "SNIFOFF_51_Lang3"
Multilingual translation layer (Group 3) for Smart Trader, SNIF-OFF 5.1, Trade Finder.
Provides 9 exported functions covering the Trade Finder and Signal Health dashboard rows,
the S17/S18/S19 volume scenarios, the PROVISIONAL badge, the Native footprint texts,
12 tooltips, and 4 helper affixes.
All 7 languages live in this single library; SNIFOFF_51_Lang and SNIFOFF_51_Lang2 stay frozen.
f_trVol3(en, lang)
Translates the S17/S18/S19 volume scenario labels.
Parameters:
en (string) : The English scenario label from f_volScenarioMsg (S17/S18/S19 keys only).
lang (string) : The dashboard language selected by the user.
Returns: The translated scenario label. Unmapped inputs return unchanged.
f_volNarr3(sid, deltaDir, liveAlert, lang)
Builds the S17/S18/S19 volume narrative with optional live-spike overlay.
Parameters:
sid (string) : Scenario ID: "S17", "S18", or "S19". Any other ID returns "".
deltaDir (int) : Anchored delta direction (+1 buyers, -1 sellers, 0 balanced) — S17 wording.
liveAlert (bool) : Explosive bar volume spike flag (Live Exception protocol).
lang (string) : The dashboard language selected by the user.
Returns: The multi-line narrative string, or "" for unknown scenario IDs.
f_trBadge3(en, lang)
Translates the Signal Health PROVISIONAL badge.
Parameters:
en (string) : The English badge label ("◌ PROVISIONAL").
lang (string) : The dashboard language selected by the user.
Returns: The translated badge label. Unmapped inputs return unchanged.
f_trTitle3(en, lang)
Translates the Trade Finder and Signal Health section titles.
Parameters:
en (string) : The English section title.
lang (string) : The dashboard language selected by the user.
Returns: The translated section title. Unmapped inputs return unchanged.
f_trTf(en, lang)
Translates Trade Finder and Signal Health state and watch labels.
Parameters:
en (string) : The English state or watch label.
lang (string) : The dashboard language selected by the user.
Returns: The translated label. Unmapped inputs return unchanged.
f_tfNarrative(state, dir, consensus, lang)
Builds the Trade Finder narrative row text.
Parameters:
state (int) : State code 1..10 (see section header for the mapping).
dir (int) : Composite pressure direction (+1 bullish, -1 bearish, 0 flat).
consensus (int) : Number of dimensions agreeing with the composite direction (0-5).
lang (string) : The dashboard language selected by the user.
Returns: The narrative string for the Trade Finder dashboard row.
f_trTipTf(key, lang)
Returns translated tooltip text for Trade Finder and Signal Health cells.
Parameters:
key (string) : Tooltip key identifier (see section header for valid keys).
lang (string) : The dashboard language selected by the user.
Returns: The translated tooltip string. Empty string for unknown keys.
f_trInline3(key, lang)
Returns translated helper affixes used inside composed dashboard strings.
Parameters:
key (string) : Affix key identifier: agree_sfx, live_sfx, bull_pfx, bear_pfx.
lang (string) : The dashboard language selected by the user.
Returns: The translated affix string. Empty string for unknown keys.
f_trTipFp3(key, lang)
Returns Native-footprint display texts for the dashboard.
Parameters:
key (string) : Text key: fp_title_nat, fp_lock_nat, fp_lock_tip_nat, fp_badge_nat.
lang (string) : The dashboard language selected by the user.
Returns: The translated text. Empty string for unknown keys. Libreria

ChatgptLibraryLibrary "ChatgptLibrary"
TODO: add library description here
effective_period(high_series, low_series, volume_series, period_length, lookback_length, max_search)
Calculates adaptive effective period.
Parameters:
high_series (float) : High price series.
low_series (float) : Low price series.
volume_series (float) : Volume series.
period_length (simple int) : Base period.
lookback_length (simple int) : EMA lookback multiplier.
max_search (int) : Maximum search distance.
Returns: Adaptive effective period.
adaptive_ema(source, high_series, low_series, volume_series, period_length, lookback_length, max_search)
Adaptive EMA using effective period.
Parameters:
source (float) : Source series.
high_series (float) : High price series.
low_series (float) : Low price series.
volume_series (float) : Volume series.
period_length (simple int) : Base period.
lookback_length (simple int) : EMA lookback multiplier.
max_search (int) : Maximum search distance.
Returns: Adaptive EMA, alpha and effective period.
adaptive_channel(high_series, low_series, volume_series, period_length, lookback_length, smooth_length, max_search)
Adaptive price channel.
Parameters:
high_series (float) : High price series.
low_series (float) : Low price series.
volume_series (float) : Volume series.
period_length (simple int) : Base period.
lookback_length (simple int) : EMA lookback multiplier.
smooth_length (simple int) : EMA smoothing.
max_search (int) : Maximum search distance.
Returns: Effective period, upper, lower, middle and width.
adaptive_rsi(source, high_series, low_series, volume_series, period_length, lookback_length, max_search)
Adaptive RSI.
Parameters:
source (float) : Source series.
high_series (float) : High price series.
low_series (float) : Low price series.
volume_series (float) : Volume series.
period_length (simple int) : Base period.
lookback_length (simple int) : EMA lookback multiplier.
max_search (int) : Maximum search distance.
Returns: Adaptive RSI and effective period.
adaptive_atr(high_series, low_series, close_series, volume_series, period_length, lookback_length, max_search)
Adaptive ATR.
Parameters:
high_series (float) : High price series.
low_series (float) : Low price series.
close_series (float) : Close price series.
volume_series (float) : Volume series.
period_length (simple int) : Base period.
lookback_length (simple int) : EMA lookback multiplier.
max_search (int) : Maximum search distance.
Returns: Adaptive ATR and effective period.
adaptive_macd(source, high_series, low_series, volume_series, fast_period, slow_period, signal_period, lookback_length, max_search)
Adaptive MACD.
Parameters:
source (float) : Source series.
high_series (float) : High price series.
low_series (float) : Low price series.
volume_series (float) : Volume series.
fast_period (simple int) : Fast adaptive period.
slow_period (simple int) : Slow adaptive period.
signal_period (int) : Signal EMA period.
lookback_length (simple int) : EMA lookback multiplier.
max_search (int) : Maximum search distance.
Returns: MACD, Signal, Histogram.
adaptive_bollinger(source, high_series, low_series, volume_series, period_length, deviation, lookback_length, max_search)
Adaptive Bollinger Bands.
Parameters:
source (float) : Source series.
high_series (float) : High price series.
low_series (float) : Low price series.
volume_series (float) : Volume series.
period_length (simple int) : Base period.
deviation (float) : Standard deviation multiplier.
lookback_length (simple int) : EMA lookback multiplier.
max_search (int) : Maximum search distance.
Returns: Upper band, Middle band, Lower band, Band width and Effective period.
adaptive_supertrend(high_series, low_series, close_series, volume_series, period_length, multiplier, lookback_length, max_search)
Adaptive SuperTrend.
Parameters:
high_series (float) : High price series.
low_series (float) : Low price series.
close_series (float) : Close price series.
volume_series (float) : Volume series.
period_length (simple int) : Base period.
multiplier (float) : ATR multiplier.
lookback_length (simple int) : EMA lookback multiplier.
max_search (int) : Maximum search distance.
Returns: SuperTrend, Trend Direction and Effective Period.
adaptive_donchian(high_series, low_series, volume_series, period_length, lookback_length, max_search)
Adaptive Donchian Channel.
Parameters:
high_series (float) : High price series.
low_series (float) : Low price series.
volume_series (float) : Volume series.
period_length (simple int) : Base period.
lookback_length (simple int) : EMA lookback multiplier.
max_search (int) : Maximum search distance.
Returns: Upper band, Lower band, Middle line, Width and Effective period.
adaptive_keltner(source, high_series, low_series, close_series, volume_series, period_length, multiplier, lookback_length, max_search)
Adaptive Keltner Channel.
Parameters:
source (float) : Source series.
high_series (float) : High price series.
low_series (float) : Low price series.
close_series (float) : Close price series.
volume_series (float) : Volume series.
period_length (simple int) : Base period.
multiplier (float) : ATR multiplier.
lookback_length (simple int) : EMA lookback multiplier.
max_search (int) : Maximum search distance.
Returns: Upper band, Middle band, Lower band, Width and Effective period.
adaptive_adx(high_series, low_series, close_series, volume_series, period_length, lookback_length, max_search)
Adaptive ADX.
Parameters:
high_series (float) : High price series.
low_series (float) : Low price series.
close_series (float) : Close price series.
volume_series (float) : Volume series.
period_length (simple int) : Base period.
lookback_length (simple int) : EMA lookback multiplier.
max_search (int) : Maximum search distance.
Returns: ADX, +DI, -DI and Effective Period.
adaptive_stochastic(close_series, high_series, low_series, volume_series, period_length, smooth_k, smooth_d, lookback_length, max_search)
Adaptive Stochastic.
Parameters:
close_series (float) : Close price series.
high_series (float) : High price series.
low_series (float) : Low price series.
volume_series (float) : Volume series.
period_length (simple int) : Base period.
smooth_k (int) : K smoothing.
smooth_d (int) : D smoothing.
lookback_length (simple int) : EMA lookback multiplier.
max_search (int) : Maximum search distance.
Returns: K, D and Effective Period.
adaptive_cci(high_series, low_series, close_series, volume_series, period_length, lookback_length, max_search)
Adaptive Commodity Channel Index.
Parameters:
high_series (float) : High price series.
low_series (float) : Low price series.
close_series (float) : Close price series.
volume_series (float) : Volume series.
period_length (simple int) : Base period.
lookback_length (simple int) : EMA lookback multiplier.
max_search (int) : Maximum search distance.
Returns: CCI and Effective Period.
adaptive_williams_r(high_series, low_series, close_series, volume_series, period_length, lookback_length, max_search)
Adaptive Williams %R.
Parameters:
high_series (float) : High price series.
low_series (float) : Low price series.
close_series (float) : Close price series.
volume_series (float) : Volume series.
period_length (simple int) : Base period.
lookback_length (simple int) : EMA lookback multiplier.
max_search (int) : Maximum search distance.
Returns: Williams %R and Effective Period.
adaptive_roc(source, high_series, low_series, volume_series, period_length, lookback_length, max_search)
Adaptive Rate of Change.
Parameters:
source (float) : Source series.
high_series (float) : High price series.
low_series (float) : Low price series.
volume_series (float) : Volume series.
period_length (simple int) : Base period.
lookback_length (simple int) : EMA lookback multiplier.
max_search (int) : Maximum search distance.
Returns: ROC and Effective Period.
adaptive_pivot(source, left_bars, right_bars)
Adaptive Pivot Detector.
Parameters:
source (float) : Source series.
left_bars (int) : Left pivot bars.
right_bars (int) : Right pivot bars.
Returns: Pivot High, Pivot Low, Pivot High Price, Pivot Low Price.
adaptive_divergence(price_source, indicator_source, pivot_length)
Adaptive Divergence Detector.
Parameters:
price_source (float) : Price series.
indicator_source (float) : Indicator series.
pivot_length (int) : Pivot length.
Returns: Bullish divergence, Bearish divergence and Divergence strength.
adaptive_pivot_divergence(price_source, signal_source, pivot_length)
Adaptive Pivot Divergence Detector.
Parameters:
price_source (float) : Price series.
signal_source (float) : Indicator series.
pivot_length (int) : Pivot length.
Returns: Bullish divergence, Bearish divergence and Divergence strength.
adaptive_flat_channel(upper_channel, lower_channel, flat_length, tolerance)
Adaptive Flat Channel Detector.
Parameters:
upper_channel (float) : Upper channel.
lower_channel (float) : Lower channel.
flat_length (int) : Number of bars to evaluate.
tolerance (float) : Maximum allowed movement.
Returns: Flat upper, Flat lower and Flat channel.
adaptive_breakout_strength(close_series, upper_channel, lower_channel, channel_width, volume_series, volume_length)
Adaptive Breakout Strength.
Parameters:
close_series (float) : Close price.
upper_channel (float) : Upper channel.
lower_channel (float) : Lower channel.
channel_width (float) : Channel width.
volume_series (float) : Volume.
volume_length (simple int) : Volume EMA length.
Returns: Breakout direction and Breakout strength.
adaptive_channel_rejection(open_series, high_series, low_series, close_series, upper_channel, lower_channel)
Adaptive Channel Rejection.
Parameters:
open_series (float) : Open price.
high_series (float) : High price.
low_series (float) : Low price.
close_series (float) : Close price.
upper_channel (float) : Upper channel.
lower_channel (float) : Lower channel.
Returns: Rejection direction and Rejection strength.
adaptive_channel_compression(channel_width, compression_length)
Adaptive Channel Compression.
Parameters:
channel_width (float) : Width of the channel.
compression_length (simple int) : Number of bars.
Returns: Compression ratio, Is compressing, Is expanding.
adaptive_market_energy(channel_width, volume_series, volume_length)
Adaptive Market Energy.
Parameters:
channel_width (float) : Width of channel.
volume_series (float) : Volume series.
volume_length (simple int) : Volume EMA length.
Returns: Energy score.
adaptive_market_phase(adx, rsi, compression_ratio, breakout_strength)
Adaptive Market Phase.
Parameters:
adx (float) : Adaptive ADX.
rsi (float) : Adaptive RSI.
compression_ratio (float) : Channel compression ratio.
breakout_strength (float) : Breakout strength.
Returns: Market phase.
adaptive_rsi_zigzag(rsi_series, center_level, lookback_length)
Adaptive RSI Zigzag Detector.
Parameters:
rsi_series (float) : RSI series.
center_level (float) : Center level.
lookback_length (int) : Number of bars.
Returns: Zigzag count and Zigzag detected.
adaptive_flat_level(level_series, flat_length, tolerance)
Adaptive Flat Level Detector.
Parameters:
level_series (float) : Channel upper or lower series.
flat_length (int) : Number of bars.
tolerance (float) : Maximum allowed movement.
Returns: Flat state and Flat strength.
adaptive_level_strength(level_series, high_series, low_series, tolerance, lookback_length)
Adaptive Level Strength.
Parameters:
level_series (float) : Support or resistance level.
high_series (float) : High price series.
low_series (float) : Low price series.
tolerance (float) : Touch tolerance.
lookback_length (int) : Number of bars.
Returns: Touch count and Level strength.
adaptive_breakout_probability(breakout_strength, level_strength, compression_ratio, volume_ratio)
Adaptive Breakout Probability.
Parameters:
breakout_strength (float) : Breakout strength.
level_strength (float) : Level strength.
compression_ratio (float) : Channel compression ratio.
volume_ratio (float) : Volume ratio.
Returns: Breakout probability.
adaptive_reversal_probability(rsi, divergence_strength, rejection_strength, flat_strength, channel_width_percent)
Adaptive Reversal Probability.
Parameters:
rsi (float) : Relative Strength Index.
divergence_strength (float) : Divergence strength.
rejection_strength (float) : Rejection strength.
flat_strength (float) : Flat level strength.
channel_width_percent (float) : Channel width percentage.
Returns: Reversal probability.
adaptive_trend_exhaustion(rsi, adx, momentum, roc)
Adaptive Trend Exhaustion.
Parameters:
rsi (float) : Relative Strength Index.
adx (float) : Average Directional Index.
momentum (float) : Momentum.
roc (float) : Rate of Change.
Returns: Trend exhaustion score.
adaptive_channel_memory(upper_channel, lower_channel, tolerance, lookback_length)
Adaptive Channel Memory.
Parameters:
upper_channel (float) : Upper channel.
lower_channel (float) : Lower channel.
tolerance (float) : Maximum channel difference.
lookback_length (int) : Number of bars.
Returns: Memory score.
adaptive_false_breakout(breakout_strength, rejection_strength, volume_ratio)
Adaptive False Breakout Detector.
Parameters:
breakout_strength (float) : Breakout strength.
rejection_strength (float) : Rejection strength.
volume_ratio (float) : Current volume divided by average volume.
Returns: False breakout probability.
adaptive_trap_detector(breakout_direction, breakout_strength, rejection_strength, rsi)
Adaptive Trap Detector.
Parameters:
breakout_direction (int) : Breakout direction.
breakout_strength (float) : Breakout strength.
rejection_strength (float) : Rejection strength.
rsi (float) : Relative Strength Index.
Returns: Trap direction and Trap probability.
adaptive_rsi_behavior(rsi, zigzag_count, divergence_strength, rejection_strength)
Adaptive RSI Behavior.
Parameters:
rsi (float) : Relative Strength Index.
zigzag_count (int) : RSI zigzag count.
divergence_strength (float) : Divergence strength.
rejection_strength (float) : Rejection strength.
Returns: RSI behavior score.
adaptive_market_behavior(trend_strength, reversal_probability, breakout_probability, exhaustion, energy, rsi_behavior)
Adaptive Market Behavior.
Parameters:
trend_strength (float) : Trend strength.
reversal_probability (float) : Reversal probability.
breakout_probability (float) : Breakout probability.
exhaustion (float) : Trend exhaustion.
energy (float) : Market energy.
rsi_behavior (float) : RSI behavior.
Returns: Market behavior score. Libreria

Isotropic Coordinate System (ICS)Library "ICS"
Isotropic Coordinate System (ICS): a dimensionless price-time space
for scale-invariant chart geometry.
Vertical axis: y = ln(price) / sigma, where sigma is the Yang-Zhang (2000)
minimum-variance, drift-independent, gap-consistent OHLC volatility estimator.
Horizontal axis: two scalings via the XScale enum.
legacy : x = bars / lookback. Linear window fraction. Backward compatible.
isotropic : x = sqrt(bars / lookback), with y additionally divided by
sqrt(lookback). Diffusion-consistent (sqrt-time scaling), so that
tan(theta) equals the z-score of the move and 45 degrees
corresponds to a move of exactly one standard deviation
of the n-bar log-return distribution. Assumes approximately
iid returns within the sigma window (the standard assumption
behind sqrt-time scaling; see Danielsson & Zigrand, 2006, for
its known limits under vol clustering and jumps).
Every output (angle, length, area, centroid) is a pure dimensionless number,
comparable across symbols, currencies, and timeframes.
Reference: Yang, D. & Zhang, Q. (2000), "Drift-Independent Volatility
Estimation Based on High, Low, Open, and Close Prices",
The Journal of Business, 73(3), 477-492.
yangZhangSigma(length)
Yang-Zhang volatility estimator. Minimum-variance, unbiased,
drift-independent, and consistent with opening gaps
(Yang & Zhang, 2000). Uses the unbiased sample variance
(biased = false) for both the overnight and open-to-close
components, matching the estimator's unbiasedness claim.
Parameters:
length (simple int) : (simple int) Rolling window length. Must be >= 2.
Returns: (series float) Per-bar sigma, floored at 1e-10.
toX(bars, lookback, mode)
Dimensionless horizontal coordinate.
Parameters:
bars (int) : (series int) Signed bar distance from the anchor.
lookback (int) : (series int) Window length acting as the horizontal unit.
mode (series XScale) : (series XScale) Scaling mode.
Returns: (series float) Signed dimensionless x.
toY(price, sigma, lookback, mode)
Dimensionless vertical coordinate.
Parameters:
price (float) : (series float) Price. Must be > 0.
sigma (float) : (series float) Yang-Zhang sigma. Must be > 1e-10.
lookback (int) : (series int) Window length (used by isotropic mode only).
mode (series XScale) : (series XScale) Scaling mode.
Returns: (series float) Dimensionless y, or na when inputs are invalid.
moveZScore(dLogPrice, sigma, bars)
Z-score of a log-price move over n bars: dLog / (sigma * sqrt(n)).
In isotropic mode this equals tan(theta) of the same move.
Parameters:
dLogPrice (float) : (series float) ln(target) - ln(anchor).
sigma (float) : (series float) Per-bar Yang-Zhang sigma. Must be > 1e-10.
bars (int) : (series int) Number of bars in the move. Must be > 0.
Returns: (series float) The z-score, or na when inputs are invalid.
triangle(td, anchorPrice, anchorBar, targetPrice, targetBar, sig, lookback, mode)
Right triangle between an anchor and a target, computed entirely
in ICS space. Writes results in place into `td` and returns it.
On invalid inputs every field is set to na, so world X never
receives contaminated numbers.
Parameters:
td (TriangleData) : (TriangleData) Output object, updated in place.
anchorPrice (float) : (series float) Anchor price (world A). Must be > 0.
anchorBar (int) : (series int) Anchor bar_index.
targetPrice (float) : (series float) Target price (world A). Must be > 0.
targetBar (int) : (series int) Target bar_index. Must differ from anchorBar.
sig (float) : (series float) Yang-Zhang sigma. Must be > 1e-10.
lookback (int) : (series int) Horizontal unit window.
mode (series XScale) : (series XScale) Scaling mode.
Returns: (TriangleData) The same `td`, for chaining.
pinTriangle(td, anchorPrice, anchorBar, extremePrice, bodyPrice, curBar, sig, lookback, mode)
Pin (wick) triangle with three vertices in ICS space:
A = anchor, B = candle extreme, C = candle body edge.
Side BC is the wick. theta = signed angle at A between AB and AC.
Since xB = xC, the shoelace area reduces exactly to
0.5 * |yB - yC| * |dx|.
Parameters:
td (TriangleData) : (TriangleData) Output object, updated in place.
anchorPrice (float) : (series float) Anchor price (hh or ll). Must be > 0.
anchorBar (int) : (series int) Anchor bar_index.
extremePrice (float) : (series float) Candle extreme (high or low). Must be > 0.
bodyPrice (float) : (series float) Candle body edge. Must be > 0.
curBar (int) : (series int) Current bar_index. Must differ from anchorBar.
sig (float) : (series float) Yang-Zhang sigma. Must be > 1e-10.
lookback (int) : (series int) Horizontal unit window.
mode (series XScale) : (series XScale) Scaling mode.
Returns: (TriangleData) The same `td`, for chaining.
zeroTri(td)
Resets a TriangleData to na. Use when the structure is inactive,
so inactive periods never enter moving averages or normalization
as fake zero values.
Parameters:
td (TriangleData) : (TriangleData) Object to reset, updated in place.
Returns: (TriangleData) The same `td`, for chaining.
TriangleData
One triangle's measurements in ICS space. All fields dimensionless.
Fields:
theta (series float) : Signed hypotenuse angle in degrees; in isotropic mode tan(theta) is the z-score of the move.
dy (series float) : Signed Euclidean magnitude of the hypotenuse.
area (series float) : Triangle area (>= 0).
centroidY (series float) : Vertical centroid of the triangle.
FrozenAnchors
Anchors frozen at a reference bar, plus activity state.
Fields:
hh (series float) : Highest high at the freeze bar (world-A price units).
ll (series float) : Lowest low at the freeze bar (world-A price units).
mid (series float) : Geometric mean sqrt(hh * ll) at the freeze bar.
bar_x (series int) : bar_index of the freeze bar.
time_x (series int) : time of the freeze bar.
is_active (series bool) : Whether the frozen structure is currently active. Libreria

StocksDeveloperAlertsLibrary "StocksDeveloperAlerts"
AutoTrader Web alert builder by Stocks Developer — turn TradingView alerts into real broker orders across many accounts and brokers. Ready-made functions for single orders, options the easy way, 8 option structures (straddle/strangle/spreads/iron condor/iron fly), custom multi-leg, account or group targeting, and your own risk limits. No alert-text typing. stocksdeveloper.in
order(symbol, exchange, producttype, tradetype, account, group, lots, quantity, ordertype, price, triggerprice, validity, amo, optiontype, strike, expiry, spothint, usespot, onslicefailure, risk, extra)
Build an alert message for a single order (stock, futures or one option leg). This is the full builder; equity() and option() are shorter wrappers over it. Set exactly one of account/group and exactly one of lots/quantity. Add optiontype to make it an option order.
Parameters:
symbol (string) : (series string) Broker-independent symbol, e.g. "NIFTY", "BANKNIFTY", "SBIN". For options, pass the underlier (e.g. "NIFTY"), not a full contract.
exchange (string) : (series string) Exchange code, e.g. "NSE"/"BSE" for stocks, "NFO" for options and futures.
producttype (string) : (series string) INTRADAY, DELIVERY, NORMAL or MTF.
tradetype (string) : (series string) BUY or SELL.
account (string) : (series string) Place in this single account. Set this OR group.
group (string) : (series string) Place in every live account in this group. Set this OR account.
lots (int) : (series int) Number of lots. Set this OR quantity.
quantity (int) : (series int) Exact quantity. Set this OR lots.
ordertype (string) : (series string) MARKET (default), LIMIT, STOP_LOSS or SL_MARKET.
price (float) : (series float) Limit price (required for LIMIT).
triggerprice (float) : (series float) Trigger price (for stop-loss orders).
validity (string) : (series string) DAY (default) or IOC.
amo (bool) : (series bool) true for an after-market order.
optiontype (string) : (series string) CE for a call, PE for a put. Adding this makes it an option order.
strike (string) : (series string) ATM (default), ATM+1 / ATM-2, OTM / OTM2, ITM / ITM2, or an exact strike like "24500". Requires optiontype.
expiry (string) : (series string) weekly (default), next, monthly, or an exact date like "10-JUL-2026". Requires optiontype.
spothint (string) : (series string) Advanced: a spot price to help option-strike selection.
usespot (bool) : (series bool) Advanced: use the spot hint for strike selection.
onslicefailure (string) : (series string) Advanced: continue (default), alert or retry, if a large order that was auto-split has a slice fail.
risk (string) : (series string) A risk block from risk() — for example risk=atw.risk(maxloss=5000).
extra (string) : (series string) Advanced: any extra "key=value" lines to pass through unchanged (one per line).
Returns: (series string) The ready-to-send alert message.
equity(symbol, exchange, producttype, tradetype, account, group, lots, quantity, ordertype, price, triggerprice, validity, amo, risk, extra)
Build an alert for a single stock or futures order (no option fields). Set exactly one of account/group and exactly one of lots/quantity.
Parameters:
symbol (string) : (series string) Broker-independent symbol, e.g. "SBIN".
exchange (string) : (series string) Exchange code, e.g. "NSE" or "NFO".
producttype (string) : (series string) INTRADAY, DELIVERY, NORMAL or MTF.
tradetype (string) : (series string) BUY or SELL.
account (string) : (series string) Single account. Set this OR group.
group (string) : (series string) Group of accounts. Set this OR account.
lots (int) : (series int) Number of lots. Set this OR quantity.
quantity (int) : (series int) Exact quantity. Set this OR lots.
ordertype (string) : (series string) MARKET (default), LIMIT, STOP_LOSS or SL_MARKET.
price (float) : (series float) Limit price (required for LIMIT).
triggerprice (float) : (series float) Trigger price (for stop-loss orders).
validity (string) : (series string) DAY (default) or IOC.
amo (bool) : (series bool) true for an after-market order.
risk (string) : (series string) A risk block from risk().
extra (string) : (series string) Extra "key=value" lines to pass through unchanged.
Returns: (series string) The ready-to-send alert message.
option(symbol, exchange, producttype, tradetype, optiontype, strike, expiry, account, group, lots, quantity, ordertype, price, triggerprice, validity, amo, spothint, usespot, risk, extra)
Build an option order the easy way — give the underlier and pick the strike + expiry; no need to type the full option symbol. Set exactly one of account/group and exactly one of lots/quantity.
Parameters:
symbol (string) : (series string) The underlier, e.g. "NIFTY", "BANKNIFTY".
exchange (string) : (series string) Options exchange code, e.g. "NFO".
producttype (string) : (series string) INTRADAY, DELIVERY, NORMAL or MTF.
tradetype (string) : (series string) BUY or SELL.
optiontype (string) : (series string) CE for a call, PE for a put.
strike (string) : (series string) ATM (default), ATM+1 / ATM-2, OTM / OTM2, ITM / ITM2, or an exact strike like "24500".
expiry (string) : (series string) weekly (default), next, monthly, or an exact date like "10-JUL-2026".
account (string) : (series string) Single account. Set this OR group.
group (string) : (series string) Group of accounts. Set this OR account.
lots (int) : (series int) Number of lots. Set this OR quantity.
quantity (int) : (series int) Exact quantity. Set this OR lots.
ordertype (string) : (series string) MARKET (default), LIMIT, STOP_LOSS or SL_MARKET.
price (float) : (series float) Limit price (required for LIMIT).
triggerprice (float) : (series float) Trigger price (for stop-loss orders).
validity (string) : (series string) DAY (default) or IOC.
amo (bool) : (series bool) true for an after-market order.
spothint (string) : (series string) Advanced: a spot price to help strike selection.
usespot (bool) : (series bool) Advanced: use the spot hint for strike selection.
risk (string) : (series string) A risk block from risk().
extra (string) : (series string) Extra "key=value" lines to pass through unchanged.
Returns: (series string) The ready-to-send alert message.
straddle(symbol, exchange, producttype, account, group, lots, quantity, expiry, direction, ordertype, price, onlegfailure, risk, extra)
Straddle — buy (or sell) a call and a put at the money. direction "BUY" = long straddle, "SELL" = short straddle.
Parameters:
symbol (string) : (series string) The underlier, e.g. "NIFTY".
exchange (string) : (series string) Options exchange code, e.g. "NFO".
producttype (string) : (series string) INTRADAY, DELIVERY, NORMAL or MTF.
account (string) : (series string) Single account. Set this OR group.
group (string) : (series string) Group of accounts. Set this OR account.
lots (int) : (series int) Number of lots. Set this OR quantity.
quantity (int) : (series int) Exact quantity. Set this OR lots.
expiry (string) : (series string) weekly (default), next, monthly, or an exact date.
direction (string) : (series string) BUY (default) builds the structure as named; SELL flips every leg.
ordertype (string) : (series string) MARKET (default) or LIMIT.
price (float) : (series float) Limit price (required for LIMIT).
onlegfailure (string) : (series string) alert (default), cancel or continue, if one leg cannot be placed.
risk (string) : (series string) A risk block from risk().
extra (string) : (series string) Extra "key=value" lines to pass through unchanged.
Returns: (series string) The ready-to-send alert message.
strangle(symbol, exchange, producttype, account, group, lots, quantity, width, expiry, direction, ordertype, price, onlegfailure, risk, extra)
Strangle — buy (or sell) an out-of-the-money call and put, each 'width' strikes out. direction "BUY" = long strangle, "SELL" = short strangle.
Parameters:
symbol (string) : (series string) The underlier, e.g. "NIFTY".
exchange (string) : (series string) Options exchange code, e.g. "NFO".
producttype (string) : (series string) INTRADAY, DELIVERY, NORMAL or MTF.
account (string) : (series string) Single account. Set this OR group.
group (string) : (series string) Group of accounts. Set this OR account.
lots (int) : (series int) Number of lots. Set this OR quantity.
quantity (int) : (series int) Exact quantity. Set this OR lots.
width (int) : (series int) How far out of the money the legs sit, in strike steps (default 2).
expiry (string) : (series string) weekly (default), next, monthly, or an exact date.
direction (string) : (series string) BUY (default) or SELL (flips every leg).
ordertype (string) : (series string) MARKET (default) or LIMIT.
price (float) : (series float) Limit price (required for LIMIT).
onlegfailure (string) : (series string) alert (default), cancel or continue.
risk (string) : (series string) A risk block from risk().
extra (string) : (series string) Extra "key=value" lines to pass through unchanged.
Returns: (series string) The ready-to-send alert message.
bullCall(symbol, exchange, producttype, account, group, lots, quantity, width, expiry, direction, ordertype, price, onlegfailure, risk, extra)
Bull call spread — buy a call at the money and sell a call 'width' strikes out. Use direction "SELL" to reverse.
Parameters:
symbol (string) : (series string) The underlier, e.g. "NIFTY".
exchange (string) : (series string) Options exchange code, e.g. "NFO".
producttype (string) : (series string) INTRADAY, DELIVERY, NORMAL or MTF.
account (string) : (series string) Single account. Set this OR group.
group (string) : (series string) Group of accounts. Set this OR account.
lots (int) : (series int) Number of lots. Set this OR quantity.
quantity (int) : (series int) Exact quantity. Set this OR lots.
width (int) : (series int) Distance between the two strikes, in strike steps (default 2).
expiry (string) : (series string) weekly (default), next, monthly, or an exact date.
direction (string) : (series string) BUY (default) or SELL (flips every leg).
ordertype (string) : (series string) MARKET (default) or LIMIT.
price (float) : (series float) Limit price (required for LIMIT).
onlegfailure (string) : (series string) alert (default), cancel or continue.
risk (string) : (series string) A risk block from risk().
extra (string) : (series string) Extra "key=value" lines to pass through unchanged.
Returns: (series string) The ready-to-send alert message.
bearPut(symbol, exchange, producttype, account, group, lots, quantity, width, expiry, direction, ordertype, price, onlegfailure, risk, extra)
Bear put spread — buy a put at the money and sell a put 'width' strikes out. Use direction "SELL" to reverse.
Parameters:
symbol (string) : (series string) The underlier, e.g. "NIFTY".
exchange (string) : (series string) Options exchange code, e.g. "NFO".
producttype (string) : (series string) INTRADAY, DELIVERY, NORMAL or MTF.
account (string) : (series string) Single account. Set this OR group.
group (string) : (series string) Group of accounts. Set this OR account.
lots (int) : (series int) Number of lots. Set this OR quantity.
quantity (int) : (series int) Exact quantity. Set this OR lots.
width (int) : (series int) Distance between the two strikes, in strike steps (default 2).
expiry (string) : (series string) weekly (default), next, monthly, or an exact date.
direction (string) : (series string) BUY (default) or SELL (flips every leg).
ordertype (string) : (series string) MARKET (default) or LIMIT.
price (float) : (series float) Limit price (required for LIMIT).
onlegfailure (string) : (series string) alert (default), cancel or continue.
risk (string) : (series string) A risk block from risk().
extra (string) : (series string) Extra "key=value" lines to pass through unchanged.
Returns: (series string) The ready-to-send alert message.
bullPut(symbol, exchange, producttype, account, group, lots, quantity, width, expiry, direction, ordertype, price, onlegfailure, risk, extra)
Bull put spread (credit) — sell a put at the money and buy a put 'width' strikes out. Use direction "SELL" to reverse.
Parameters:
symbol (string) : (series string) The underlier, e.g. "NIFTY".
exchange (string) : (series string) Options exchange code, e.g. "NFO".
producttype (string) : (series string) INTRADAY, DELIVERY, NORMAL or MTF.
account (string) : (series string) Single account. Set this OR group.
group (string) : (series string) Group of accounts. Set this OR account.
lots (int) : (series int) Number of lots. Set this OR quantity.
quantity (int) : (series int) Exact quantity. Set this OR lots.
width (int) : (series int) Distance between the two strikes, in strike steps (default 2).
expiry (string) : (series string) weekly (default), next, monthly, or an exact date.
direction (string) : (series string) BUY (default) or SELL (flips every leg).
ordertype (string) : (series string) MARKET (default) or LIMIT.
price (float) : (series float) Limit price (required for LIMIT).
onlegfailure (string) : (series string) alert (default), cancel or continue.
risk (string) : (series string) A risk block from risk().
extra (string) : (series string) Extra "key=value" lines to pass through unchanged.
Returns: (series string) The ready-to-send alert message.
bearCall(symbol, exchange, producttype, account, group, lots, quantity, width, expiry, direction, ordertype, price, onlegfailure, risk, extra)
Bear call spread (credit) — sell a call at the money and buy a call 'width' strikes out. Use direction "SELL" to reverse.
Parameters:
symbol (string) : (series string) The underlier, e.g. "NIFTY".
exchange (string) : (series string) Options exchange code, e.g. "NFO".
producttype (string) : (series string) INTRADAY, DELIVERY, NORMAL or MTF.
account (string) : (series string) Single account. Set this OR group.
group (string) : (series string) Group of accounts. Set this OR account.
lots (int) : (series int) Number of lots. Set this OR quantity.
quantity (int) : (series int) Exact quantity. Set this OR lots.
width (int) : (series int) Distance between the two strikes, in strike steps (default 2).
expiry (string) : (series string) weekly (default), next, monthly, or an exact date.
direction (string) : (series string) BUY (default) or SELL (flips every leg).
ordertype (string) : (series string) MARKET (default) or LIMIT.
price (float) : (series float) Limit price (required for LIMIT).
onlegfailure (string) : (series string) alert (default), cancel or continue.
risk (string) : (series string) A risk block from risk().
extra (string) : (series string) Extra "key=value" lines to pass through unchanged.
Returns: (series string) The ready-to-send alert message.
ironCondor(symbol, exchange, producttype, account, group, lots, quantity, width, wing, expiry, direction, ordertype, price, onlegfailure, risk, extra)
Iron condor — sell a call and a put 'width' strikes out, and buy a call and a put 'width'+'wing' strikes out as protection. direction "BUY" builds this credit condor; "SELL" reverses it.
Parameters:
symbol (string) : (series string) The underlier, e.g. "NIFTY".
exchange (string) : (series string) Options exchange code, e.g. "NFO".
producttype (string) : (series string) INTRADAY, DELIVERY, NORMAL or MTF.
account (string) : (series string) Single account. Set this OR group.
group (string) : (series string) Group of accounts. Set this OR account.
lots (int) : (series int) Number of lots. Set this OR quantity.
quantity (int) : (series int) Exact quantity. Set this OR lots.
width (int) : (series int) How far out the sold legs sit, in strike steps (default 2).
wing (int) : (series int) Extra distance out to the protective legs, in strike steps (defaults to width).
expiry (string) : (series string) weekly (default), next, monthly, or an exact date.
direction (string) : (series string) BUY (default) or SELL (flips every leg).
ordertype (string) : (series string) MARKET (default) or LIMIT.
price (float) : (series float) Limit price (required for LIMIT).
onlegfailure (string) : (series string) alert (default), cancel or continue.
risk (string) : (series string) A risk block from risk().
extra (string) : (series string) Extra "key=value" lines to pass through unchanged.
Returns: (series string) The ready-to-send alert message.
ironFly(symbol, exchange, producttype, account, group, lots, quantity, wing, expiry, direction, ordertype, price, onlegfailure, risk, extra)
Iron fly — sell a call and a put at the money, and buy a call and a put 'wing' strikes out as protection. direction "BUY" builds this credit fly; "SELL" reverses it.
Parameters:
symbol (string) : (series string) The underlier, e.g. "NIFTY".
exchange (string) : (series string) Options exchange code, e.g. "NFO".
producttype (string) : (series string) INTRADAY, DELIVERY, NORMAL or MTF.
account (string) : (series string) Single account. Set this OR group.
group (string) : (series string) Group of accounts. Set this OR account.
lots (int) : (series int) Number of lots. Set this OR quantity.
quantity (int) : (series int) Exact quantity. Set this OR lots.
wing (int) : (series int) How far out the protective legs sit, in strike steps (default 2).
expiry (string) : (series string) weekly (default), next, monthly, or an exact date.
direction (string) : (series string) BUY (default) or SELL (flips every leg).
ordertype (string) : (series string) MARKET (default) or LIMIT.
price (float) : (series float) Limit price (required for LIMIT).
onlegfailure (string) : (series string) alert (default), cancel or continue.
risk (string) : (series string) A risk block from risk().
extra (string) : (series string) Extra "key=value" lines to pass through unchanged.
Returns: (series string) The ready-to-send alert message.
leg(optiontype, strike, tradetype, multiplier)
Build one option leg string for use with multiLeg(), e.g. atw.leg("CE", "ATM+2", "SELL", 2) -> "CE ATM+2 SELL x2".
Parameters:
optiontype (string) : (series string) CE for a call, PE for a put.
strike (string) : (series string) ATM, ATM+2, OTM2, ITM1, or an exact strike like "24500".
tradetype (string) : (series string) BUY or SELL for this leg.
multiplier (int) : (series int) Size multiplier for this leg (default 1).
Returns: (series string) The leg descriptor.
multiLeg(symbol, exchange, producttype, legs, account, group, lots, quantity, expiry, ordertype, price, onlegfailure, risk, extra)
Build an alert for a fully custom multi-leg order from a list of legs (1 to 10) made with leg(). Set exactly one of account/group and exactly one of lots/quantity.
Parameters:
symbol (string) : (series string) The underlier, e.g. "NIFTY".
exchange (string) : (series string) Options exchange code, e.g. "NFO".
producttype (string) : (series string) INTRADAY, DELIVERY, NORMAL or MTF.
legs (array) : (array) The legs, e.g. array.from(atw.leg("PE","ATM-2","SELL"), atw.leg("PE","ATM-6","BUY")).
account (string) : (series string) Single account. Set this OR group.
group (string) : (series string) Group of accounts. Set this OR account.
lots (int) : (series int) Number of lots. Set this OR quantity.
quantity (int) : (series int) Exact quantity. Set this OR lots.
expiry (string) : (series string) weekly (default), next, monthly, or an exact date.
ordertype (string) : (series string) MARKET (default) or LIMIT.
price (float) : (series float) Limit price (required for LIMIT).
onlegfailure (string) : (series string) alert (default), cancel or continue.
risk (string) : (series string) A risk block from risk().
extra (string) : (series string) Extra "key=value" lines to pass through unchanged.
Returns: (series string) The ready-to-send alert message.
riskLimits(maxloss, forceexit, entrywindow, blockExpiry)
Build a risk-limits block to attach to any order via risk=. Example: risk=atw.riskLimits(maxloss=5000). These are your own limits; see the Alert Automation guide for exactly how each one behaves.
Parameters:
maxloss (float) : (series float) Maximum day loss for the account, in your account currency.
forceexit (string) : (series string) A square-off time as "HH:mm", e.g. "15:15".
entrywindow (string) : (series string) An allowed entry-time window "HH:mm-HH:mm", e.g. "09:30-14:30".
blockExpiry (bool) : (series bool) Block new entries on the instrument's expiry day.
Returns: (series string) The risk lines, ready to pass as risk=. Libreria
