OPEN-SOURCE SCRIPT

Crypto Directional Score Oscillator [FibonacciFlux]

86
A causal OHLCV direction score for crypto with a fixed-coefficient mode and two Bayesian-regime modes - published with measurements showing that the default mode ranks outcomes only weakly, that its percentages are not probabilities, and that the two Bayesian modes do not rank outcomes at all.

This plots an Up score and a Down score from 0 to 100 against a threshold. Neither is a chance of anything. It was saved as "Crypto Directional Probability Oscillator" and renamed before publishing, because the measurements below show the number is not a probability.

🔶 USAGE

In Fixed mode the oscillator blends five features of the current bar - trend, momentum, mean reversion, volume-weighted close location and path efficiency - into a logistic score from 0 to 100; the Bayesian modes add a volatility-regime input. Markers print where the score crosses a threshold. Read it as a compact summary of which features dominate right now. Do not read it as a forecast: its best measured ranking ability is an AUC of 0.55, before any trading cost, and its markers do not beat chance.

🔹 Reading the pane
  • Up score, teal, and Down score, red, are mirror images: the Down score is 100 minus the Up score. They are one number drawn twice.
  • The grey guides sit at the threshold, at 50, and at 100 minus the threshold.
  • A marker prints on a confirmed bar when either line crosses up through the threshold. Every marker sits on the upper guide, bearish ones included, because a bearish marker is the red Down score crossing up through it; nothing prints at the lower guide. C means efficiency is at or above the Trend Regime Threshold and trend agrees in sign; R is every other crossing.
  • The table, bottom right: the active mode; what the number is and its measured AUC range; in the Bayesian modes the dominant regime and its posterior; in Bayesian + Adaptive the number of scored samples each expert holds (weights apply from 12); and a warning when volume is missing or the timeframe is outside 1h-4h.
  • In the Bayesian modes the Data Window also lists the four regime posteriors (Bull, Bear, Range, Stress) in percent.


🔹 The modes have opposite signs
A HIGH Fixed reading means price below its fast EMA with negative momentum - a dip-buy read. A high reading in either Bayesian mode means an established uptrend above it - a continuation read. Across all four symbol-timeframe pairs, the Up score correlates +0.51 to +0.60 with mean reversion and -0.09 to +0.02 with trend in Fixed, against -0.46 to -0.41 and +0.78 to +0.81 in both Bayesian modes. Switching the dropdown reverses what a high number means.

🔹 Warm-up and repainting
Fixed needs 55 bars and the Bayesian modes 64 - about 2.3 and 2.7 days on 1h, 9 and 11 days on 4h. Adaptive weights go live after roughly 150-160 bars; the exact count depends on where the chart's history starts, because adaptation samples every eighth bar by timestamp. The lines move while a bar is open. The regime filter, the adaptation and every marker update on confirmed bars only, so historical markers do not repaint.

🔶 DETAILS

🔹 The mechanism
Fixed mode, every coefficient asserted rather than estimated:
Pine Script®

The Bayesian modes run a four-state filter (Bull, Bear, Range, Stress) with Student-t likelihoods and gate four expert logits by the posterior. Two constants flip the sign, and only together: the gate gives mean reversion 0.05 of the weight under a Bull or Bear posterior (0.55 under Range), and a 0.90 * (pBull - pBear) term adds a directional-state signal driven mostly by trend. Changing either alone leaves the mean-reversion correlation at -0.21 to -0.29; changing both turns it to +0.44 to +0.49. None of the roughly 80 constants in the file was fitted to data.

🔹 Measured result
Binance BTCUSDT and ETHUSDT, 1h (21,567 bars per symbol) and 4h (5,392 per symbol), 2024-04-01 to 2026-09-16. The code attaches no forward horizon to the score, so outcomes were scored at 1, 8 and 24 bars: 12 cells per mode. Nulls are circular shifts of the outcome series, seeded, with the observed statistic pooled into the draws.

  • Fixed ranks outcomes, weakly. AUC 0.509 to 0.550, above 0.5 in 12 of 12 cells, significant in 8 (400 draws), family-wise p 0.027 - but the 12 cells are not independent: they share three overlapping horizons and two nested timeframes, and BTCUSDT and ETHUSDT log returns correlate 0.82. Uneven: 6 of 6 ETHUSDT cells, 2 of 3 BTCUSDT 1h, 0 of 3 BTCUSDT 4h (p 0.24-0.63).
  • Its percentages overstate that by roughly 4 to 24 times. At 8 bars the top Fixed decile (mean printed 63.0-63.7) rose 50.7-52.5% of the time; the bottom decile (36.9-37.5) rose 44.1-49.5%. A printed spread of about 26 points is a realized spread of 1.1 to 6.8, an overstatement of 3.9x, 4.5x, 9.7x and 23.8x in the four cells. Brier skill against always predicting the base rate is negative in 11 of 12 Fixed cells (-0.004 to -0.021; one cell +0.003).
  • The Bayesian modes do not rank outcomes. AUC 0.467 to 0.505 across 24 cells, none significant (smallest p 0.095), family-wise p 0.91, Brier skill -0.156 to -0.205. Their extreme tails lean the wrong way - the top decile rose less often than the bottom in 24 of 24 cells, mean -0.062 - but the ranking as a whole is not detectably inverted.
  • The markers do not separate from chance. 138 tests (144 marker-type x horizon x symbol x timeframe x mode combinations, less 6 with fewer than 5 events): 13 reach p <= 0.05 where 6.9 are expected, family-wise p 0.120. The two strongest are the same marker with opposite signs, both Bayesian + Adaptive one bar ahead: bearish continuation +54.89bp on BTCUSDT 4h, -72.52bp on ETHUSDT 4h.


