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. Library

Library

Library

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

Library

Library

Library

ChopEngineLibrary "ChopEngine"
chopBase(_high, _low, _len)
Parameters:
_high (float)
_low (float)
_len (simple int)
gaugeFromCi(_ci, _tl, _cl)
Parameters:
_ci (float)
_tl (simple float)
_cl (simple float)
chopGauge(_high, _low, _tl, _cl, _len)
Parameters:
_high (float)
_low (float)
_tl (simple float)
_cl (simple float)
_len (simple int)
getChopBase(_sym, _tf)
Parameters:
_sym (simple string)
_tf (simple string)
getChop(_ciPrev, _ci, _tl, _cl)
Parameters:
_ciPrev (simple float)
_ci (simple float)
_tl (simple float)
_cl (simple float)
chgStateLabel(_g)
Parameters:
_g (float)
chgColor(_chg)
Parameters:
_chg (float)
chgCell(_chg, _prefix)
Parameters:
_chg (float)
_prefix (string)
method init(this, _ciPrev, _ci, _tl, _cl)
Namespace types: Chop
Parameters:
this (Chop)
_ciPrev (float)
_ci (float)
_tl (simple float)
_cl (simple float)
method update(this, _ciPrev, _ci, _tl, _cl)
Namespace types: Chop
Parameters:
this (Chop)
_ciPrev (float)
_ci (float)
_tl (simple float)
_cl (simple float)
method chgVsPrev(this)
Namespace types: Chop
Parameters:
this (Chop)
method chgVsEod(this)
Namespace types: Chop
Parameters:
this (Chop)
method state(this)
Namespace types: Chop
Parameters:
this (Chop)
method isTrending(this)
Namespace types: Chop
Parameters:
this (Chop)
method isChoppy(this)
Namespace types: Chop
Parameters:
this (Chop)
method isImproving(this)
Namespace types: Chop
Parameters:
this (Chop)
method isDeteriorating(this)
Namespace types: Chop
Parameters:
this (Chop)
Chop
Fields:
now (series float)
prev (series float)
eod (series float) Library

