PINE LIBRARY
IC optimiser lib

Library "IC optimiser lib"
Library for IC-based parameter optimization
findOptimalParam(testParams, icValues, currentParam, smoothing)
Find optimal parameter from array of IC values
Parameters:
testParams (array<float>): Array of parameter values being tested
icValues (array<float>): Array of IC values for each parameter (same size as testParams)
currentParam (float): Current parameter value (for smoothing)
smoothing (simple float): Smoothing factor (0-1, e.g., 0.2 means 20% new, 80% old)
Returns: [optimizedParam, bestIC, bestIndex] New parameter value, its IC, and array index
adaptiveParamWithStarvation(opt, testParams, icValues, smoothing, starvationThreshold, starvationJumpSize)
Adaptive parameter selection with starvation handling
Parameters:
opt (ICOptimizer): ICOptimizer object
testParams (array<float>): Array of parameter values
icValues (array<float>): Array of IC values for each parameter
smoothing (simple float): Normal smoothing factor
starvationThreshold (simple int): Number of updates before triggering starvation mode
starvationJumpSize (simple float): Jump size when in starvation (as fraction of range)
Returns: [newParam, bestIC] Updated parameter and IC
detectAndAdjustDomination(longCount, shortCount, currentLongLevel, currentShortLevel, dominationRatio, jumpSize, minLevel, maxLevel)
Detect signal imbalance and adjust parameters
Parameters:
longCount (int): Number of long signals in period
shortCount (int): Number of short signals in period
currentLongLevel (float): Current long threshold
currentShortLevel (float): Current short threshold
dominationRatio (simple int): Ratio threshold (e.g., 4 = 4:1 imbalance)
jumpSize (simple float): Size of adjustment
minLevel (simple float): Minimum allowed level
maxLevel (simple float): Maximum allowed level
Returns: [newLongLevel, newShortLevel, isDominated]
calcIC(signals, returns, lookback)
Parameters:
signals (float)
returns (float)
lookback (simple int)
classifyIC(currentIC, icWindow, goodPercentile, badPercentile)
Parameters:
currentIC (float)
icWindow (simple int)
goodPercentile (simple int)
badPercentile (simple int)
evaluateSignal(signal, forwardReturn)
Parameters:
signal (float)
forwardReturn (float)
updateOptimizerState(opt, signal, forwardReturn, currentIC, metaICPeriod)
Parameters:
opt (ICOptimizer)
signal (float)
forwardReturn (float)
currentIC (float)
metaICPeriod (simple int)
calcSuccessRate(successful, total)
Parameters:
successful (int)
total (int)
createICStatsTable(opt, paramName, normalSuccess, normalTotal)
Parameters:
opt (ICOptimizer)
paramName (string)
normalSuccess (int)
normalTotal (int)
initOptimizer(initialParam)
Parameters:
initialParam (float)
ICOptimizer
Fields:
currentParam (series float)
currentIC (series float)
metaIC (series float)
totalSignals (series int)
successfulSignals (series int)
goodICSignals (series int)
goodICSuccess (series int)
nonBadICSignals (series int)
nonBadICSuccess (series int)
goodICThreshold (series float)
badICThreshold (series float)
updateCounter (series int)
Library for IC-based parameter optimization
findOptimalParam(testParams, icValues, currentParam, smoothing)
Find optimal parameter from array of IC values
Parameters:
testParams (array<float>): Array of parameter values being tested
icValues (array<float>): Array of IC values for each parameter (same size as testParams)
currentParam (float): Current parameter value (for smoothing)
smoothing (simple float): Smoothing factor (0-1, e.g., 0.2 means 20% new, 80% old)
Returns: [optimizedParam, bestIC, bestIndex] New parameter value, its IC, and array index
adaptiveParamWithStarvation(opt, testParams, icValues, smoothing, starvationThreshold, starvationJumpSize)
Adaptive parameter selection with starvation handling
Parameters:
opt (ICOptimizer): ICOptimizer object
testParams (array<float>): Array of parameter values
icValues (array<float>): Array of IC values for each parameter
smoothing (simple float): Normal smoothing factor
starvationThreshold (simple int): Number of updates before triggering starvation mode
starvationJumpSize (simple float): Jump size when in starvation (as fraction of range)
Returns: [newParam, bestIC] Updated parameter and IC
detectAndAdjustDomination(longCount, shortCount, currentLongLevel, currentShortLevel, dominationRatio, jumpSize, minLevel, maxLevel)
Detect signal imbalance and adjust parameters
Parameters:
longCount (int): Number of long signals in period
shortCount (int): Number of short signals in period
currentLongLevel (float): Current long threshold
currentShortLevel (float): Current short threshold
dominationRatio (simple int): Ratio threshold (e.g., 4 = 4:1 imbalance)
jumpSize (simple float): Size of adjustment
minLevel (simple float): Minimum allowed level
maxLevel (simple float): Maximum allowed level
Returns: [newLongLevel, newShortLevel, isDominated]
calcIC(signals, returns, lookback)
Parameters:
signals (float)
returns (float)
lookback (simple int)
classifyIC(currentIC, icWindow, goodPercentile, badPercentile)
Parameters:
currentIC (float)
icWindow (simple int)
goodPercentile (simple int)
badPercentile (simple int)
evaluateSignal(signal, forwardReturn)
Parameters:
signal (float)
forwardReturn (float)
updateOptimizerState(opt, signal, forwardReturn, currentIC, metaICPeriod)
Parameters:
opt (ICOptimizer)
signal (float)
forwardReturn (float)
currentIC (float)
metaICPeriod (simple int)
calcSuccessRate(successful, total)
Parameters:
successful (int)
total (int)
createICStatsTable(opt, paramName, normalSuccess, normalTotal)
Parameters:
opt (ICOptimizer)
paramName (string)
normalSuccess (int)
normalTotal (int)
initOptimizer(initialParam)
Parameters:
initialParam (float)
ICOptimizer
Fields:
currentParam (series float)
currentIC (series float)
metaIC (series float)
totalSignals (series int)
successfulSignals (series int)
goodICSignals (series int)
goodICSuccess (series int)
nonBadICSignals (series int)
nonBadICSuccess (series int)
goodICThreshold (series float)
badICThreshold (series float)
updateCounter (series int)
Pine脚本库
本着真正的TradingView精神,作者将此Pine代码发布为开源库,以便我们社区的其他Pine程序员可以重复使用它。向作者致敬!您可以私密或在其他开源出版物中使用此库,但在出版物中重复使用此代码受网站规则约束。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。
Pine脚本库
本着真正的TradingView精神,作者将此Pine代码发布为开源库,以便我们社区的其他Pine程序员可以重复使用它。向作者致敬!您可以私密或在其他开源出版物中使用此库,但在出版物中重复使用此代码受网站规则约束。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。