PINE LIBRARY
已更新 EKAssetCorrelation

Library "EKAssetCorrelation"
Full asset correlation library for SMT divergence detection. Drop-in replacement for fstarcapital/AssetCorrelationUtils/11.
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
detectMetalsFuturesQuad(ticker)
Detects Metal Futures in Quad Mode (Gold->SI/XAUEUR/XAUGBP, Silver->GC/XAGEUR/XAGGBP)
Parameters:
ticker (string): The ticker string to check
Returns: AssetPairing with futures secondary + GXT cross-pairs as tertiary/quaternary (empty for copper)
detectMetalsFuturesGxt(ticker)
Detects Metal Futures in GXT Mode (Gold->XAUEUR/XAUGBP, Silver->XAGEUR/XAGGBP)
Parameters:
ticker (string): The ticker string to check
Returns: AssetPairing with GXT secondary and tertiary assets (empty for copper)
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 + EUR/GBP cross-pairs)
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
detectMetalsCFDGxt(ticker, tickerId)
Detects Metals CFD in GXT Mode (XAUUSD->XAUEUR/XAUGBP, XAGUSD->XAGEUR/XAGGBP)
Parameters:
ticker (string): The ticker string to check
tickerId (string): The full ticker ID for primary asset
Returns: AssetPairing with GXT secondary and tertiary assets (empty for copper)
detectMetalsCFDQuad(ticker, tickerId)
Detects Metals CFD in Quad Mode (XAUUSD->XAGUSD/XAUEUR/XAUGBP, etc.)
Parameters:
ticker (string): The ticker string to check
tickerId (string): The full ticker ID for primary asset
Returns: AssetPairing with quad assets (empty for copper)
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 [primaryAsset, secondaryAsset, tertiaryAsset, invertSecondary, invertTertiary]
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 [primaryAsset, secondaryAsset, invertSecondary]
resolveQuad(chartTickerId, pairing)
Resolves quad asset assignments with proper inversion flags (4 assets)
Parameters:
chartTickerId (string): The current chart's ticker ID (syminfo.tickerid)
pairing (AssetPairing): The detected AssetPairing with quaternary populated
Returns: Tuple [primaryAsset, secondaryAsset, tertiaryAsset, quaternaryAsset, invertSecondary, invertTertiary, invertQuaternary]
resolveAssets(ticker, tickerId, assetType, sessionType, useBackadjust, gxtMode, quadMode)
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
gxtMode (bool): When true, metals use currency-cross triads instead of standard metal correlations
quadMode (bool): When true, metals use futures secondary + GXT cross-pairs as tertiary/quaternary. Takes priority over gxtMode for metals.
Returns: AssetConfig with fully resolved assets, inversion flags, and detection status
resolveCurrentChart(gxtMode, quadMode)
Simplified auto-detection using current chart's syminfo values
Parameters:
gxtMode (bool): When true, metals use currency-cross triads instead of standard metal correlations
quadMode (bool): When true, metals use futures secondary + GXT cross-pairs as tertiary/quaternary
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)
quaternary (series string): The quaternary correlated asset ticker ID (empty unless quad mode)
invertSecondary (series bool): Whether secondary asset should be inverted for divergence calc
invertTertiary (series bool): Whether tertiary asset should be inverted for divergence calc
invertQuaternary (series bool): Whether quaternary 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)
isQuadMode (series bool): True if quad (4 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)
quaternary (series string): The resolved quaternary asset ticker ID (empty unless quad mode)
invertSecondary (series bool): Computed inversion flag for secondary asset
invertTertiary (series bool): Computed inversion flag for tertiary asset
invertQuaternary (series bool): Computed inversion flag for quaternary asset
assetCategory (series string): String describing the detected asset category
Full asset correlation library for SMT divergence detection. Drop-in replacement for fstarcapital/AssetCorrelationUtils/11.
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
detectMetalsFuturesQuad(ticker)
Detects Metal Futures in Quad Mode (Gold->SI/XAUEUR/XAUGBP, Silver->GC/XAGEUR/XAGGBP)
Parameters:
ticker (string): The ticker string to check
Returns: AssetPairing with futures secondary + GXT cross-pairs as tertiary/quaternary (empty for copper)
detectMetalsFuturesGxt(ticker)
Detects Metal Futures in GXT Mode (Gold->XAUEUR/XAUGBP, Silver->XAGEUR/XAGGBP)
Parameters:
ticker (string): The ticker string to check
Returns: AssetPairing with GXT secondary and tertiary assets (empty for copper)
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 + EUR/GBP cross-pairs)
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
detectMetalsCFDGxt(ticker, tickerId)
Detects Metals CFD in GXT Mode (XAUUSD->XAUEUR/XAUGBP, XAGUSD->XAGEUR/XAGGBP)
Parameters:
ticker (string): The ticker string to check
tickerId (string): The full ticker ID for primary asset
Returns: AssetPairing with GXT secondary and tertiary assets (empty for copper)
detectMetalsCFDQuad(ticker, tickerId)
Detects Metals CFD in Quad Mode (XAUUSD->XAGUSD/XAUEUR/XAUGBP, etc.)
Parameters:
ticker (string): The ticker string to check
tickerId (string): The full ticker ID for primary asset
Returns: AssetPairing with quad assets (empty for copper)
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 [primaryAsset, secondaryAsset, tertiaryAsset, invertSecondary, invertTertiary]
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 [primaryAsset, secondaryAsset, invertSecondary]
resolveQuad(chartTickerId, pairing)
Resolves quad asset assignments with proper inversion flags (4 assets)
Parameters:
chartTickerId (string): The current chart's ticker ID (syminfo.tickerid)
pairing (AssetPairing): The detected AssetPairing with quaternary populated
Returns: Tuple [primaryAsset, secondaryAsset, tertiaryAsset, quaternaryAsset, invertSecondary, invertTertiary, invertQuaternary]
resolveAssets(ticker, tickerId, assetType, sessionType, useBackadjust, gxtMode, quadMode)
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
gxtMode (bool): When true, metals use currency-cross triads instead of standard metal correlations
quadMode (bool): When true, metals use futures secondary + GXT cross-pairs as tertiary/quaternary. Takes priority over gxtMode for metals.
Returns: AssetConfig with fully resolved assets, inversion flags, and detection status
resolveCurrentChart(gxtMode, quadMode)
Simplified auto-detection using current chart's syminfo values
Parameters:
gxtMode (bool): When true, metals use currency-cross triads instead of standard metal correlations
quadMode (bool): When true, metals use futures secondary + GXT cross-pairs as tertiary/quaternary
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)
quaternary (series string): The quaternary correlated asset ticker ID (empty unless quad mode)
invertSecondary (series bool): Whether secondary asset should be inverted for divergence calc
invertTertiary (series bool): Whether tertiary asset should be inverted for divergence calc
invertQuaternary (series bool): Whether quaternary 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)
isQuadMode (series bool): True if quad (4 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)
quaternary (series string): The resolved quaternary asset ticker ID (empty unless quad mode)
invertSecondary (series bool): Computed inversion flag for secondary asset
invertTertiary (series bool): Computed inversion flag for tertiary asset
invertQuaternary (series bool): Computed inversion flag for quaternary asset
assetCategory (series string): String describing the detected asset category
發行說明
v2Pine腳本庫
秉持TradingView一貫精神,作者已將此Pine代碼以開源函式庫形式發佈,方便我們社群中的其他Pine程式設計師重複使用。向作者致敬!您可以在私人專案或其他開源發表中使用此函式庫,但在公開發表中重用此代碼須遵守社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
Pine腳本庫
秉持TradingView一貫精神,作者已將此Pine代碼以開源函式庫形式發佈,方便我們社群中的其他Pine程式設計師重複使用。向作者致敬!您可以在私人專案或其他開源發表中使用此函式庫,但在公開發表中重用此代碼須遵守社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。