PriceActionLibrary "PriceAction"
Will draw out the market structure for the disired pivot length.
SetBarIndices(pivotHigh, pivotLow)
Sets the 'BarIndex' value of the 'Pivot' object. Useful if the pivot is from an other timeframe.
Parameters:
pivotHigh (Pivot) : The 'Pivot' object for the high pivot.
pivotLow (Pivot) : The 'Pivot' object for the low pivot.
Alert(turtleSoupsContext, settings)
Will fire off an alert if there is one. To be used lastly in the calling script.
Parameters:
turtleSoupsContext (TurtleSoups) : The context of all turtle soups.
settings (TurtleSoupSettings) : The settings for turtle soups.
VisualizeTurtleSoups(pivots, turtleSoups, turtleSoupsContext, settings)
Will visulize found turtle soups and add alert messages for it.
Parameters:
pivots (array) : All current pivots (high or low).
turtleSoups (array) : All bullish or bearish turtle soups.
turtleSoupsContext (TurtleSoups) : The context of all turtle soups.
settings (TurtleSoupSettings) : The settings for turtle soups.
GetPivots(settings)
Will get available pivots. Can be called from another timeframe.
Parameters:
settings (TurtleSoupSettings) : The settings for turtle soups.
Returns: A tuple of high and then low pivots.
SetPivots(turtleSoupsContext, settings, pivotHigh, pivotLow)
Will set the new pivots in turtleSoupsContext.
Parameters:
turtleSoupsContext (TurtleSoups) : The context of all turtle soups.
settings (TurtleSoupSettings) : The settings for turtle soups.
pivotHigh (Pivot) : The 'Pivot' object for the high pivot.
pivotLow (Pivot) : The 'Pivot' object for the low pivot.
Confirm(turtleSoups, turtleSoupsContext, settings, previousStructureBreakBarIndex, screener)
Will visualize turtle soups. To be called if 'TurtleSoupSettings.Confirmation' is true.
Parameters:
turtleSoups (array) : All bullish or bearish turtle soups.
turtleSoupsContext (TurtleSoups) : The context of all turtle soups.
settings (TurtleSoupSettings) : The settings for turtle soups.
previousStructureBreakBarIndex (int) : The bar index of the previous structure break (BOS/CHoCH/CHoCH+).
screener (Screener) : The 'Screener' object to be used for Pine Screening by Tradingview. The function will set 'TurtleSoupUntilBarIndex' if there's a confirmed turtle soup.
Liqudity(liquidity)
Will draw liquidity.
Parameters:
liquidity (Liquidity) : The 'PriceAction.Liquidity' object.
Pivot(structure)
Sets the pivots in the structure.
Parameters:
structure (Structure)
PivotLabels(structure)
Draws labels for the pivots found.
Parameters:
structure (Structure)
EqualHighOrLow(structure)
Draws the boxes for equal highs/lows. Also creates labels for the pivots included.
Parameters:
structure (Structure)
BreakOfStructure(structure)
Will create lines when a break of strycture occures.
Parameters:
structure (Structure)
Returns: The 'Pivot' that caused the break of structure, na otherwise.
ChangeOfCharacter(structure)
Will create lines when a change of character occures. This line will have a label with "CHoCH" or "CHoCH+".
Parameters:
structure (Structure)
Returns: The 'Pivot' that caused the change of character, na otherwise.
VisualizeCurrent(structure)
Will create a box with a background for between the latest high and low pivots. This can be used as the current trading range (if the pivots broke strucure somehow).
Parameters:
structure (Structure)
StructureBreak
Holds drawings for a structure break.
Fields:
Line (series line) : The line object.
Label (series label) : The label object.
Pivot
Holds all the values for a found pivot.
Fields:
Price (series float) : The price of the pivot.
BarIndex (series int) : The bar_index where the pivot occured.
Type (series int) : The type of the pivot (-1 = low, 1 = high).
Time (series int) : The time where the pivot occured.
BreakOfStructureBroken (series bool) : Sets to true if a break of structure has happened.
LiquidityBroken (series bool) : Sets to true if a liquidity of the price level has happened.
ChangeOfCharacterBroken (series bool) : Sets to true if a change of character has happened.
Structure
Holds all the values for the market structure.
Fields:
LeftLength (series int) : Define the left length of the pivots used.
RightLength (series int) : Define the right length of the pivots used.
Type (series Type) : Set the type of the market structure. Two types can be used, 'internal' and 'swing' (0 = internal, 1 = swing).
Trend (series int) : This will be set internally and can be -1 = downtrend, 1 = uptrend.
EqualPivotsFactor (series float) : Set how the limits are for an equal pivot. This is a factor of the Average True Length (ATR) of length 14. If a low pivot is considered to be equal if it doesn't break the low pivot (is at a lower value) and is inside the previous low pivot + this limit.
ExtendEqualPivotsZones (series bool) : Set to true if you want the equal pivots zones to be extended.
ExtendEqualPivotsStyle (series string) : Set the style of equal pivot zones.
ExtendEqualPivotsColor (series color) : Set the color of equal pivot zones.
EqualHighs (array) : Holds the boxes for zones that contains equal highs.
EqualLows (array) : Holds the boxes for zones that contains equal lows.
BreakOfStructures (array) : Holds all the break of structures within the trend (before a change of character).
Pivots (array) : All the pivots in the current trend, added with the latest first, this is cleared when the trend changes.
FontSize (series int) : Holds the size of the font displayed.
AlertChangeOfCharacter (series bool) : Holds true or false if a change of character should be alerted or not.
AlertBreakOfStructure (series bool) : Holds true or false if a break of structure should be alerted or not.
AlerEqualPivots (series bool) : Holds true or false if equal highs/lows should be alerted or not.
Liquidity
Holds all the values for liquidity.
Fields:
LiquidityPivotsHigh (array) : All high pivots for liquidity.
LiquidityPivotsLow (array) : All low pivots for liquidity.
LiquidityConfirmationBars (series int) : The number of bars to confirm that a liquidity is valid.
LiquidityPivotsLookback (series int) : A number of pivots to look back for.
FontSize (series int) : Holds the size of the font displayed.
PriceAction
Holds all the values for the general price action and the market structures.
Fields:
Liquidity (Liquidity)
Swing (Structure) : Placeholder for all objects used for the swing market structure.
Internal (Structure) : Placeholder for all objects used for the internal market structure.
TurtleSoupSettings
Holds sll the values for the settings for turtle soups.
Fields:
PivotLeftLenght (series int) : Define the left length of the pivots used.
PivotRightLenght (series int) : Define the right length of the pivots used.
Lookback (series int) : Set how many pivots back that will be used.
Confirmation (series bool) : Set if you want confirmation to be needed for q turtle soup to be formed (e g. a CHoCH).
Color (series color) : The color of turtle soups.
ScreenerKeep (series int) : Set the number of bars that the plot 'Turtle soup' will have a value after a turtle soup is found.
AlertFrequency (series string) : Set the frequency of alerts, possible values are 'alert.freq_all', 'alert.freq_once_per_bar' or 'alert.freq_once_per_bar_close'.
TurtleSoup
To be used when a turtle soup is found and holds all values needed for it.
Fields:
Line (series line) : The line object between the pivot and the turtle soup.
Box (series box) : The bos for the turtle soup.
Start (series int) : The first bar of the turtle soup.
End (series int) : The last bar of the turtle soup.
Pivot (Pivot) : The pivot which liquidity was taken by the turtle soup.
Screener
Holds all values to be used in the Pine Screener by Tradingview.
Fields:
TurtleSoupUntilBarIndex (series int) : Pine Screener value for turtle soups.
TurtleSoups
TurtleSoups The entire context for all turtle soups.
Fields:
Highs (array) : The high pivots.
Lows (array) : The low pivots.
Bullish (array) : Bullish turtle soups.
Bearish (array) : Bearish turtle soups.
AlertMessages (array) : All messages for the current iteration. Library

