@pgnio/helios-mcp 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +44 -2
  2. package/dist/chunk-NWGWXYTS.mjs +2964 -0
  3. package/dist/cli.d.mts +1 -0
  4. package/dist/cli.d.ts +1 -0
  5. package/dist/cli.js +2946 -0
  6. package/dist/cli.mjs +24 -0
  7. package/dist/index.d.mts +2137 -0
  8. package/dist/index.d.ts +2137 -0
  9. package/dist/index.js +3021 -0
  10. package/dist/index.mjs +52 -0
  11. package/docs/ai-agent-indicators/00_index.txt +210 -0
  12. package/docs/ai-agent-indicators/activity_ratio.txt +166 -0
  13. package/docs/ai-agent-indicators/activity_zscore.txt +166 -0
  14. package/docs/ai-agent-indicators/bayesian_overbought.txt +134 -0
  15. package/docs/ai-agent-indicators/directional_efficiency.txt +134 -0
  16. package/docs/ai-agent-indicators/hfi.txt +172 -0
  17. package/docs/ai-agent-indicators/hfi_weights.txt +124 -0
  18. package/docs/ai-agent-indicators/hmi.txt +305 -0
  19. package/docs/ai-agent-indicators/hmi_velocity.txt +155 -0
  20. package/docs/ai-agent-indicators/hurst_exponent.txt +136 -0
  21. package/docs/ai-agent-indicators/macd_divergence.txt +133 -0
  22. package/docs/ai-agent-indicators/macd_histogram.txt +145 -0
  23. package/docs/ai-agent-indicators/macd_signal.txt +119 -0
  24. package/docs/ai-agent-indicators/market_structure.txt +201 -0
  25. package/docs/ai-agent-indicators/poc.txt +131 -0
  26. package/docs/ai-agent-indicators/poc_distance.txt +129 -0
  27. package/docs/ai-agent-indicators/regime.txt +225 -0
  28. package/docs/ai-agent-indicators/rsi_divergence.txt +145 -0
  29. package/docs/ai-agent-indicators/squeeze_duration.txt +115 -0
  30. package/docs/ai-agent-indicators/squeeze_energy.txt +128 -0
  31. package/docs/ai-agent-indicators/support_resistance.txt +169 -0
  32. package/docs/ai-agent-indicators/tf_alignment.txt +165 -0
  33. package/docs/ai-agent-indicators/trend_interpretation.txt +98 -0
  34. package/docs/ai-agent-indicators/trend_strength.txt +134 -0
  35. package/docs/ai-agent-indicators/value_area_position.txt +142 -0
  36. package/docs/ai-agent-indicators/volatility_clustering.txt +160 -0
  37. package/docs/ai-agent-indicators/volatility_squeeze.txt +169 -0
  38. package/docs/ai-agent-indicators/volume_change_point.txt +151 -0
  39. package/docs/ai-agent-indicators/vwap.txt +133 -0
  40. package/docs/ai-agent-indicators/vwap_zscore.txt +154 -0
  41. package/docs/ai-agent-indicators/weighted_rsi.txt +148 -0
  42. package/docs/ai-agent-mcp/00_index.txt +110 -0
  43. package/docs/ai-agent-mcp/01_auth/00_overview.txt +51 -0
  44. package/docs/ai-agent-mcp/01_auth/01_tools.txt +94 -0
  45. package/docs/ai-agent-mcp/01_auth/02_data_contracts.txt +38 -0
  46. package/docs/ai-agent-mcp/01_auth/03_decision_rules.txt +25 -0
  47. package/docs/ai-agent-mcp/01_auth/04_failures_and_recovery.txt +46 -0
  48. package/docs/ai-agent-mcp/02_account/00_overview.txt +29 -0
  49. package/docs/ai-agent-mcp/02_account/01_tools.txt +67 -0
  50. package/docs/ai-agent-mcp/02_account/02_data_contracts.txt +34 -0
  51. package/docs/ai-agent-mcp/02_account/03_decision_rules.txt +17 -0
  52. package/docs/ai-agent-mcp/02_account/04_failures_and_recovery.txt +17 -0
  53. package/docs/ai-agent-mcp/03_market/00_overview.txt +27 -0
  54. package/docs/ai-agent-mcp/03_market/01_tools.txt +102 -0
  55. package/docs/ai-agent-mcp/03_market/02_data_contracts.txt +39 -0
  56. package/docs/ai-agent-mcp/03_market/03_decision_rules.txt +22 -0
  57. package/docs/ai-agent-mcp/03_market/04_failures_and_recovery.txt +18 -0
  58. package/docs/ai-agent-mcp/04_trading/00_overview.txt +25 -0
  59. package/docs/ai-agent-mcp/04_trading/01_tools.txt +123 -0
  60. package/docs/ai-agent-mcp/04_trading/02_data_contracts.txt +42 -0
  61. package/docs/ai-agent-mcp/04_trading/03_decision_rules.txt +30 -0
  62. package/docs/ai-agent-mcp/04_trading/04_failures_and_recovery.txt +25 -0
  63. package/docs/ai-agent-mcp/05_ledger/00_overview.txt +31 -0
  64. package/docs/ai-agent-mcp/05_ledger/01_tools.txt +80 -0
  65. package/docs/ai-agent-mcp/05_ledger/02_data_contracts.txt +46 -0
  66. package/docs/ai-agent-mcp/05_ledger/03_decision_rules.txt +44 -0
  67. package/docs/ai-agent-mcp/05_ledger/04_failures_and_recovery.txt +24 -0
  68. package/package.json +66 -3
