๐ฎ TITAN ORACLE โ Complete Technical Documentation
Disclaimer: Educational and research material only โ not financial or investment advice. Trading involves substantial risk of loss; past or simulated results do not indicate future results. Titan HFT is provided AS-IS, with no liability and no support. No API keys are included.
Guide to the 7-Layer Predictive Indicator
TITAN ORACLE is a predictive super-indicator that combines 7 advanced mathematical algorithms into a single score (oracle_score) ranging from -100 to +100. Unlike traditional indicators (EMA, RSI, MACD), which are lagging (they look at the past), TITAN ORACLE is leading โ it forecasts what comes next.
General Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ INPUT DATA โ
โ candles[] โ close, high, low, volume โ
โโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโ
โผ โผ โผ
โโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ
โ LAYER 1โ โ LAYER 2 โ โ LAYER 3 โ
โ Kalman โ โ Entropy โ โ Hurst โ
โ Filter โ โ Flow โ โ Exponent โ
โโโโโฌโโโโโ โโโโโโฌโโโโโโ โโโโโโฌโโโโโโ
โ โ โ
โผ โผ โผ
โโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ
โ LAYER 4โ โ LAYER 5 โ โ LAYER 6 โ โ LAYER 7 โ
โLyapunovโ โ Wavelet โ โ VPIN โ โChangepointโ
โ Chaos โ โ Denoise โ โ Volume โ โ Bayesian โ
โโโโโฌโโโโโ โโโโโโฌโโโโโโ โโโโโโฌโโโโโโ โโโโโโฌโโโโโโ
โ โ โ โ
โโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโ
โผ
โโโโโโโโโโโโโโโโโโ
โ FUSION LAYER โ
โ Adaptive โ
โ Weights โ
โโโโโโโโโฌโโโโโโโโโ
โผ
oracle_score [-100, +100]
confidence [0.0, 1.0]
regime: Trending/MeanReverting/Chaotic
LAYER 1: Kalman Filter (Kalman Adaptive Predictor)
What does it do?
It predicts the future price and the rate of change of the price. The Kalman filter is used in missile guidance, GPS and autopilots โ here we apply it to the market.
Mathematical Model
The system state is a 2D vector:
x = [price, velocity]
State Equation (Prediction):
x_predicted = F ยท x_previous
where the transition matrix F is:
F = | 1 dt | (dt = 1 bar)
| 0 1 |
This says: new_price = old_price + velocity ร dt
Observation Equation (Correction):
z = H ยท x + noise
where H = [1, 0] (we observe only the price, not the velocity).
Kalman update in 5 steps:
- Predict State:
xฬ = F ยท x - Predict Covariance:
Pฬ = F ยท P ยท Fแต + Q - Kalman Gain:
K = Pฬ ยท Hแต ยท (H ยท Pฬ ยท Hแต + R)โปยน - Update State:
x = xฬ + K ยท (z - H ยท xฬ) - Update Covariance:
P = (I - K ยท H) ยท Pฬ
Parameters
| Parameter | Value | Description |
|---|---|---|
Q (process noise) | [[0.01, 0], [0, 0.01]] | How much the market changes "internally" |
R (measurement noise) | 1.0 | Observation noise (raw price) |
Pโ (initial covariance) | [[1, 0], [0, 1]] | Initial uncertainty |
Output
| Field | Type | Description |
|---|---|---|
predicted_price | f64 | Predicted price for the next bar |
predicted_velocity | f64 | Rate of change (positive = rising, negative = falling) |
uncertainty | f64 | Prediction uncertainty (P[0][0]) |
Trading Signal
velocity > 0โ BULLISH (price is accelerating upward)velocity < 0โ BEARISH (price is decelerating / falling)- Raw signal:
kalman_signal = (velocity ร 1000).clamp(-1, +1)
LAYER 2: Shannon Entropy Flow Regime Detector
What does it do?
It detects the market regime: Trending, Mean Reverting or Chaotic. Shannon entropy measures the "disorder" of returns โ orderly (trending) markets have low entropy, chaotic ones have maximum entropy.
Mathematical Formula
1. Return Calculation:
r[i] = (close[i] - close[i-1]) / close[i-1]
2. Bin Distribution:
Returns are sorted into 10 bins (histogram). Shannon entropy:
H = -ฮฃ p(i) ยท logโ(p(i)) for all bins with p(i) > 0
where p(i) = probability of falling in bin i.
3. Normalisation:
H_normalized = H / logโ(num_bins) โ [0, 1]
H โ 0= All returns are identical (perfect trend)H โ 1= Completely random returns (pure noise)
4. Regime Detection via Autocorrelation:
autocorr = ฮฃ(r[i] ยท r[i-1]) / ฮฃ(r[i]ยฒ)
autocorr > 0.3โ TRENDING (moves propagate)autocorr < -0.3โ MEAN REVERTING (moves reverse)otherwiseโ CHAOTIC (unpredictable)
Parameters
| Parameter | Value | Description |
|---|---|---|
window | 50 | Number of bars analysed |
num_bins | 10 | Number of bins for the Shannon histogram |
autocorr threshold | ยฑ0.3 | Regime classification threshold |
Output
| Field | Type | Description |
|---|---|---|
entropy | f64 | Normalised entropy [0, 1] |
regime | MarketRegime | Trending / MeanReverting / Chaotic / Unknown |
clarity_score | f64 | 1 - entropy (signal clarity) |
LAYER 3: Hurst Exponent (Fractal Memory Analyzer)
What does it do?
It detects whether the market has memory (the trend will continue) or evolves randomly. It is based on R/S (Rescaled Range) analysis, invented by the hydrologist Harold Edwin Hurst.
Mathematical Formula
R/S (Rescaled Range) Method:
For each sub-series size n:
- Split the N-element series into sub-series of length
n - For each sub-series:
- Compute the mean:
ฮผ = ฮฃx / n - Compute the cumulative deviation:
Y[i] = ฮฃ(x[j] - ฮผ), j=1..i - Compute the range:
R = max(Y) - min(Y) - Compute the standard deviation:
S = sqrt(ฮฃ(x[j] - ฮผ)ยฒ / n) R/S = R / S(if S > 0)
- Average R/S over all sub-series
Log-log regression:
log(R/S) = H ยท log(n) + c
The Hurst exponent H is the slope of the linear regression on the log-log scale.
Interpretation
| Hurst | Meaning |
|---|---|
H > 0.5 | Persistent โ the trend will continue |
H = 0.5 | Random Walk โ no memory |
H < 0.5 | Anti-persistent โ the trend will reverse |
Signal
persistence_signal = (H - 0.5) ร 2.0 โ [-1, +1]
Multiplied by the direction of the most recent move:
- If price rose recently AND
H > 0.5โ persistence_signal becomes positive (bullish continuation) - If price fell recently AND
H > 0.5โ persistence_signal becomes negative (bearish continuation)
Parameters
| Parameter | Value | Description |
|---|---|---|
window | 128 | Maximum number of bars analysed |
min_group_sizes | [8, 16, 32, 64, 128] | Sub-series sizes |
LAYER 4: Lyapunov Exponent (Chaos Detector)
What does it do?
It measures how chaotic or predictable the market is. If similar trajectories diverge quickly โ the market is chaotic and unpredictable. If they stay similar โ the market is stable and predictable.
Mathematical Formula
1. Phase-space reconstruction (Takens' Theorem):
v[i] = [x[i], x[i+lag], x[i+2ยทlag], ..., x[i+(dim-1)ยทlag]]
with dim = 3, lag = 2
2. Nearest-neighbour search:
For each vector v[i], find the nearest neighbour v[j] (with a minimum temporal separation of 2 ร lag):
dist_0 = ||v[i] - v[j]||โ (Euclidean distance)
3. Divergence evolution:
Track how the distance evolves after k steps:
dist_k = ||v[i+k] - v[j+k]||โ
4. Lyapunov exponent:
ฮป = (1/N) ยท ฮฃ ln(dist_k / dist_0) / k
Interpretation
| ฮป | Meaning |
|---|---|
ฮป > 0.05 | CHAOTIC โ predictions are unreliable |
ฮป โ 0 | STABLE โ the market is predictable |
ฮป < 0 | CONVERGENT โ highly predictable |
Output
predictability = exp(-ฮป ร 10).clamp(0, 1)
predictability โ 1.0โ The market is predictablepredictability โ 0.0โ The market is chaotic
Parameters
| Parameter | Value | Description |
|---|---|---|
embedding_dim | 3 | Phase-space dimension |
lag | 2 | Embedding lag |
evolution_steps | 5 | How many steps divergence is tracked |
LAYER 5: Haar Wavelet Decomposition
What does it do?
It separates the price signal into a trend component (low frequency) and noise (high frequency). In effect it "denoises" the price, revealing the real trend hidden under the fluctuations.
Mathematical Formula
Haar transform at level l:
The signal is split recursively:
approx[i] = (signal[2i] + signal[2i+1]) / โ2 (approximation โ trend)
detail[i] = (signal[2i] - signal[2i+1]) / โ2 (detail โ noise)
This process is repeated over max_levels = min(6, logโ(N)) levels.
Reconstruction (Denoise):
The high-frequency details (first 2 levels) are zeroed and the inverse transform is applied:
signal_reconst[2i] = (approx[i] + detail[i]) / โ2
signal_reconst[2i+1] = (approx[i] - detail[i]) / โ2
Noise Ratio:
noise_ratio = (energy_detail_level_1 + energy_detail_level_2) / total_energy
where energy = ฮฃ d[i]ยฒ
Output
| Field | Type | Description |
|---|---|---|
denoised_trend | f64 | Denoised price (clean trend) |
trend_direction | f64 | Slope of the last 5 denoised values |
dominant_cycle | usize | Dominant cycle (2^level) |
noise_ratio | f64 | Proportion of noise [0, 1] |
LAYER 6: VPIN (Volume-Synchronized Probability of Informed Trading)
What does it do?
It detects smart money (informed) activity. High VPIN = someone with privileged information is trading aggressively. Developed at Cornell University for flash-crash detection.
Mathematical Formula
1. Volume classification (Bulk Volume Classification):
buy_fraction = (close - low) / (high - low)
buy_volume = volume ร buy_fraction
sell_volume = volume ร (1 - buy_fraction)
2. Volume Buckets:
Total volume is split into n_buckets equal buckets:
bucket_volume = total_volume / n_buckets
Each bucket accumulates buy and sell volume until it is full.
3. VPIN Calculation:
VPIN = ฮฃ|buy_bucket[i] - sell_bucket[i]| / ฮฃ(buy_bucket[i] + sell_bucket[i])
over the last n_buckets buckets.
Output
| Field | Type | Description |
|---|---|---|
vpin | f64 | Probability of informed trading [0, 1] |
toxicity_alert | bool | true if VPIN > 0.6 (smart money active!) |
buy_pressure | f64 | Buying pressure [0, 1] |
Interpretation
| VPIN | Meaning |
|---|---|
< 0.3 | Normal โ no smart-money activity |
0.3 - 0.6 | Moderate โ caution |
> 0.6 | ALERT โ smart money is trading aggressively |
LAYER 7: Bayesian Online Changepoint Detection (BOCPD)
What does it do?
It detects structural changes in real time. Based on the Adams & MacKay (2007) paper. When the market shifts from one regime to another (e.g. from trend to crash), BOCPD pinpoints the exact moment.
Mathematical Formula
Run Length = how many bars have elapsed since the last changepoint.
For each observation x_t:
1. Predictive Probability (Student-t):
ฯ(x_t | r) = Student-t(x_t; ฮผ_n, ฯยฒ_n, 2ฮฑ_n)
with Normal-Inverse-Gamma parameters updated online.
2. Growth vs Changepoint:
growth_prob[r+1] = joint[r] ร (1 - 1/ฮป)
changepoint_prob[0] += joint[r] ร (1/ฮป)
where ฮป = hazard_lambda (how often changepoints occur).
3. Normalisation:
P(r_t | data) = probs / ฮฃ probs
4. MAP Run Length:
best_run_length = argmax P(r_t | data)
Parameters
| Parameter | Value | Description |
|---|---|---|
hazard_lambda | 100.0 | Mean interval between changepoints (bars) |
ฮผโ | 0.0 | Prior mean |
ฮบโ | 1.0 | Prior strength |
ฮฑโ | 1.0 | Prior shape |
ฮฒโ | 0.0001 | Prior scale |
Output
| Field | Type | Description |
|---|---|---|
changepoint_probability | f64 | Probability of a changepoint NOW [0, 1] |
run_length | usize | Bars since the last changepoint |
regime_stable | bool | true if changepoint_prob < 0.3 |
FUSION LAYER โ Adaptive Combination
What does it do?
It combines the signals of all 7 layers with adaptive weights โ layers that are more confident receive a higher weight.
Fusion Formula
1. Individual Signals โ [-1, +1]:
kalman_signal = (velocity ร 1000).clamp(-1, +1)
hurst_signal = persistence_signal (already [-1, +1])
wavelet_signal = (trend_direction ร 100).clamp(-1, +1)
vpin_signal = (buy_pressure - 0.5) ร 2 (map [0,1] โ [-1,+1])
2. Fixed (Base) Weights:
| Layer | Weight | Rationale |
|---|---|---|
| Kalman | 0.30 | The most direct predictor (price + velocity) |
| Wavelet | 0.25 | High-quality denoised trend |
| Hurst | 0.20 | Memory / persistence |
| VPIN | 0.15 | Smart-money activity |
| Entropy echo | 0.10 | Clarity ร Kalman (confirmation) |
3. Meta-Confidence (Global Modifier):
meta_confidence = (lyapunov.predictability ร entropy.clarity ร stability_factor).clamp(0, 1)
where stability_factor = 1.0 if the regime is stable, 0.3 otherwise.
4. Regime Boost:
Trending โ ร 1.3 (boost โ directional signals are trustworthy)
MeanReverting โ ร 0.7 (reduce โ the trend may reverse)
Chaotic โ ร 0.3 (severe penalty โ unpredictable)
5. Final Score:
raw = w_kalman ร kalman + w_wavelet ร wavelet + w_hurst ร hurst + w_vpin ร vpin + w_entropy ร kalman ร clarity
oracle_score = (raw ร regime_boost ร meta_confidence ร 100).clamp(-100, +100)
6. Final Confidence:
confidence = meta_confidence ร max(0, 1 - noise_ratio)
Interpreting oracle_score
| Score | Interpretation | Action |
|---|---|---|
| +15 to +100 | Bullish | ๐ข LONG |
| -15 to +15 | Neutral / Uncertain | โช HOLD |
| -100 to -15 | Bearish | ๐ด SHORT |
V2 OPTIMISATION NOTE: The historical computation was optimised from O(nยฒ) to O(n) using pre-computed series and point-by-point fusion. This allows instant computation over thousands of bars without timeouts. The thresholds were adjusted to ยฑ15 to reflect the real scale of the composite scores.
Chaos Kill Switch
If confidence < 0.15, the market is in complete chaos:
- A -50 point penalty is applied to the strategy score
- This effectively blocks any trade entry
- Rationale: in chaos, NO indicator can be trusted
Data Flow Diagram
Candle[] โโโ close[] โโโฌโโ Kalman Filter โโโโ predicted_price, velocity
โโโ Entropy Regime โโโโ entropy, regime, clarity
โโโ Hurst R/S โโโโโโโโโ hurst, persistence
โโโ Lyapunov โโโโโโโโโโ exponent, predictability
โโโ Wavelet Haar โโโโโโ denoised_trend, noise_ratio
Candle[] โโโ volume โโโโโ VPIN โโโโโโโโโโโโโโโ vpin, buy_pressure, toxicity
close[] โโโโโ BOCPD โโโโโโโโโโโโโโ changepoint_prob, run_length
โ
โผ
FUSION LAYER
adaptive weights ร regime
โ
โผ
oracle_score [-100, +100]
confidence [0.0, 1.0]
dominant_regime
Advantages over Traditional Indicators
| Aspect | Classic Indicators (EMA, RSI) | TITAN ORACLE |
|---|---|---|
| Timing | Lagging (look at the past) | Leading (forecast the future) |
| Noise | Sensitive to noise | Wavelet denoises the signal |
| Regime | Not detected | Entropy + Changepoint detect it |
| Smart Money | Invisible | VPIN detects informed activity |
| Chaos | Ignored | Lyapunov + Kill Switch protect |
| Memory | Not analysed | Hurst detects persistence |
| Adaptivity | Fixed parameters | Adaptive weights based on conditions |
Source Files
| File | Description |
|---|---|
src-tauri/crates/titan-indicators/src/oracle.rs | Full implementation (all 7 layers + fusion + unit tests) |
src-tauri/crates/titan-indicators/benches/bench_oracle.rs | Criterion benchmarks for the Oracle pipeline |
src-tauri/src/titan_oracle.rs | Re-export of the titan-indicators Oracle API into the main crate |
src-tauri/src/strategy.rs | Decision logic driven by oracle_score |
src-tauri/src/commands/backtest.rs | Tauri command get_oracle_snapshot (registered in main.rs) |
TITAN ORACLE v1.0 โ Precision. Prediction. Profit. ๐ฎ