OriginLifecycleLibrary "OriginLifecycle"
Strict Highlander v7 origin lifecycle for engulfing indicators.
Exports enums, an OriginCandidate UDT, and four helper functions
used by engulfing_opportunities_v20.6+ to detect, track, promote,
invalidate, and consume origin levels discovered on lower
timeframes inside an engulfment zone.
Published-as-library rationale: the engulfing indicator is already at Pine v6's
top-level-declaration limit (CE10295). Moving these types and functions into a
library frees ~7 declarations in the main script without changing semantics.
Reference: highlander_v7.pine:212-293 for the state-transition rules this
implementation mirrors.
tickStateMachine(c, bO, bH, bL, bC, bTime)
Pure state-transition function. One closed LTF bar in,
updated candidate out. Mirrors highlander_v7.pine:212-293.
Parameters:
c (OriginCandidate) : The current candidate state.
bO (float) : Bar open.
bH (float) : Bar high.
bL (float) : Bar low.
bC (float) : Bar close.
bTime (int) : Bar start time in ms.
Returns: Updated OriginCandidate with `lastProcessedTime := bTime`.
Caller is responsible for:
- Only passing CLOSED LTF bars.
- Skipping bars whose time <= c.lastProcessedTime.
- On BROKEN_BSUT, looking for a retest in subsequent bars to delete.
scanForBreakCandidates(isBullish, zoneLow, zoneHigh, prevO, prevH, prevL, prevC, prevT, currO, currH, currL, currC, currT, ltfValid, ltfMin, tfLabel, outCandidates)
Find new BREAK pairs in the engulfment zone and push
them to `outCandidates` if not already tracked. De-dup
key is (price, createdTime, tfLabel).
Parameters:
isBullish (bool) : true -> look for SUPPORT (green-green) pairs;
false -> look for RESISTANCE (red-red) pairs.
zoneLow (float) : Lower bound of the engulfment zone (inclusive).
zoneHigh (float) : Upper bound of the engulfment zone (inclusive).
prevO (array)
prevH (array)
prevL (array)
prevC (array)
prevT (array)
currO (array)
currH (array)
currL (array)
currC (array)
currT (array)
ltfValid (bool) : Pre-computed validity flag for this LTF.
ltfMin (int) : LTF length in minutes (baked into each new candidate).
tfLabel (string) : Display string, e.g. "1H".
outCandidates (array) : The per-pattern candidate array to push into.
Returns: Nothing (mutates outCandidates).
processNewLTFBars(candidates, ltfMin, prevO, prevH, prevL, prevC, prevT, currO, currH, currL, currC, currT, ltfValid)
Drive the state machine across unprocessed LTF bars for every
candidate whose `ltfMinutes == ltfMin`. Removes candidates
that reach BROKEN_BSUT AND see a retest within the buffer.
Parameters:
candidates (array) : The per-pattern candidate array to update.
ltfMin (int) : The LTF length this buffer represents; candidates with a
different ltfMinutes are skipped.
prevO (array)
prevH (array)
prevL (array)
prevC (array)
prevT (array)
currO (array)
currH (array)
currL (array)
currC (array)
currT (array)
ltfValid (bool) : Validity flag.
Returns: Nothing (mutates candidates).
applyConsumedOnTouch(candidates, greedyEntries, greedyConsumedFlags, isBullish, curLow, curHigh)
Per-tick sweep. Marks CONFIRMED origins and
untouched greedy entries as consumed once price
wicks into them. Caller passes `curLow`/`curHigh`
because library functions cannot reference the
`low`/`high` chart globals directly.
Parameters:
candidates (array) : Per-pattern origin-candidate array.
greedyEntries (array) : Per-pattern greedy-entry price array.
greedyConsumedFlags (array) : Parallel bool array — resized lazily to match
greedyEntries size.
isBullish (bool) : Drives the touch check for greedy entries
(origins use their own per-candidate dir).
curLow (float) : Current bar low (pass `low` from caller).
curHigh (float) : Current bar high (pass `high` from caller).
Returns: Nothing (mutates both arrays).
OriginCandidate
A single tracked origin candidate.
Fields:
tfLabel (series string) : Display string ("1H", "5m" etc.).
ltfMinutes (series int) : Lower-timeframe length in minutes; used for the
price (series float) : The origin level price.
dir (series OriginDir) : UP (support) or DOWN (resistance).
state (series OriginState) : Current lifecycle state.
firstTouchTime (series int) : ms timestamp of first touch (0 if `touchSeen == false`).
touchSeen (series bool) : True once this candidate has been touched at least once.
createdTime (series int) : ms timestamp of the d1 bar that formed the BREAK pair.
lastProcessedTime (series int) : ms timestamp of the last LTF bar fed through the
consecutiveDirCount (series int) : Counter for 2-bar CONFIRMED confirmation, 0-2. Library

