OverfittingMetricsLibrary "OverfittingMetrics"
calculateMetrics(tradeResults, tradeTypes, minTrades, startCapital)
Parameters:
tradeResults (array)
tradeTypes (array)
minTrades (int)
startCapital (float)
randomizeParameter(baseValue, variationPercent, seed)
Parameters:
baseValue (float)
variationPercent (float)
seed (int)
classifyMarket(priceSeries, lookbackLength)
Parameters:
priceSeries (float)
lookbackLength (simple int)
checkOverfittingWarnings(winRate, profitFactor, totalTrades)
Parameters:
winRate (float)
profitFactor (float)
totalTrades (int)
calculateConsistency(tradeResults)
Parameters:
tradeResults (array)
isOverfitDetected(winRate, profitFactor, totalTrades, minTrades)
Parameters:
winRate (float)
profitFactor (float)
totalTrades (int)
minTrades (int)
getOverfitScore(winRate, profitFactor, totalTrades)
Parameters:
winRate (float)
profitFactor (float)
totalTrades (int)
Alerts
AssetCorrelationUtils
- Open source Library Used for Indicators that utilize correlation between assets for divergence calculations. It has no drawing elements.
ASSET CORRELATION UTILS
PineScript library for automatic detection of correlated asset pairs and triads for multi-asset analysis.
WHAT IT DOES
This library automatically identifies correlated assets based on the current chart symbol. It returns properly configured asset pairings for use in SMT divergence detection, inter-market analysis, and multi-asset comparison tools.
HOW IT WORKS
The library matches your chart symbol against known correlation groups:
Index Futures: NQ/ES/YM/RTY triads (including micros)
Metals: Gold/Silver/Copper triads (futures and CFD)
Forex: EUR/GBP/DXY and USD/JPY/CHF triads
Energy: Crude/Gasoline/Heating Oil triads
Treasury: ZB/ZF/ZN bond triads
Crypto: BTC/ETH/TOTAL3 and major altcoin pairings
Inversion flags are automatically computed for assets that move inversely (e.g., DXY vs EUR pairs).
HOW TO USE
import fstarcapital/AssetCorrelationUtils/1 as acu
// Simple: auto-detect from current chart
config = acu.resolveCurrentChart()
// Access resolved assets
primary = config.primary
secondary = config.secondary
tertiary = config.tertiary
EXPORTED FUNCTIONS
resolveCurrentChart(): One-call auto-detection using chart syminfo
resolveAssets(): Full detection with custom parameters
resolveTriad() / resolveDyad(): Manual resolution with inversion logic
detect*() functions: Category-specific detectors for custom workflows
TYPES
AssetPairing: Core structure for primary/secondary/tertiary tickers with inversion flags
AssetConfig: Full resolution result with detection status and asset category
DISCLAIMER
This library is a utility for building multi-asset indicators. Asset correlations are not guaranteed and may change over time. Always validate pairings for your specific trading context.
Full Default Function @type and @field descriptions below.
Library "AssetCorrelationUtils"
detectIndicesFutures(ticker)
Detects Index Futures (NQ/ES/YM/RTY + micro variants)
Parameters:
ticker (string) : The ticker string to check (typically syminfo.ticker)
Returns: AssetPairing with secondary and tertiary assets configured
detectMetalsFutures(ticker)
Detects Metal Futures (GC/SI/HG + micro variants)
Parameters:
ticker (string) : The ticker string to check
Returns: AssetPairing with secondary and tertiary assets configured
detectForexFutures(ticker)
Detects Forex Futures (6E/6B + micro variants)
Parameters:
ticker (string) : The ticker string to check
Returns: AssetPairing with secondary and tertiary assets configured
detectEnergyFutures(ticker)
Detects Energy Futures (CL/RB/HO + micro variants)
Parameters:
ticker (string) : The ticker string to check
Returns: AssetPairing with secondary and tertiary assets configured
detectTreasuryFutures(ticker)
Detects Treasury Futures (ZB/ZF/ZN)
Parameters:
ticker (string) : The ticker string to check
Returns: AssetPairing with secondary and tertiary assets configured
detectCryptoFutures(ticker)
Detects CME Crypto Futures (BTC/ETH + micro variants)
Parameters:
ticker (string) : The ticker string to check
Returns: AssetPairing with secondary and tertiary assets configured
detectCADFutures(ticker)
Detects CAD Forex Futures (6C + micro variants)
Parameters:
ticker (string) : The ticker string to check
Returns: AssetPairing with secondary and tertiary assets configured
detectForexCFD(ticker, tickerId)
Detects Forex CFD pairs (EUR/GBP/DXY, USD/JPY/CHF triads)
Parameters:
ticker (string) : The ticker string to check
tickerId (string) : The full ticker ID (syminfo.tickerid) for primary asset
Returns: AssetPairing with secondary and tertiary assets configured
detectCrypto(ticker, tickerId)
Detects major Crypto assets (BTC, ETH, SOL, XRP, alts)
Parameters:
ticker (string) : The ticker string to check
tickerId (string) : The full ticker ID for primary asset
Returns: AssetPairing with secondary and tertiary assets configured
detectMetalsCFD(ticker, tickerId)
Detects Metals CFD (XAU/XAG/Copper)
Parameters:
ticker (string) : The ticker string to check
tickerId (string) : The full ticker ID for primary asset
Returns: AssetPairing with secondary and tertiary assets configured
detectIndicesCFD(ticker, tickerId)
Detects Indices CFD (NAS100/SP500/DJ30)
Parameters:
ticker (string) : The ticker string to check
tickerId (string) : The full ticker ID for primary asset
Returns: AssetPairing with secondary and tertiary assets configured
detectEUStocks(ticker, tickerId)
Detects EU Stock Indices (GER40/EU50) - Dyad only
Parameters:
ticker (string) : The ticker string to check
tickerId (string) : The full ticker ID for primary asset
Returns: AssetPairing with secondary asset configured (tertiary empty for dyad)
getDefaultFallback(tickerId)
Returns default fallback assets (chart ticker only, no correlation)
Parameters:
tickerId (string) : The full ticker ID for primary asset
Returns: AssetPairing with chart ticker as primary, empty secondary/tertiary (no correlation)
applySessionModifierWithBackadjust(tickerStr, sessionType)
Applies futures session modifier to ticker WITH back adjustment
Parameters:
tickerStr (string) : The ticker to modify
sessionType (string) : The session type (syminfo.session)
Returns: Modified ticker string with session and backadjustment.on applied
applySessionModifierNoBackadjust(tickerStr, sessionType)
Applies futures session modifier to ticker WITHOUT back adjustment
Parameters:
tickerStr (string) : The ticker to modify
sessionType (string) : The session type (syminfo.session)
Returns: Modified ticker string with session and backadjustment.off applied
isTriadMode(pairing)
Checks if a pairing represents a valid triad (3 assets)
Parameters:
pairing (AssetPairing) : The AssetPairing to check
Returns: True if tertiary is non-empty (triad mode), false for dyad
getAssetTicker(tickerId)
Extracts clean ticker string from full ticker ID
Parameters:
tickerId (string) : The full ticker ID (e.g., "BITGET:BTCUSDT.P")
Returns: Clean ticker string (e.g., "BTCUSDT.P")
resolveTriad(chartTickerId, pairing)
Resolves triad asset assignments with proper inversion flags
Parameters:
chartTickerId (string) : The current chart's ticker ID (syminfo.tickerid)
pairing (AssetPairing) : The detected AssetPairing
Returns: Tuple
resolveDyad(chartTickerId, pairing)
Resolves dyad asset assignment with proper inversion flag
Parameters:
chartTickerId (string) : The current chart's ticker ID
pairing (AssetPairing) : The detected AssetPairing (dyad: tertiary is empty)
Returns: Tuple
resolveAssets(ticker, tickerId, assetType, sessionType, useBackadjust)
Main auto-detection entry point. Detects asset category and returns fully resolved config.
Parameters:
ticker (string) : The ticker string to check (typically syminfo.ticker)
tickerId (string) : The full ticker ID (typically syminfo.tickerid)
assetType (string) : The asset type (typically syminfo.type)
sessionType (string) : The session type for futures (typically syminfo.session)
useBackadjust (bool) : Whether to apply back adjustment for futures session alignment
Returns: AssetConfig with fully resolved assets, inversion flags, and detection status
resolveCurrentChart()
Simplified auto-detection using current chart's syminfo values
Returns: AssetConfig with fully resolved assets, inversion flags, and detection status
AssetPairing
Core asset pairing structure for triad/dyad configurations
Fields:
primary (series string) : The primary (chart) asset ticker ID
secondary (series string) : The secondary correlated asset ticker ID
tertiary (series string) : The tertiary correlated asset ticker ID (empty for dyad)
invertSecondary (series bool) : Whether secondary asset should be inverted for divergence calc
invertTertiary (series bool) : Whether tertiary asset should be inverted for divergence calc
AssetConfig
Full asset resolution result with mode detection and computed values
Fields:
detected (series bool) : Whether auto-detection succeeded
isTriadMode (series bool) : True if triad (3 assets), false if dyad (2 assets)
primary (series string) : The resolved primary asset ticker ID
secondary (series string) : The resolved secondary asset ticker ID
tertiary (series string) : The resolved tertiary asset ticker ID (empty for dyad)
invertSecondary (series bool) : Computed inversion flag for secondary asset
invertTertiary (series bool) : Computed inversion flag for tertiary asset
assetCategory (series string) : String describing the detected asset category
InfinityCandlePatternsLibrary "InfinityCandlePatterns"
isMorningStar(o, c, atr)
Parameters:
o (float)
c (float)
atr (float)
isEveningStar(o, c, atr)
Parameters:
o (float)
c (float)
atr (float)
isThreeWhiteSoldiers(o, h, c, atr)
Parameters:
o (float)
h (float)
c (float)
atr (float)
isThreeBlackCrows(o, l, c, atr)
Parameters:
o (float)
l (float)
c (float)
atr (float)
isBullishHarami(o, c, atr)
Parameters:
o (float)
c (float)
atr (float)
isBearishHarami(o, c, atr)
Parameters:
o (float)
c (float)
atr (float)
isBullishEngulfing(o, c)
Parameters:
o (float)
c (float)
isBearishEngulfing(o, c)
Parameters:
o (float)
c (float)
isThreeInsideUp(o, h, c, atr)
Parameters:
o (float)
h (float)
c (float)
atr (float)
isThreeInsideDown(o, l, c, atr)
Parameters:
o (float)
l (float)
c (float)
atr (float)
isTweezerBottom(o, l, c, atr)
Parameters:
o (float)
l (float)
c (float)
atr (float)
isTweezerTop(o, h, c, atr)
Parameters:
o (float)
h (float)
c (float)
atr (float)
isBullishKicker(o, c)
Parameters:
o (float)
c (float)
isBearishKicker(o, c)
Parameters:
o (float)
c (float)
isBullishBreakaway(o, c, atr)
Parameters:
o (float)
c (float)
atr (float)
isBearishBreakaway(o, c, atr)
Parameters:
o (float)
c (float)
atr (float)
isHammer(o, h, l, c, atr)
Parameters:
o (float)
h (float)
l (float)
c (float)
atr (float)
isShootingStar(o, h, l, c, atr)
Parameters:
o (float)
h (float)
l (float)
c (float)
atr (float)
isStandardDoji(o, c, atr)
Parameters:
o (float)
c (float)
atr (float)
isDragonflyDoji(o, h, l, c, atr)
Parameters:
o (float)
h (float)
l (float)
c (float)
atr (float)
isGravestoneDoji(o, h, l, c, atr)
Parameters:
o (float)
h (float)
l (float)
c (float)
atr (float)
isBullishMarubozu(o, h, l, c, atr)
Parameters:
o (float)
h (float)
l (float)
c (float)
atr (float)
isBearishMarubozu(o, h, l, c, atr)
Parameters:
o (float)
h (float)
l (float)
c (float)
atr (float)
isSpinningTop(o, h, l, c, atr)
Parameters:
o (float)
h (float)
l (float)
c (float)
atr (float)
bullAny(o, h, l, c, atr)
Parameters:
o (float)
h (float)
l (float)
c (float)
atr (float)
bearAny(o, h, l, c, atr)
Parameters:
o (float)
h (float)
l (float)
c (float)
atr (float)
neutralAny(o, h, l, c, atr)
Parameters:
o (float)
h (float)
l (float)
c (float)
atr (float)
bullStrong(o, h, c, atr)
Parameters:
o (float)
h (float)
c (float)
atr (float)
bearStrong(o, l, c, atr)
Parameters:
o (float)
l (float)
c (float)
atr (float)
T5_TradeEngineLibrary "T5_TradeEngine"
tick(close_, high_, low_, ema21, ema50, ema200, atrPct, emaGapPct, btcEma50, btcEma200, btcFilterEffective, isBarClose, crossUp21_50, crossDown21_50, allowEntries, exitOnOppositeCross, feeBps, useSR_TPSL, srLeft, srRight, srLookbackPivots, srBufferPct, srMinDistPct, srMinNetAfterFeesPct, srFallbackToATR, tp1CapPct, slCapPct, useTP2Trail, trailExitOnCloseOnly, tp2CapPct, trailCapPct, holdBars)
Parameters:
close_ (float)
high_ (float)
low_ (float)
ema21 (float)
ema50 (float)
ema200 (float)
atrPct (float)
emaGapPct (float)
btcEma50 (float)
btcEma200 (float)
btcFilterEffective (bool)
isBarClose (bool)
crossUp21_50 (bool)
crossDown21_50 (bool)
allowEntries (bool)
exitOnOppositeCross (bool)
feeBps (float)
useSR_TPSL (bool)
srLeft (int)
srRight (int)
srLookbackPivots (int)
srBufferPct (float)
srMinDistPct (float)
srMinNetAfterFeesPct (float)
srFallbackToATR (bool)
tp1CapPct (float)
slCapPct (float)
useTP2Trail (bool)
trailExitOnCloseOnly (bool)
tp2CapPct (float)
trailCapPct (float)
holdBars (int)
T5_EngineLibrary "T5_Engine"
run(ema50, ema200, atrPct, emaGapPct, btcEma50, btcEma200, isBarClose, crossUp21_50, crossDown21_50, useBTCFilter, useSpreadFilter, minSpreadPctFixed, useAdaptiveSpread, spreadBaseMinPct, spreadAtrK, atrLowTh, atrHighTh)
Parameters:
ema50 (float)
ema200 (float)
atrPct (float)
emaGapPct (float)
btcEma50 (float)
btcEma200 (float)
isBarClose (bool)
crossUp21_50 (bool)
crossDown21_50 (bool)
useBTCFilter (bool)
useSpreadFilter (bool)
minSpreadPctFixed (float)
useAdaptiveSpread (bool)
spreadBaseMinPct (float)
spreadAtrK (float)
atrLowTh (float)
atrHighTh (float)
HTFStructCore_v2Library "HTFStructCore_v2"
f_structure_from_pivots(phSeries, plSeries)
Parameters:
phSeries (float)
plSeries (float)
f_adx_from_series(plusDMSeries, minusDMSeries, trSeries, adxLen)
Parameters:
plusDMSeries (float)
minusDMSeries (float)
trSeries (float)
adxLen (simple int)
f_retest_triggers(trendRaw, lastHigh, lastLow, retestTol, enableRetest)
Parameters:
trendRaw (int)
lastHigh (float)
lastLow (float)
retestTol (float)
enableRetest (bool)
f_sweep_triggers(trendRaw, sweepLookback, enableSweep)
Parameters:
trendRaw (int)
sweepLookback (int)
enableSweep (bool)
f_risk(lastLow, lastHigh, atrLen, atrStopMult, atrTpMult, preferTightStop)
Parameters:
lastLow (float)
lastHigh (float)
atrLen (simple int)
atrStopMult (float)
atrTpMult (float)
preferTightStop (bool)
News2024H1Library "News2024H1" - This contains news events from 2024 H1 News Events
f_loadNewsRows()
f_loadExcSevByTypeId()
f_loadExcTagByTypeId()
NewsTypesLibrary "NewsTypes" Provides the based library for the news system
f_hhmmToMs(_hhmm)
Parameters:
_hhmm (int)
f_addNews(_d, _hhmm, _tid, _dArr, _tArr, _idArr)
Parameters:
_d (string)
_hhmm (int)
_tid (int)
_dArr (array)
_tArr (array)
_idArr (array)
f_addNewsMs(_d, _ms, _tid, _dArr, _tArr, _idArr)
Parameters:
_d (string)
_ms (int)
_tid (int)
_dArr (array)
_tArr (array)
_idArr (array)
f_loadTypeSevByTypeId()
key_level_alerts_libLibrary "key_level_alerts_lib"
shouldFireAlertAbove(level, acceptableRange, filterEnabled)
Detects if price crossed above and closed above a level on this bar
Parameters:
level (float) : The price level to check for cross
acceptableRange (float) : The maximum distance from level for close to be considered valid (used when filterEnabled=true)
filterEnabled (bool) : When true, checks that close is within acceptable range above level
Returns: true if price crossed and closed above the level (optionally within acceptable range)
Detection logic:
Condition A: Opened below level AND closed above level (direct cross up)
Condition B: Opened above level, low touched/dipped to level (low <= level), closed above level
shouldFireAlertBelow(level, acceptableRange, filterEnabled)
Detects if price crossed below and closed below a level on this bar
Parameters:
level (float) : The price level to check for cross
acceptableRange (float) : The maximum distance from level for close to be considered valid (used when filterEnabled=true)
filterEnabled (bool) : When true, checks that close is within acceptable range below level
Returns: true if price crossed and closed below the level (optionally within acceptable range)
Detection logic:
Condition A: Opened above level AND closed below level (direct cross down)
Condition B: Opened below level, high touched/spiked to level (high >= level), closed below level
processAlertAbove(level, acceptableRange, currentState, alertEnabled, filterEnabled)
Process "crossed above" alert for a level - fires alert if transitioning from below/unknown to above
Parameters:
level (float) : The price level to check
acceptableRange (float) : The acceptable range threshold for filtering
currentState (int) : Current alert state (-1=below, 0=unknown, 1=above)
alertEnabled (bool) : Whether the alert is enabled
filterEnabled (bool) : Whether to apply acceptable range filtering
Returns: tuple where newState is updated alert state and shouldFire indicates if alert should trigger
State behavior:
- Alert fires when: state was -1 or 0 AND cross above detected AND alert enabled
- State updates to 1 (above) on any cross above
- State updates to -1 (below) on any cross below (resets for next above alert)
processAlertBelow(level, acceptableRange, currentState, alertEnabled, filterEnabled)
Process "crossed below" alert for a level - fires alert if transitioning from above/unknown to below
Parameters:
level (float) : The price level to check
acceptableRange (float) : The acceptable range threshold for filtering
currentState (int) : Current alert state (-1=below, 0=unknown, 1=above)
alertEnabled (bool) : Whether the alert is enabled
filterEnabled (bool) : Whether to apply acceptable range filtering
Returns: tuple where newState is updated alert state and shouldFire indicates if alert should trigger
State behavior:
- Alert fires when: state was 1 or 0 AND cross below detected AND alert enabled
- State updates to -1 (below) on any cross below
- State updates to 1 (above) on any cross above (resets for next below alert)
calculateAcceptableRange(atrValue, acceptableRangePct)
Calculates the acceptable range threshold for alert filtering based on ATR
Parameters:
atrValue (float) : The daily ATR value
acceptableRangePct (float) : The acceptable range percentage (e.g., 85 for 85%)
Returns: The acceptable range threshold in price units
Calculation: oneFullLevel = ATR × 0.24 (24% of daily ATR = one standard key level spacing)
acceptableRange = (acceptableRangePct / 100) × oneFullLevel
getAlertLabelTextSize(sizeStr)
Converts a size string to Pine Script size constant for labels
Parameters:
sizeStr (string) : The size string ("tiny", "small", "normal", "large", "huge")
Returns: The corresponding Pine Script size constant
MK_FractalLibrary "MK_Fractal"
ResCal(price, degree)
Parameters:
price (float)
degree (float)
SupCal(price, degree)
Parameters:
price (float)
degree (float)
CalcAllLevels(price)
Parameters:
price (float)
FindNearestLevel(current_price, resistances, supports)
Parameters:
current_price (float)
resistances (array)
supports (array)
IsTouchSupport(current_price, supports, tolerance_pct)
Parameters:
current_price (float)
supports (array)
tolerance_pct (float)
IsTouchResistance(current_price, resistances, tolerance_pct)
Parameters:
current_price (float)
resistances (array)
tolerance_pct (float)
GetLevelByDegree(price, degree)
Parameters:
price (float)
degree (float)
GetFormattedLevels(price)
Parameters:
price (float)
OrderlyWebhookJSONLibrary "OrderlyWebhookJSON"
Orderly 거래소 자동 거래를 위한 JSON Webhook 메시지 생성 라이브러리. Market/Limit 주문, TP/SL 설정, Percent/Absolute 수량 지정 등을 지원합니다.
createMarketOrder(symbol, leverage, side, position, quantity_type, quantity, tp_type, tp_value, sl_type, sl_value)
Market 주문 JSON 생성 (TP/SL 포함)
Parameters:
symbol (string) : 거래 심볼 (예: "BTCUSDT")
leverage (float) : 레버리지 배율 (예: 10)
side (string) : "Long" 또는 "Short"
position (string) : "Open" 또는 "Close"
quantity_type (string) : "Percent" 또는 "Absolute"
quantity (float) : 수량 값 (Percent인 경우 0-100, Absolute인 경우 실제 수량)
tp_type (string) : "percent" 또는 "price"
tp_value (float) : TP 값 (percent인 경우 퍼센트, price인 경우 절대가격)
sl_type (string) : "percent" 또는 "price"
sl_value (float) : SL 값 (percent인 경우 퍼센트, price인 경우 절대가격)
Returns: JSON 형식 문자열
createLimitOrder(symbol, leverage, side, position, limit_price, quantity_type, quantity, tp_type, tp_value, sl_type, sl_value)
Limit 주문 JSON 생성 (TP/SL 포함)
Parameters:
symbol (string) : 거래 심볼 (예: "BTCUSDT")
leverage (float) : 레버리지 배율 (예: 10)
side (string) : "Long" 또는 "Short"
position (string) : "Open" 또는 "Close"
limit_price (float) : Limit 주문 가격
quantity_type (string) : "Percent" 또는 "Absolute"
quantity (float) : 수량 값 (Percent인 경우 0-100, Absolute인 경우 실제 수량)
tp_type (string) : "percent" 또는 "price"
tp_value (float) : TP 값 (percent인 경우 퍼센트, price인 경우 절대가격)
sl_type (string) : "percent" 또는 "price"
sl_value (float) : SL 값 (percent인 경우 퍼센트, price인 경우 절대가격)
Returns: JSON 형식 문자열
createSimpleMarketOrder(symbol, leverage, side, position, quantity_type, quantity)
Market 주문 JSON 생성 (TP/SL 없음 - 간단 버전)
Parameters:
symbol (string) : 거래 심볼 (예: "BTCUSDT")
leverage (float) : 레버리지 배율 (예: 10)
side (string) : "Long" 또는 "Short"
position (string) : "Open" 또는 "Close"
quantity_type (string) : "Percent" 또는 "Absolute"
quantity (float) : 수량 값
Returns: JSON 형식 문자열
createSimpleLimitOrder(symbol, leverage, side, position, limit_price, quantity_type, quantity)
Limit 주문 JSON 생성 (TP/SL 없음 - 간단 버전)
Parameters:
symbol (string) : 거래 심볼 (예: "BTCUSDT")
leverage (float) : 레버리지 배율 (예: 10)
side (string) : "Long" 또는 "Short"
position (string) : "Open" 또는 "Close"
limit_price (float) : Limit 주문 가격
quantity_type (string) : "Percent" 또는 "Absolute"
quantity (float) : 수량 값
Returns: JSON 형식 문자열
createClosePosition(symbol, side, quantity_type, quantity)
포지션 종료 전용 JSON 생성
Parameters:
symbol (string) : 거래 심볼 (예: "BTCUSDT")
side (string) : "Long" 또는 "Short" (종료할 포지션의 반대 방향)
quantity_type (string) : "Percent" 또는 "Absolute"
quantity (float) : 수량 값 (Percent 100 = 전체 종료)
Returns: JSON 형식 문자열
TradingSystems_AlphaLib_v1_FinalLibrary "TradingSystems_AlphaLib_v1_Final"
Master Library for Institutional Analysis v1
@author jmcanovelles
calc_ema(len)
Calculates standardized EMA
Parameters:
len (simple int)
calc_adx(len)
Calculates precise ADX and DI
Parameters:
len (simple int)
TradingSystems_AlphaLib_v6//@version=6
// @description Master Library for Institutional Grade Analysis v1
// @author jmcanovelles
library("TradingSystems_AlphaLib_v6")
// @function Calculates standardized EMA
// @param len Period for the average
export calc_ema(int len) =>
ta.ema(close, len)
// @function Calculates precise ADX and DI
// @param len Calculation period
export calc_adx(int len) =>
= ta.dmi(len, len)
OKXJsonLibrary "OKXJson"
f_buildId(prefix, instrument)
Parameters:
prefix (string)
instrument (string)
f_utcTimestamp()
f_investmentType(internalAction, entryType, closeType)
Parameters:
internalAction (string)
entryType (string)
closeType (string)
f_build(id, okxAction, marketPosition, prevMarketPosition, instrument, signalToken, timestampUtc, investmentType, amount, maxLagSeconds)
Parameters:
id (string)
okxAction (string)
marketPosition (string)
prevMarketPosition (string)
instrument (string)
signalToken (string)
timestampUtc (string)
investmentType (string)
amount (string)
maxLagSeconds (string)
3 EMA with Alerts 2025This indicator plots three key EMAs (20, 50, and 200) directly on the chart, making it easy to track short-, medium-, and long-term trends. A color-coded table is displayed in the top-right corner for quick reference.
The script also includes smart alerts that trigger only when the state changes:
• 🔵 EMA 20 crossing above EMA 50 & EMA 200 → Bullish signal
• 🔴 EMA 20 crossing below EMA 50 & EMA 200 → Bearish signal
This tool is designed for traders who want clean visuals, reliable alerts, and simplified trend recognition in 2025 markets.
tgpFibonacciLib_v2Library "tgpFibonacciLib_v2"
getFib(tf, ratio)
Parameters:
tf (string)
ratio (float)
getGoldenPocket(tf)
Parameters:
tf (string)
getMonthlyFib(ratio)
Parameters:
ratio (float)
getWeeklyFib(ratio)
Parameters:
ratio (float)
getYestFib(ratio)
Parameters:
ratio (float)
AdjCloseLibLibrary "AdjCloseLib"
Library for producing gap-adjusted price series that removes intraday gaps at market open
get_adj_close(_gapThresholdPct)
Calculates gap-adjusted close price by detecting and removing gaps at market open (09:15)
Parameters:
_gapThresholdPct (float) : Minimum gap size (in percentage) required to trigger adjustment. Example: 0.5 for 0.5%
Returns: Adjusted close price for the current bar (always returns a numeric value, never na)
@details Detects gaps by comparing 09:15 open with previous day's close. If gap exceeds threshold,
subtracts the gap value from all bars between 09:15-15:29 inclusive. State resets after session close.
get_adj_ohlc(_gapThresholdPct)
Calculates gap-adjusted OHLC values by subtracting detected gap from all price components
Parameters:
_gapThresholdPct (float) : Minimum gap size (in percentage) required to trigger adjustment. Example: 0.5 for 0.5%
Returns: Tuple of
@details Useful for calculating indicators (ATR, Heikin-Ashi, etc.) on gap-adjusted data.
Applies the same gap adjustment logic to all OHLC components simultaneously.
AI Bot Regime Feed (v6) — stableThis indicator generates real-time, structured JSON alerts for external trading bots or automation systems.
It combines multiple technical layers to identify market regimes and high-probability buy/sell events, and sends them to any webhook endpoint (e.g., a FastAPI or Zapier listener).
phx_liq_tlLibrary "phx_liq_tl"
new_state()
update(st, len, cup, cdn, space, proximity_pct, shs)
Parameters:
st (LTState)
len (int)
cup (color)
cdn (color)
space (float)
proximity_pct (float)
shs (bool)
LTState
Fields:
upln (array)
dnln (array)
upBroken (series bool)
dnBroken (series bool)
phx_kroLibrary "phx_kro"
compute(src, bandwidth, bbwidth, sdLook, sdMult, obos_mult)
Parameters:
src (float)
bandwidth (int)
bbwidth (float)
sdLook (int)
sdMult (float)
obos_mult (float)
start_flags(src, bandwidth, bbwidth)
Parameters:
src (float)
bandwidth (int)
bbwidth (float)
KROFeed
Fields:
Wave (series float)
is_green (series bool)
is_red (series bool)
band_width (series float)
band_width_sma (series float)
band_width_std (series float)
is_hyper_wide (series bool)
wave_sma (series float)
wave_std (series float)
wave_ob_threshold (series float)
wave_os_threshold (series float)
is_overbought (series bool)
is_oversold (series bool)
is_oversold_confirmed (series bool)
is_overbought_confirmed (series bool)
enhanced_os_confirmed (series bool)
enhanced_ob_confirmed (series bool)
triple_green_transition (series bool)
triple_red_transition (series bool)
startwave_bull (series bool)
startwave_bear (series bool)






