@@ -0,0 +1,115 @@
1
+ ================================================================================
2
+ INDICATOR: SQUEEZE_DURATION — VOLATILITY SQUEEZE DURATION
3
+ ================================================================================
4
+ id: squeeze_duration
5
+ data_field: indicators.squeeze_duration
6
+ type: NUMERIC (integer count)
7
+ range: [0, ∞)
8
+ precision: Integer (whole number of ticks)
9
+ update_rate: per_tick
10
+ latency_profile: COINCIDENT
11
+
12
+ --------------------------------------------------------------------------------
13
+ CONSTRUCT
14
+ --------------------------------------------------------------------------------
15
+ squeeze_duration counts the number of consecutive ticks where the volatility
16
+ squeeze value has been BELOW the squeeze threshold of 0.8.
17
+
18
+ IF indicators.volatility_squeeze < 0.8
19
+ squeeze_duration += 1
20
+
21
+ IF indicators.volatility_squeeze >= 0.8
22
+ squeeze_duration = 0 (reset immediately when squeeze breaks)
23
+
24
+ A duration of 0 means either the squeeze is not active (value >= 0.8) or
25
+ the squeeze just started this tick (first tick below 0.8).
26
+
27
+ This indicator quantifies the TIME dimension of the squeeze. When combined
28
+ with volatility_squeeze (depth) and squeeze_energy (integrated depth × time),
29
+ it provides the full picture of a squeeze development.
30
+
31
+ --------------------------------------------------------------------------------
32
+ RANGE INTERPRETATION
33
+ --------------------------------------------------------------------------------
34
+ value = 0
35
+ No active squeeze. volatility_squeeze >= 0.8. Normal or expanding
36
+ volatility conditions. OR: squeeze just broke this tick (value resets
37
+ immediately). In either case: not in a sustained compression state.
38
+
39
+ value 1-5 (very short)
40
+ Just entered squeeze territory. Compression has barely begun.
41
+ Insufficient duration for meaningful energy buildup. Do not treat as
42
+ an active squeeze setup until duration is longer.
43
+
44
+ value 6-20 (short squeeze)
45
+ Squeeze has persisted for a meaningful period. Some directional energy
46
+ is building, especially if volatility_squeeze is also deep (< 0.5).
47
+ Combination of squeeze_duration and squeeze_energy now worth monitoring.
48
+
49
+ value 21-60 (moderate squeeze)
50
+ Sustained compression. An extended period of volatility below the GARCH
51
+ baseline. This duration at low squeeze_value produces significant squeeze_energy.
52
+ Market is in a genuine consolidation/coiling phase.
53
+
54
+ value > 60 (extended squeeze)
55
+ Prolonged compression. Very significant stored directional energy by any
56
+ measure. Extended squeezes historically precede the most significant
57
+ breakout moves. The asset has been unable to sustain any realized trend
58
+ for a long period.
59
+
60
+ --------------------------------------------------------------------------------
61
+ INDICATOR RELATIONSHIPS
62
+ --------------------------------------------------------------------------------
63
+ indicators.volatility_squeeze | REQUIRED_COMPANION
64
+ squeeze_duration counts ticks at squeeze; but duration without
65
+ knowing the depth (volatility_squeeze value) is incomplete.
66
+
67
+ High duration + deep squeeze = maximum energy accumulation.
68
+ High duration + shallow squeeze (value = 0.75) = moderate accumulation.
69
+ Low duration + deep squeeze = sudden sharp compression, not settled yet.
70
+
71
+ The most significant setups are:
72
+ volatility_squeeze < 0.4 AND squeeze_duration > 30
73
+
74
+ indicators.squeeze_energy | COMPANION
75
+ squeeze_energy = squeeze_duration × (0.8 - volatility_squeeze)
76
+ It is the integrated compression depth over time.
77
+ squeeze_duration is the COUNT; squeeze_energy is the MAGNITUDE.
78
+ Use duration to track progression; use energy for trade assessment.
79
+
80
+ indicators.regime | CONTEXT
81
+ IF regime = CONSOL AND squeeze_duration > 20
82
+ → Both regime and volatility confirm sustained compression.
83
+ IF regime shifts from CONSOL to BREAKOUT AND squeeze_duration was > 20
84
+ → The squeeze has been significant and the breakout is more likely
85
+ to produce a sustained move.
86
+
87
+ --------------------------------------------------------------------------------
88
+ DEPENDENCY ORDER
89
+ --------------------------------------------------------------------------------
90
+ 1 If squeeze_duration = 0: no active squeeze; no buildup to evaluate.
91
+ 2 Read volatility_squeeze for current depth.
92
+ 3 Read squeeze_energy for integrated depth × time.
93
+ 4 Classify duration (short/moderate/extended) per ranges above.
94
+ 5 Regime for compression/breakout context.
95
+
96
+ --------------------------------------------------------------------------------
97
+ INVALIDATION CONDITIONS
98
+ --------------------------------------------------------------------------------
99
+ No specific invalidation beyond the parent volatility_squeeze indicator.
100
+ If volatility_squeeze is in warm-up (< 50 ticks since reset), squeeze_duration
101
+ may show extended values from the warm-up period. Treat as unreliable.
102
+
103
+ --------------------------------------------------------------------------------
104
+ ANTI-PATTERNS — DETECTABLE MISUSE CONDITIONS
105
+ --------------------------------------------------------------------------------
106
+ IF squeeze_duration > 60 is treated as urgency to enter a trade
107
+ → INCORRECT TIMING LOGIC. Long squeeze duration means energy has been
108
+ building — it does NOT tell you when the release will occur. A squeeze
109
+ can persist for 200+ ticks. Duration informs the MAGNITUDE of the
110
+ expected move when it occurs, not the TIMING.
111
+
112
+ IF squeeze_duration resets to 0 is missed and old duration is used
113
+ → DATA FRESHNESS CHECK REQUIRED. squeeze_duration resets immediately
114
+ when volatility_squeeze >= 0.8. If you are caching the prior reading,
115
+ you may be working with stale duration data. Always re-read per tick.
@@ -0,0 +1,128 @@
1
+ ================================================================================
2
+ INDICATOR: SQUEEZE_ENERGY — VOLATILITY SQUEEZE ENERGY
3
+ ================================================================================
4
+ id: squeeze_energy
5
+ data_field: indicators.squeeze_energy
6
+ type: NUMERIC
7
+ range: [0, ∞) — resets to 0 whenever squeeze breaks
8
+ precision: 3 decimal places
9
+ update_rate: per_tick
10
+ latency_profile: COINCIDENT
11
+
12
+ --------------------------------------------------------------------------------
13
+ CONSTRUCT
14
+ --------------------------------------------------------------------------------
15
+ squeeze_energy is the integrated measure of volatility compression, capturing
16
+ both HOW LONG and HOW DEEPLY the volatility has been squeezed. It combines the
17
+ time (duration) and depth (compression magnitude) of the current squeeze.
18
+
19
+ Formula (computed each tick while squeeze is active):
20
+ compressionDepth = 0.8 - indicators.volatility_squeeze
21
+ (positive only when volatility_squeeze < 0.8; deeper = larger value)
22
+
23
+ squeeze_energy = squeeze_duration × compressionDepth
24
+ = squeeze_duration × (0.8 - volatility_squeeze)
25
+
26
+ IF volatility_squeeze >= 0.8:
27
+ squeeze_energy = 0 (reset simultaneously with squeeze_duration)
28
+
29
+ Examples:
30
+ - Duration=10, squeeze_value=0.5: energy = 10 × 0.3 = 3.0
31
+ - Duration=30, squeeze_value=0.5: energy = 30 × 0.3 = 9.0 (3× longer)
32
+ - Duration=10, squeeze_value=0.2: energy = 10 × 0.6 = 6.0 (2× deeper)
33
+ - Duration=30, squeeze_value=0.2: energy = 30 × 0.6 = 18.0 (most energy)
34
+
35
+ squeeze_energy is the single best summary of "how much potential energy has built
36
+ up in this squeeze". It is zero when no squeeze is active and grows as long as
37
+ the squeeze persists.
38
+
39
+ --------------------------------------------------------------------------------
40
+ RANGE INTERPRETATION
41
+ --------------------------------------------------------------------------------
42
+ value = 0
43
+ No active squeeze OR squeeze just started. No meaningful energy accumulation.
44
+
45
+ value 0.1 - 3.0
46
+ Low energy. Short and/or shallow squeeze. Potential move is not yet
47
+ significant by historical comparison. Continue monitoring.
48
+
49
+ value 3.0 - 10.0
50
+ Moderate energy. Sufficient compression has built to support a meaningful
51
+ directional breakout when it occurs. This band represents most "ready to
52
+ break" squeeze setups.
53
+
54
+ value 10.0 - 25.0
55
+ High energy. Significant compression over extended duration and/or depth.
56
+ The breakout when it occurs is more likely to produce an outsized move.
57
+ This is an alert-level condition.
58
+
59
+ value > 25.0
60
+ Very high energy. Extreme sustained compression. Very rare in normal markets.
61
+ When seen, the eventual breakout should be expected to be substantial.
62
+ Activity_ratio and volume_change_point conditions at release are key.
63
+
64
+ --------------------------------------------------------------------------------
65
+ INDICATOR RELATIONSHIPS
66
+ --------------------------------------------------------------------------------
67
+ indicators.volatility_squeeze | REQUIRED_COMPANION
68
+ squeeze_energy is derived from volatility_squeeze depth.
69
+ Always verify volatility_squeeze is in squeeze state (< 0.8) alongside
70
+ any positive squeeze_energy reading.
71
+
72
+ indicators.squeeze_duration | COMPANION
73
+ Together with squeeze_duration, these three indicators form the complete
74
+ squeeze picture:
75
+ volatility_squeeze = current depth (real-time)
76
+ squeeze_duration = time in compression (tick count)
77
+ squeeze_energy = integrated depth × time (summary measure)
78
+
79
+ indicators.volume_change_point | ALERT COMPANION
80
+ When squeeze_energy is high AND volume_change_point.changePointProbability
81
+ is rising, it signals that the volume regime may be shifting — potentially
82
+ the initiation of the squeeze release. High energy + volume regime shift
83
+ is the most actionable combination.
84
+
85
+ indicators.market_structure | CONTEXT
86
+ IF squeeze_energy > 10 AND market_structure transitions to BREAKING_UP
87
+ or BREAKING_DOWN → the breakout is coming from a high-energy compressed
88
+ state. Highest conviction continuation expected.
89
+
90
+ indicators.hmi | POST-SQUEEZE DIRECTION
91
+ After squeeze_energy resets to 0 (squeeze broke), read hmi to determine
92
+ which direction the energy released in. This is the critical post-squeeze
93
+ directional inference step.
94
+
95
+ indicators.activity_ratio | TRIGGER COMPANION
96
+ IF squeeze_energy > 10 AND activity_ratio transitions from MODERATE/DEAD
97
+ to ACTIVE → new volume entering a compressed market. This is the most
98
+ common trigger for a squeeze release.
99
+
100
+ --------------------------------------------------------------------------------
101
+ DEPENDENCY ORDER
102
+ --------------------------------------------------------------------------------
103
+ 1 If squeeze_energy = 0: no active squeeze; no energy has accumulated.
104
+ 2 Read volatility_squeeze for current depth.
105
+ 3 Read squeeze_duration for elapsed time.
106
+ 4 Classify energy level per ranges above.
107
+ 5 Monitor volume_change_point for rising changepoint probability.
108
+ 6 Post-reset (squeeze broke): read hmi for direction of energy release.
109
+
110
+ --------------------------------------------------------------------------------
111
+ INVALIDATION CONDITIONS
112
+ --------------------------------------------------------------------------------
113
+ All invalidations from volatility_squeeze apply.
114
+ IF volatility_squeeze is in warm-up: squeeze_energy from that period is
115
+ unreliable.
116
+
117
+ --------------------------------------------------------------------------------
118
+ ANTI-PATTERNS — DETECTABLE MISUSE CONDITIONS
119
+ --------------------------------------------------------------------------------
120
+ IF high squeeze_energy is used as a directional indicator
121
+ → INCORRECT. squeeze_energy tells you that a move is more likely to
122
+ be large when it comes. It says nothing about direction.
123
+ Only post-release hmi and regime provide direction.
124
+
125
+ IF squeeze_energy is monitored but release detection is missed
126
+ → WATCH FOR RESET. When squeeze_energy drops from a high value to 0,
127
+ the squeeze has broken. The next readings of hmi and regime provide
128
+ the directional interpretation of the released energy.
@@ -0,0 +1,169 @@
1
+ ================================================================================
2
+ INDICATOR: SUPPORT / RESISTANCE — DYNAMIC SUPPORT AND RESISTANCE LEVELS
3
+ ================================================================================
4
+ id: support_resistance
5
+ data_field: indicators.support (array of level objects)
6
+ indicators.resistance (array of level objects)
7
+ type: ARRAY of level objects
8
+ update_rate: per_tick
9
+ latency_profile: SLOW (multi-scale pivot clustering; KDE-based consolidation)
10
+
11
+ --------------------------------------------------------------------------------
12
+ CONSTRUCT
13
+ --------------------------------------------------------------------------------
14
+ Support and resistance levels are detected via a hybrid system combining:
15
+ 1. EMA(120) + ATR(14) bands — structural dynamic levels
16
+ 2. Multi-scale pivot point clustering — historical price turning points
17
+ 3. Bayesian Beta-Binomial strength scoring — statistical hold probability
18
+
19
+ Each output is an array of level objects sorted by proximity to current price.
20
+
21
+ Level object structure:
22
+ {
23
+ price: price level (number)
24
+ distance: % distance from current price (positive if above)
25
+ touches: raw count of price interactions
26
+ weightedTouches: volume and time-decay weighted touch count
27
+ strength: STRONG | MODERATE | WEAK (based on weightedTouches)
28
+ source: "ema_band" | "pivot_cluster" | "poc" | "polarity_flip"
29
+ bayesianStrength: P(0..1) — Bayesian posterior probability the level holds
30
+ }
31
+
32
+ PIVOT CLUSTERING (4 window scales: 240, 120, 60, 30 candles):
33
+ A pivot high exists when a candle has the highest High in its window.
34
+ A pivot low exists when a candle has the lowest Low in its window.
35
+ Pivots are KDE-smoothed (Gaussian kernel) and merged when within dead zone.
36
+
37
+ WEIGHT FORMULA PER LEVEL:
38
+ timeWeight = f(age of level):
39
+ age <= 6h: linear decay 1.0 → 0.8
40
+ 6h - 24h: linear decay 0.8 → 0.3
41
+ > 25h: base weight 0.1
42
+ recencyBoost: × 2.0 if age <= 240 minutes
43
+ volScore: clamp(1 + (volume at level / avgVolume)^0.5, 1.0, 3.0)
44
+ weight = timeWeight × recencyBoost × volScore
45
+
46
+ STRENGTH TIERS (by weightedTouches):
47
+ >= 3.0 → STRONG
48
+ >= 1.5 → MODERATE
49
+ >= 0.5 → WEAK
50
+ < 0.5 → filtered out (not emitted)
51
+
52
+ DEAD ZONE FILTER:
53
+ min(ATR × 0.1, price × 0.001) — levels closer than this to each other
54
+ or to current price are filtered out (noise).
55
+
56
+ BAYESIAN STRENGTH (Beta-Binomial over 2000-candle lookback):
57
+ At each level, over the last 2000 bars:
58
+ - Total times price approached the level: N
59
+ - Times price held/reversed at the level: k
60
+ bayesianStrength = (k + 1) / (N + 2) [Laplace-smoothed Beta posterior]
61
+ Represents the empirical probability that the level holds when tested.
62
+
63
+ POLARITY FLIPS:
64
+ A resistance level becomes support after 30 consecutive bars where price
65
+ holds >= 0.3% above the broken level. Vice versa for support → resistance.
66
+ source = "polarity_flip" for these converted levels.
67
+
68
+ --------------------------------------------------------------------------------
69
+ LEVEL INTERPRETATION
70
+ --------------------------------------------------------------------------------
71
+ STRONG level (weightedTouches >= 3.0)
72
+ This level has been tested and respected multiple times with volume and time
73
+ weighting. Each time price has approached, it has reversed or consolidated.
74
+ High-significance structural level.
75
+
76
+ MODERATE level (weightedTouches 1.5-3.0)
77
+ Notable level with multiple weighted touches. Meaningful but not dominant.
78
+ Valid for stop reference and entry proximity but less reliable than STRONG.
79
+
80
+ WEAK level (weightedTouches 0.5-1.5)
81
+ Recent or lightly tested level. Provides short-term reference but may not
82
+ hold under strong directional pressure.
83
+
84
+ bayesianStrength thresholds:
85
+ >= 0.75 : high probability of holding at next test
86
+ 0.50-0.74: moderate probability
87
+ < 0.50 : historically holds less than 50% of tests — treat as breakout zone
88
+
89
+ POLARITY FLIP levels:
90
+ Former resistance now support (or vice versa). These are often the most
91
+ significant structural levels — the price level has been validated as
92
+ a decision zone from both sides.
93
+
94
+ --------------------------------------------------------------------------------
95
+ INDICATOR RELATIONSHIPS
96
+ --------------------------------------------------------------------------------
97
+ indicators.poc | AMPLIFIES
98
+ A support level that coincides with POC (within dead zone tolerance)
99
+ has the highest structural significance in the entire system.
100
+ Two independent computations (volume profile + pivot clustering) agree.
101
+
102
+ indicators.vwap | AMPLIFIES
103
+ A support level near VWAP is doubly anchored (volume cost average +
104
+ price pivot). When these coincide during a pullback, they define the
105
+ highest-probability support zone.
106
+
107
+ indicators.value_area_high / value_area_low | CONTEXT
108
+ VA edges are implicit levels. When S/R indicator also identifies a level
109
+ near VA_High or VA_Low, the zone is confirmed by both methods.
110
+
111
+ indicators.hmi | CONTEXT
112
+ IF hmi >= 60 AND price pulls back to STRONG support
113
+ → Trend intact, prices testing known structural support. Standard
114
+ trend continuation zone.
115
+ IF hmi < 20 AND price is at STRONG resistance
116
+ → Low momentum meets high resistance. Structural ceiling may cap.
117
+
118
+ indicators.market_structure | COMPANION
119
+ market_structure = BREAKING_UP or CONFIRMED_BREAK_UP often coincides
120
+ with price breaking above a STRONG resistance level. Confirm the break
121
+ by checking which resistance level was breached.
122
+
123
+ indicators.activity_ratio | MODULATES
124
+ Levels formed during high activity_ratio periods have higher volScore
125
+ (capped at 3.0). Levels formed in dead-volume sessions are inherently weaker.
126
+
127
+ --------------------------------------------------------------------------------
128
+ DEPENDENCY ORDER
129
+ --------------------------------------------------------------------------------
130
+ 1 Read indicators.resistance array; nearest levels first.
131
+ 2 Read indicators.support array; nearest levels first.
132
+ 3 For each level: check strength and bayesianStrength.
133
+ 4 Identify STRONG or polarity_flip levels near current price.
134
+ 5 Cross-reference with poc and vwap proximity.
135
+ 6 Gate interpretation with regime and hmi for directional context.
136
+
137
+ --------------------------------------------------------------------------------
138
+ INVALIDATION CONDITIONS
139
+ --------------------------------------------------------------------------------
140
+ IF activity_ratio < 0.5 AND the level was formed in the last 60 minutes
141
+ → Levels formed in dead-volume are low-quality. Bayesian strength will
142
+ be low; treat as WEAK regardless of touch count.
143
+
144
+ IF age of level > 25 hours AND timeWeight drops to 0.1
145
+ → Level is still in the array but has low effective weight. Verify
146
+ bayesianStrength is still >= 0.6 before treating as active.
147
+
148
+ IF market has gapped significantly (> 3% up or down) since level was formed
149
+ → Many historical levels below (upside gap) or above (downside gap) may
150
+ be in thin-trade zones. Bayesian strength may not reflect post-gap
151
+ behavior. Treat pre-gap levels with caution.
152
+
153
+ --------------------------------------------------------------------------------
154
+ ANTI-PATTERNS — DETECTABLE MISUSE CONDITIONS
155
+ --------------------------------------------------------------------------------
156
+ IF all levels in the support array are treated equally
157
+ → INCOMPLETE. Use strength (STRONG/MODERATE/WEAK) and bayesianStrength
158
+ to differentiate. Only STRONG levels with bayesianStrength >= 0.65
159
+ should be used for stop placement or significant position decisions.
160
+
161
+ IF a resistance level is treated as a hard cap regardless of regime
162
+ → INCORRECT. In CASCADE/BREAKOUT regimes, resistance levels are
163
+ commonly broken. bayesianStrength < 0.5 at a resistance level means
164
+ it is statistically more likely to break than hold under pressure.
165
+
166
+ IF the support array is assumed to always be non-empty
167
+ → INCORRECT ASSUMPTION. Dead zones, filter thresholds, and low-touch
168
+ periods can result in empty or short arrays. Handle empty array case
169
+ explicitly.
@@ -0,0 +1,165 @@
1
+ ================================================================================
2
+ INDICATOR: TF_ALIGNMENT — TIMEFRAME ALIGNMENT SCORE
3
+ ================================================================================
4
+ id: tf_alignment
5
+ data_field: indicators.tf_alignment
6
+ type: NUMERIC
7
+ range: 0.0 to 100.0
8
+ precision: 1 decimal place
9
+ update_rate: per_tick
10
+ latency_profile: COINCIDENT
11
+
12
+ --------------------------------------------------------------------------------
13
+ CONSTRUCT
14
+ --------------------------------------------------------------------------------
15
+ tf_alignment measures what percentage of short-term timeframe momentum is moving
16
+ in the same direction as the macro (longer-term) trend.
17
+
18
+ Computation:
19
+ STEP 1: Determine macro direction using 4h, 6h, 8h, 12h, 24h changes only.
20
+ macroDir = sign(sum of those 5 TF changes) ∈ {-1, 0, 1}
21
+
22
+ STEP 2: For each short TF [1m, 3m, 5m, 15m, 30m, 1h, 2h], compute the
23
+ magnitude-weighted contribution toward or against macroDir.
24
+
25
+ Weights applied per TF (decaying):
26
+ 1m: 1.00 | 3m: 0.95 | 5m: 0.90 | 15m: 0.85
27
+ 30m: 0.80 | 1h: 0.75 | 2h: 0.65
28
+
29
+ For each short TF:
30
+ contribution = |change| × weight
31
+ IF sign(change) == macroDir: adds to alignedWeight
32
+ always adds to totalWeight
33
+
34
+ value = (alignedWeight / totalWeight) × 100
35
+
36
+ Special case: IF all short TFs are near zero (totalWeight ≈ 0):
37
+ Fall back to sign-agreement count rather than magnitude weighting.
38
+
39
+ tf_alignment specifically measures whether SHORTER timeframes (1m–2h) are
40
+ agreeing with the LONGER timeframe direction (4h–24h). It does NOT measure
41
+ whether all 12 TFs agree with each other.
42
+
43
+ A value of 100 means every short TF is moving in the same direction as the
44
+ macro trend. A value of 0 means every short TF is moving against the macro.
45
+ A value of 50 means perfectly split.
46
+
47
+ --------------------------------------------------------------------------------
48
+ RANGE INTERPRETATION
49
+ --------------------------------------------------------------------------------
50
+ value > 85
51
+ Extreme alignment. Every short timeframe contribution is directionally
52
+ consistent with macro. Short-TF price action is fully confirming the
53
+ longer-term trend. Historically associated with CASCADE and BREAKOUT
54
+ regimes. Maximum breadth state.
55
+
56
+ value > 70 AND value <= 85
57
+ High alignment. Most short-TF magnitude agrees with macro. The trend
58
+ has broad participation from intraday timeframes. Strong confirmation
59
+ of macro direction from the shorter stack.
60
+
61
+ value > 55 AND value <= 70
62
+ Moderate alignment. Majority of short-TF weight is directionally aligned,
63
+ but meaningful dissent exists. Some shorter TFs are countertrending.
64
+ Likely reflects normal pullbacks or consolidation within an established trend.
65
+
66
+ value > 40 AND value <= 55
67
+ Low alignment. Roughly split between short TFs agreeing and disagreeing
68
+ with macro. Directional inference is unreliable. The short-TF stack is
69
+ not confirming OR refuting the macro trend.
70
+
71
+ value <= 40
72
+ Divergence. The short-TF stack is predominantly moving AGAINST the macro
73
+ direction. This can represent:
74
+ - A reversal forming at the short-TF level
75
+ - A countertrend move before macro reasserts
76
+ - Transition period between regimes
77
+ Do not use macro-aligned directional signals during this state.
78
+
79
+ --------------------------------------------------------------------------------
80
+ TRAJECTORY — RATE OF CHANGE
81
+ --------------------------------------------------------------------------------
82
+ # tf_alignment does not have its own velocity field in the data feed.
83
+ # Assess trajectory by comparing consecutive readings or using hmi_velocity
84
+ # as a proxy (they tend to move together at turns).
85
+
86
+ Rising tf_alignment (→ recent readings higher than prior)
87
+ Short TFs are converging toward macro direction.
88
+ Alignment is broadening. Associated with momentum building.
89
+
90
+ Falling tf_alignment (→ recent readings lower than prior)
91
+ Short TFs are diverging from macro direction.
92
+ Alignment is narrowing. Associated with momentum fading or pullback.
93
+
94
+ tf_alignment < 50 while hmi is still positive
95
+ Short TFs have turned against macro. HMI is lagging.
96
+ The current HMI value overstates current alignment state.
97
+
98
+ --------------------------------------------------------------------------------
99
+ INDICATOR RELATIONSHIPS
100
+ --------------------------------------------------------------------------------
101
+ indicators.hmi | AMPLIFIES
102
+ tf_alignment measures breadth; hmi measures magnitude.
103
+ These are different but complementary dimensions of the same stack.
104
+
105
+ IF hmi >= 60 AND tf_alignment >= 80
106
+ → Maximum signal quality. Both magnitude and breadth confirm direction.
107
+
108
+ IF hmi >= 60 AND tf_alignment < 50
109
+ → HMI has high weighted sum but short TFs are not broadly aligned.
110
+ The high magnitude is concentrated — likely the 1h/2h TFs are
111
+ dominant while others are flat or opposing. Reduce confidence.
112
+
113
+ IF hmi < 30 AND tf_alignment > 70
114
+ → High breadth but low magnitude. Many TFs agree on direction but
115
+ none have meaningful momentum yet. Low-energy directional state.
116
+
117
+ indicators.regime | CROSS_VALIDATE
118
+ CASCADE and BREAKOUT regimes imply tf_alignment should be >= 70.
119
+ IF regime = CASCADE_UP AND tf_alignment < 55:
120
+ → Data may be stale or the regime transition just occurred.
121
+ Monitor for convergence.
122
+
123
+ IF regime = CHOP AND tf_alignment is near 50:
124
+ → Expected. Both indicators consistently reflect disagreement.
125
+
126
+ indicators.directional_efficiency | COMPANION
127
+ tf_alignment measures directional breadth relative to macro.
128
+ directional_efficiency measures how cleanly price is moving in one
129
+ direction (low noise). They are complementary: high alignment +
130
+ high efficiency = strongest trending signal.
131
+
132
+ --------------------------------------------------------------------------------
133
+ DEPENDENCY ORDER
134
+ --------------------------------------------------------------------------------
135
+ 1 Regime: if CHOP/CONSOL/RANGING, macro direction is undefined; tf_alignment
136
+ near 50 is expected and uninformative.
137
+ 2 Read value and range bucket.
138
+ 3 Cross-validate with hmi for magnitude-breadth divergence.
139
+ 4 Assess recent trajectory (rising vs falling alignment) if consecutive
140
+ readings are available.
141
+
142
+ --------------------------------------------------------------------------------
143
+ INVALIDATION CONDITIONS
144
+ --------------------------------------------------------------------------------
145
+ IF regime = CHOP
146
+ → macroDir is undefined (sum of 4h-24h changes is near zero).
147
+ tf_alignment near 50 is expected and uninformative.
148
+
149
+ IF all TF changes are near zero (very low volatility / illiquid period)
150
+ → Magnitude weighting collapses to sign agreement. Result is noisy.
151
+ Cross-check with activity_ratio. If activity_ratio < 0.5: discard.
152
+
153
+ --------------------------------------------------------------------------------
154
+ ANTI-PATTERNS — DETECTABLE MISUSE CONDITIONS
155
+ --------------------------------------------------------------------------------
156
+ IF tf_alignment is used as a standalone direction signal
157
+ → INCORRECT USE. tf_alignment measures alignment WITH macro direction.
158
+ It cannot tell you what macro direction is. You must know macroDir
159
+ (from the 4h-24h cluster) separately before interpreting alignment
160
+ as bullish or bearish context.
161
+
162
+ IF tf_alignment of 80% is interpreted as "80% of timeframes are positive"
163
+ → INCORRECT INTERPRETATION. The percentage is MAGNITUDE-WEIGHTED alignment
164
+ with macro — not a head count of positive timeframes. A single 1h TF
165
+ with high magnitude can dominate the weighted result.
@@ -0,0 +1,98 @@
1
+ ================================================================================
2
+ INDICATOR: TREND_INTERPRETATION
3
+ ================================================================================
4
+ id: trend_interpretation
5
+ data_field: indicators.trend_interpretation
6
+ type: CATEGORICAL
7
+ values: STRONG | MODERATE | WEAK | RANGING_CHOPPY
8
+ update_rate: per_tick
9
+ latency_profile: COINCIDENT
10
+
11
+ --------------------------------------------------------------------------------
12
+ CONSTRUCT
13
+ --------------------------------------------------------------------------------
14
+ trend_interpretation is a categorical label derived from indicators.trend_strength
15
+ using fixed thresholds. It carries the same information as trend_strength in a
16
+ discrete format. See trend_strength.txt for the full mathematical construction.
17
+
18
+ Mapping:
19
+ trend_strength >= 60 → STRONG
20
+ trend_strength >= 40 → MODERATE
21
+ trend_strength >= 20 → WEAK
22
+ trend_strength < 20 → RANGING_CHOPPY
23
+
24
+ This indicator has NO direction. STRONG does not mean STRONG UPWARD — it means
25
+ the market is strongly moving in ONE direction. Use hmi or regime to determine
26
+ which direction that is.
27
+
28
+ --------------------------------------------------------------------------------
29
+ STATE DEFINITIONS
30
+ --------------------------------------------------------------------------------
31
+ STRONG
32
+ The directional imbalance across all weighted timeframe clusters is
33
+ significant (trend_strength >= 60). One direction dominates the
34
+ timeframe stack. Momentum strategies have a structural edge.
35
+
36
+ MODERATE
37
+ Notable directional imbalance exists (trend_strength 40-59) but is
38
+ not extreme. A trend is present and tradeable with reduced confidence.
39
+ Some countertrend TF activity is present.
40
+
41
+ WEAK
42
+ Faint directional bias only (trend_strength 20-39). Near-even balance
43
+ between up and down movement. Use directional indicators with caution.
44
+
45
+ RANGING_CHOPPY
46
+ Near-equal directional balance (trend_strength < 20). No meaningful
47
+ trend in any direction. Equivalent in implication to CHOP regime.
48
+ Discard momentum-based edge signals.
49
+
50
+ --------------------------------------------------------------------------------
51
+ INDICATOR RELATIONSHIPS
52
+ --------------------------------------------------------------------------------
53
+ indicators.trend_strength | SAME DATA
54
+ Always consistent. Use trend_interpretation for categorical branching
55
+ and trend_strength when numeric precision is needed (e.g., thresholds
56
+ within the MODERATE band).
57
+
58
+ indicators.regime | CROSS_VALIDATE
59
+ RANGING_CHOPPY state should co-occur with CHOP, CONSOL, or RANGING regime.
60
+ IF trend_interpretation = STRONG AND regime = CHOP
61
+ → Conflict. One is stale. Check timestamps and activity.
62
+ IF trend_interpretation = STRONG AND regime IN [CASCADE, BREAKOUT, TREND]
63
+ → Full agreement. Highest confidence trending condition.
64
+
65
+ indicators.hmi | CONTEXT
66
+ trend_interpretation indicates strength; hmi provides directional sign:
67
+ IF trend_interpretation = STRONG AND hmi > 40
68
+ → Strong directional trend to the upside.
69
+ IF trend_interpretation = STRONG AND hmi < -40
70
+ → Strong directional trend to the downside.
71
+ IF trend_interpretation = STRONG AND |hmi| < 20
72
+ → Trend strength diverges from hmi. Investigate which TF clusters
73
+ are driving trend_strength vs hmi to resolve.
74
+
75
+ --------------------------------------------------------------------------------
76
+ DEPENDENCY ORDER
77
+ --------------------------------------------------------------------------------
78
+ 1 Read state.
79
+ 2 RANGING_CHOPPY: momentum-based inference is not supported.
80
+ 3 Pair with hmi or regime for direction.
81
+ 4 Most informative when state is MODERATE or STRONG.
82
+
83
+ --------------------------------------------------------------------------------
84
+ INVALIDATION CONDITIONS
85
+ --------------------------------------------------------------------------------
86
+ Same as trend_strength. If activity_ratio < 0.5: discard.
87
+
88
+ --------------------------------------------------------------------------------
89
+ ANTI-PATTERNS — DETECTABLE MISUSE CONDITIONS
90
+ --------------------------------------------------------------------------------
91
+ IF STRONG state is interpreted as bullish
92
+ → INCORRECT. STRONG means one direction dominates — direction
93
+ unknown from this field alone. Pair with hmi direction.
94
+
95
+ IF WEAK is treated as "no edge"
96
+ → PARTIALLY CORRECT. Weak trend means reduced directional edge from
97
+ trend-following, but mean-reversion setups may still be valid.
98
+ Check vwap_zscore and S/R distance in WEAK states.