Library

Library

Library

Library

MyLibraryPubLibrary "MyLibraryPub"
TODO: add library description here
futu_ema(src, len)
与futu的MA系统,保持一致
Parameters:
src (float)
len (int)
MaxEMA(c)
多头ema最大值
Parameters:
c (float)
MaxEMA10(c)
多头ema最大值,10
Parameters:
c (float)
isEmpty(inStr)
空字符判定
Parameters:
inStr (string)
Bull_Max(tk, tf)
进入多头价格
Parameters:
tk (string)
tf (string)
Bull_Day(tk, tf)
多头天数
Parameters:
tk (string)
tf (string)
Bull(tk, tf)
是否多头
Parameters:
tk (string)
tf (string)
Bull10(tk, tf)
是否多头10
Parameters:
tk (string)
tf (string)
Bull_BuyMax(tk, tf)
可以买的最大值
Parameters:
tk (string)
tf (string)
Bull_BuyStatus(tk, tf)
当前状态
Parameters:
tk (string)
tf (string)
pct_D20(tk, tf)
涨幅
Parameters:
tk (string)
tf (string)
pct_D10(tk, tf)
涨幅
Parameters:
tk (string)
tf (string)
pct_D5(tk, tf)
涨幅
Parameters:
tk (string)
tf (string) Library

