PINE LIBRARY
Cập nhật MLLib

Library "MLLib"
Machine Learning Library - Adaptive learning algorithms for parameter optimization
f_kirschenbaum_sgd(feature_z, baseline_ma, baseline_dev, pivot_high, pivot_low, sensitivity_current, learning_rate, sensitivity_min, sensitivity_max, coupling_strength, coupling_gate, pivot_lookback, proximity_pct, survival_prob)
Pivot-based SGD for adaptive sensitivity tuning (Kirschenbaum method)
Parameters:
feature_z (float): Z-score of the predictive feature (e.g., basket vector)
baseline_ma (float): Baseline moving average (center line)
baseline_dev (float): Standard deviation for band calculation
pivot_high (float): Recent pivot high price (na if none)
pivot_low (float): Recent pivot low price (na if none)
sensitivity_current (float): Current sensitivity parameter value
learning_rate (float): Learning rate for SGD updates
sensitivity_min (float): Minimum allowed sensitivity value
sensitivity_max (float): Maximum allowed sensitivity value
coupling_strength (float): Coupling strength for gating updates (0-1)
coupling_gate (float): Minimum coupling threshold for updates
pivot_lookback (int): Lookback period to historical feature/price at pivot
proximity_pct (float): Proximity threshold (0-1) for pivot to be "near band"
survival_prob (float): Survival probability for band calculation (e.g., 0.68 for 1-sigma)
Returns: [new_sensitivity, update_count] Updated sensitivity and number of updates performed
f_sgd_update(param_current, gradient, learning_rate, param_min, param_max, gate_strength, gate_threshold)
Generic SGD parameter update with optional gating
Parameters:
param_current (float): Current parameter value
gradient (float): Gradient (error * feature)
learning_rate (float): Learning rate
param_min (float): Minimum parameter value
param_max (float): Maximum parameter value
gate_strength (float): Gating strength (0-1, optional)
gate_threshold (float): Minimum gate strength to allow full update
Returns: float Updated parameter value
SGDState
SGD learning state for tracking parameter updates
Fields:
param (series float): Current parameter value
updates (series int): Number of updates performed
last_error (series float): Last prediction error
Machine Learning Library - Adaptive learning algorithms for parameter optimization
f_kirschenbaum_sgd(feature_z, baseline_ma, baseline_dev, pivot_high, pivot_low, sensitivity_current, learning_rate, sensitivity_min, sensitivity_max, coupling_strength, coupling_gate, pivot_lookback, proximity_pct, survival_prob)
Pivot-based SGD for adaptive sensitivity tuning (Kirschenbaum method)
Parameters:
feature_z (float): Z-score of the predictive feature (e.g., basket vector)
baseline_ma (float): Baseline moving average (center line)
baseline_dev (float): Standard deviation for band calculation
pivot_high (float): Recent pivot high price (na if none)
pivot_low (float): Recent pivot low price (na if none)
sensitivity_current (float): Current sensitivity parameter value
learning_rate (float): Learning rate for SGD updates
sensitivity_min (float): Minimum allowed sensitivity value
sensitivity_max (float): Maximum allowed sensitivity value
coupling_strength (float): Coupling strength for gating updates (0-1)
coupling_gate (float): Minimum coupling threshold for updates
pivot_lookback (int): Lookback period to historical feature/price at pivot
proximity_pct (float): Proximity threshold (0-1) for pivot to be "near band"
survival_prob (float): Survival probability for band calculation (e.g., 0.68 for 1-sigma)
Returns: [new_sensitivity, update_count] Updated sensitivity and number of updates performed
f_sgd_update(param_current, gradient, learning_rate, param_min, param_max, gate_strength, gate_threshold)
Generic SGD parameter update with optional gating
Parameters:
param_current (float): Current parameter value
gradient (float): Gradient (error * feature)
learning_rate (float): Learning rate
param_min (float): Minimum parameter value
param_max (float): Maximum parameter value
gate_strength (float): Gating strength (0-1, optional)
gate_threshold (float): Minimum gate strength to allow full update
Returns: float Updated parameter value
SGDState
SGD learning state for tracking parameter updates
Fields:
param (series float): Current parameter value
updates (series int): Number of updates performed
last_error (series float): Last prediction error
Phát hành các Ghi chú
v2Added:
foutcomelabelstep(bars_elapsed, close_at_signal, atr_at_signal, amp_thresh, k_min, k_max, close_now)
Parameters:
bars_elapsed (int)
close_at_signal (float)
atr_at_signal (float)
amp_thresh (float)
k_min (int)
k_max (int)
close_now (float)
ftrainingbuffernew()
ftrainingbufferpush(tb, v1, v2, v3, v4, v5, v6, v7, pk, amp, hor, bar_i, dir)
Parameters:
tb (TrainingBuffer)
v1 (float)
v2 (float)
v3 (float)
v4 (float)
v5 (float)
v6 (float)
v7 (float)
pk (int)
amp (float)
hor (int)
bar_i (int)
dir (int)
ftrainingbuffercap(tb, max_size)
Parameters:
tb (TrainingBuffer)
max_size (int)
fpendingqueuenew()
fpendingqueuepush(pq, b, c, a, dir, f1, f2, f3, f4, f5, f6, f7, pk)
Parameters:
pq (PendingQueue)
b (int)
c (float)
a (float)
dir (int)
f1 (float)
f2 (float)
f3 (float)
f4 (float)
f5 (float)
f6 (float)
f7 (float)
pk (int)
fpendingqueuepopfront(pq)
Parameters:
pq (PendingQueue)
OutcomeLabel
Fields:
amplitude (series float)
horizon (series int)
ready (series bool)
TrainingBuffer
Fields:
f1 (array<float>)
f2 (array<float>)
f3 (array<float>)
f4 (array<float>)
f5 (array<float>)
f6 (array<float>)
f7 (array<float>)
packed (array<int>)
amplitude (array<float>)
horizon (array<int>)
bar_idx (array<int>)
direction (array<int>)
PendingQueue
Fields:
bar_idx (array<int>)
close_at (array<float>)
atr_at (array<float>)
direction (array<int>)
snap_f1 (array<float>)
snap_f2 (array<float>)
snap_f3 (array<float>)
snap_f4 (array<float>)
snap_f5 (array<float>)
snap_f6 (array<float>)
snap_f7 (array<float>)
snap_packed (array<int>)
Phát hành các Ghi chú
v3Added:
fpendingqueuepushtyped(pq, bar_idx, c0, atr0, dir_, f1, f2, f3, f4, f5, f6, f7, packed, stype)
Parameters:
pq (PendingQueue)
bar_idx (int)
c0 (float)
atr0 (float)
dir_ (int)
f1 (float)
f2 (float)
f3 (float)
f4 (float)
f5 (float)
f6 (float)
f7 (float)
packed (int)
stype (int)
ftrainingbufferpushtyped(tb, f1, f2, f3, f4, f5, f6, f7, packed, amp, hor, bar_idx, dir_, stype)
Parameters:
tb (TrainingBuffer)
f1 (float)
f2 (float)
f3 (float)
f4 (float)
f5 (float)
f6 (float)
f7 (float)
packed (int)
amp (float)
hor (int)
bar_idx (int)
dir_ (int)
stype (int)
Phát hành các Ghi chú
v4Added:
ftrainingbuffernew_atomic()
ftrainingbufferpush_atomic(tb, v1, v2, v3, v4, v5, v6, v7, pk, amp, hor, bar_i, dir, stype, f8)
Parameters:
tb (array<TBSample>)
v1 (float)
v2 (float)
v3 (float)
v4 (float)
v5 (float)
v6 (float)
v7 (float)
pk (int)
amp (float)
hor (int)
bar_i (int)
dir (int)
stype (int)
f8 (float)
ftrainingbuffercap_atomic(tb, max_size)
Parameters:
tb (array<TBSample>)
max_size (int)
fpendingqueuenew_atomic()
fpendingqueuepush_atomic(pq, b, c, a, dir, f1, f2, f3, f4, f5, f6, f7, pk, stype, f8)
Parameters:
pq (array<PQSample>)
b (int)
c (float)
a (float)
dir (int)
f1 (float)
f2 (float)
f3 (float)
f4 (float)
f5 (float)
f6 (float)
f7 (float)
pk (int)
stype (int)
f8 (float)
fpendingqueuepopfront_atomic(pq)
Parameters:
pq (array<PQSample>)
TBSample
Fields:
f1 (series float)
f2 (series float)
f3 (series float)
f4 (series float)
f5 (series float)
f6 (series float)
f7 (series float)
packed (series int)
amplitude (series float)
horizon (series int)
bar_idx (series int)
direction (series int)
sample_type (series int)
f8_val (series float)
PQSample
Fields:
bar_idx (series int)
close_at (series float)
atr_at (series float)
direction (series int)
snap_f1 (series float)
snap_f2 (series float)
snap_f3 (series float)
snap_f4 (series float)
snap_f5 (series float)
snap_f6 (series float)
snap_f7 (series float)
snap_packed (series int)
sample_type (series int)
f8_val (series float)
Phát hành các Ghi chú
v5Phát hành các Ghi chú
v6Updated:
ftrainingbuffercap_atomic(tb)
Parameters:
tb (array<TBSample>)
Thư viện Pine
Theo đúng tinh thần TradingView, tác giả đã công bố mã Pine này như một thư viện mã nguồn mở để các lập trình viên Pine khác trong cộng đồng có thể tái sử dụng. Chúc mừng tác giả! Bạn có thể sử dụng thư viện này cho mục đích cá nhân hoặc trong các ấn phẩm mã nguồn mở khác, nhưng việc tái sử dụng mã này trong các ấn phẩm phải tuân theo Nội Quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Thư viện Pine
Theo đúng tinh thần TradingView, tác giả đã công bố mã Pine này như một thư viện mã nguồn mở để các lập trình viên Pine khác trong cộng đồng có thể tái sử dụng. Chúc mừng tác giả! Bạn có thể sử dụng thư viện này cho mục đích cá nhân hoặc trong các ấn phẩm mã nguồn mở khác, nhưng việc tái sử dụng mã này trong các ấn phẩm phải tuân theo Nội Quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.