🔹 Known limits
  • Between 28% and 42% of the threshold slider does nothing in Fixed mode. Neither Fixed line can exceed 85.32 (logit bound 1.760), and the larger of the two peaked at 75.5 to 80.5, so 14, 15, 10 and 12 of the 36 positions printed no marker in 2.4 years on BTCUSDT 1h, BTCUSDT 4h, ETHUSDT 1h and ETHUSDT 4h. Both Bayesian modes reach about 93. At 0.70 on BTCUSDT 1h: 97 markers in Fixed, 574 in Bayesian Regime, 619 in Bayesian + Adaptive.
  • The Stress state is almost unused: dominant on 0.1% to 0.3% of bars, median posterior 0.004. Moving Stress Sensitivity from 0.5 to 2.0 changes the Up score by 0.34 to 0.40 points on average.
  • Adaptation moves the Up score by 1.1 to 1.3 points on average and at most 19, and leaves the Bayesian tail pattern in place in 12 of 12 cells.
  • Two instruments, two timeframes, no transaction costs.


🔹 How the numbers were checked
The model was reimplemented outside Pine and compared with the chart's Data Window: 271 values over 14 bars - Fixed and Bayesian Regime on BTCUSDT 4h (2026-06-13 to 2026-08-19), Bayesian + Adaptive on BTCUSDT 1h (2026-09-10 to 2026-09-15). Fixed and Bayesian Regime agree to 4.9e-9. The largest adaptive difference, 0.004 points of the Up score on one bar, is volume: TradingView's BINANCE feed showed 349.12 where Binance's API reports 363.19, and flow is the only input that reads it.

Three reviews of the draft changed its conclusions, and the corrections are recorded because each wrong version looked finished. The draft said the score did not discriminate at all and that the Bayesian modes rank outcomes in reverse; a re-test found Fixed does rank weakly and the reversal is confined to the tails. The marker family-wise p was first 0.0010 (each null draw was compared against a set containing itself), then 0.0605 (observed and null p on different grids), and is 0.120 with the pooled estimator. The two estimator errors both made the markers look better than they are; the first-draft error ran the other way and understated Fixed.

🔶 SETTINGS

🔹 Model Mode
  • Model Mode - Fixed, Bayesian Regime, or Bayesian + Adaptive; the modes have opposite signs (default: Fixed)


🔹 Features and Signals - used by every mode
  • Fast EMA - trend and mean-reversion anchor (default: 21, range 5-80)
  • Slow EMA - trend reference (default: 55, range 20-200)
  • Momentum Horizon - bars in the normalized return (default: 8, range 2-30)
  • Normalization Length - return deviation and volume average (default: 20, range 10-100)
  • Efficiency Length - bars in the path-efficiency ratio (default: 20, range 5-100)
  • Signal Threshold - marker level; prints nothing in Fixed from 0.76-0.81 upward (default: 0.70, range 0.55-0.90)
  • Trend Regime Threshold - efficiency needed to label a crossing C rather than R (default: 0.35, range 0.10-0.80)


🔹 Bayesian Regime
  • Trend-State Persistence - probability a trend state carries to the next bar (default: 0.90, range 0.70-0.98)
  • Student-t Degrees of Freedom - tail weight of the likelihoods (default: 5, range 3-15)
  • Stress Sensitivity - Bayesian modes only; lowers the volatility level at which Stress engages; nearly inert (default: 1.0, range 0.5-2.0)


🔹 Optional Adaptation
  • Outcome Horizon - Bayesian + Adaptive only; bars before an expert's call is scored, and the sampling cadence (default: 8, range 2-24)
  • Matured Observations - Bayesian + Adaptive only; scored samples kept per expert; at least 12 before weights apply (default: 48, range 12-120)
  • Greediness - how sharply lower loss raises an expert's weight (default: 2.0, range 0.25-6.0)
  • Minimum Expert Weight - floor on an expert's raw score before the four weights are normalized, so the realized minimum weight is higher than this: 0.10 to 0.17 in the measured data (default: 0.05, range 0.01-0.20)


🔹 Two-Color Style
  • Up / Bullish - colour of the Up score line and the bullish markers (default: #14B8A6)
  • Down / Bearish - colour of the Down score line and the bearish markers (default: #F43F5E)
  • Line Width - width of both score lines (default: 2, range 1-4)


Open source under the Mozilla Public License 2.0. Nothing here is a forecast, a signal service, or a claim of profitability.

Haftungsausschluss

Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.