Library

Library

smaemarvwapClaireLibrary "smaemarvwapClaire"
repeat_character(count)
Parameters:
count (int)
f_1_k_line_width()
is_price_in_merge_range(p1, p2, label_merge_range)
Parameters:
p1 (float)
p2 (float)
label_merge_range (float)
get_pre_label_string(kc, t, is_every)
Parameters:
kc (VWAP_key_levels_draw_settings)
t (int)
is_every (bool)
f_is_new_period_from_str(str)
Parameters:
str (string)
total_for_time_when(source, days, ma_set)
Parameters:
source (float)
days (int)
ma_set (ma_setting)
f_calculate_sma_ema_rolling_vwap(src, length, ma_settings)
Parameters:
src (float)
length (simple int)
ma_settings (ma_setting)
f_calculate_sma_ema_rvwap(ma_settings)
Parameters:
ma_settings (ma_setting)
f_get_ma_pre_label(ma_settings, sma, ema, rolling_vwap)
Parameters:
ma_settings (ma_setting)
sma (float)
ema (float)
rolling_vwap (float)
f_smart_ma_calculation(ma_settings2)
Parameters:
ma_settings2 (ma_setting)
f_calculate_endpoint(start_time, kc, is_every, endp, extend1, extend2, line_label_extend_length)
Parameters:
start_time (int)
kc (VWAP_key_levels_draw_settings)
is_every (bool)
endp (int)
extend1 (bool)
extend2 (bool)
line_label_extend_length (int)
f_single_line_label_fatory(left_point, right_point, line_col, line_width, lines_style_select, labeltext_col, label_text_size, label_array, line_array, label_col, label_text, l1, label1)
根据两个点创建线段和/或标签,并将其添加到对应的数组中
Parameters:
left_point (chart.point) : 左侧起点坐标
right_point (chart.point) : 右侧终点坐标
line_col (color) : 线段颜色
line_width (int) : 线段宽度
lines_style_select (string) : 线段样式(实线、虚线等)
labeltext_col (color) : 标签文字颜色
label_text_size (string) : 标签文字大小
label_array (array) : 存储标签对象的数组
line_array (array) : 存储线段对象的数组
label_col (color) : 标签背景颜色(默认:半透明色)
label_text (string) : 标签文字内容(默认:空字符串)
l1 (bool) : 是否创建线段(默认:false)
label1 (bool) : 是否创建标签(默认:false)
Returns: void
f_line_and_label_merge_func(t, data, l_text, kc, is_every, endp, merge_str_map, label_array, line_array, extend1, extend2, line_label_extend_length, label_merge_control, line_width, lines_style_select, label_text_size)
Parameters:
t (int)
data (float)
l_text (string)
kc (VWAP_key_levels_draw_settings)
is_every (bool)
endp (int)
merge_str_map (map)
label_array (array)
line_array (array)
extend1 (bool)
extend2 (bool)
line_label_extend_length (int)
label_merge_control (bool)
line_width (int)
lines_style_select (string)
label_text_size (string)
plot_ohlc(kc, ohlc_data, extend1, extend2, merge_str_map, label_array, line_array, is_every, line_label_extend_length, label_merge_control, line_width, lines_style_select, label_text_size)
Parameters:
kc (VWAP_key_levels_draw_settings)
ohlc_data (bardata)
extend1 (bool)
extend2 (bool)
merge_str_map (map)
label_array (array)
line_array (array)
is_every (bool)
line_label_extend_length (int)
label_merge_control (bool)
line_width (int)
lines_style_select (string)
label_text_size (string)
plot_vwap_keylevels(kc, vwap_data, extend1, extend2, merge_str_map, label_array, line_array, is_every, line_label_extend_length, label_merge_control, line_width, lines_style_select, label_text_size)
Parameters:
kc (VWAP_key_levels_draw_settings)
vwap_data (vwap_snapshot)
extend1 (bool)
extend2 (bool)
merge_str_map (map)
label_array (array)
line_array (array)
is_every (bool)
line_label_extend_length (int)
label_merge_control (bool)
line_width (int)
lines_style_select (string)
label_text_size (string)
plot_vwap_bardata(kc, ohlc_data, vwap_data, extend1, extend2, merge_str_map, label_array, line_array, is_every, line_label_extend_length, label_merge_control, line_width, lines_style_select, label_text_size)
Parameters:
kc (VWAP_key_levels_draw_settings)
ohlc_data (bardata)
vwap_data (vwap_snapshot)
extend1 (bool)
extend2 (bool)
merge_str_map (map)
label_array (array)
line_array (array)
is_every (bool)
line_label_extend_length (int)
label_merge_control (bool)
line_width (int)
lines_style_select (string)
label_text_size (string)
f_start_end_total_min(session)
Parameters:
session (string)
f_get_vwap_array(anchor1, data_manager, is_historical)
Parameters:
anchor1 (string)
data_manager (data_manager)
is_historical (bool)
f_get_bardata_array(anchorh, data_manager, is_historical)
Parameters:
anchorh (string)
data_manager (data_manager)
is_historical (bool)
vwap_snapshot
Fields:
t (series int)
vwap (series float)
upper1 (series float)
lower1 (series float)
upper2 (series float)
lower2 (series float)
upper3 (series float)
lower3 (series float)
VWAP_key_levels_draw_settings
Fields:
enable (series bool)
index (series int)
anchor (series string)
session (series string)
vwap_col (series color)
bands_col (series color)
bg_color (series color)
text_color (series color)
val (series bool)
poc (series bool)
vah (series bool)
enable2x (series bool)
enable3x (series bool)
o_control (series bool)
h_control (series bool)
l_control (series bool)
c_control (series bool)
extend_control (series bool)
only_show_the_lastone_control (series bool)
bg_control (series bool)
line_col_labeltext_col (series color)
bardata
Fields:
o (series float)
h (series float)
l (series float)
c (series float)
v (series float)
start_time (series int)
end_time (series int)
ma_setting
Fields:
day_control (series bool)
kline_numbers (series int)
ma_color (series color)
ema_color (series color)
rvwap_color (series color)
ma_control (series bool)
ema_control (series bool)
rvwap_control (series bool)
session (series string)
merge_label_template
Fields:
left_point (chart.point)
right_point (chart.point)
label_text (series string)
p (series float)
label_color (series color)
merge_init_false (series bool)
anchor_snapshots
Fields:
vwap_current (array)
vwap_historical (array)
bardata_current (array)
bardata_historical (array)
data_manager
Fields:
snapshots_map (map)
draw_settings_map (map) Library

Library

BASCOOL_LibBASCOOL Library v1
Range–Body Structure Analysis Toolkit for Intraday Trading
The BASCOOL Library provides high-quality, reusable Pine Script components for structural conviction analysis based purely on price action. It is designed for intraday traders who rely on volatility-adjusted range expansion and candle-body efficiency to identify strong, weak, or choppy market conditions.
Included Functions
rbm_from_ohlc() – Range–Body Measure (RBM)
A volatility-normalized structure indicator that evaluates:
Range Expansion:
Smooth EMA of (High–Low), normalized by ATR
→ captures strength of movement relative to volatility
Body Efficiency:
Body-to-Range ratio smoothed with EMA
→ measures how much of the candle’s range is “directional”
The RBM output is a smooth structural strength score typically between 0 and 1, where:
High RBM → strong structure, clean movement, trend-friendly conditions
Low RBM → compressed ranges, weak bodies, low-quality structure
Flat RBM → choppy environment, avoid directional trades Library

Library

Library
