@battlegrid/mcp-server 31.2.5 → 31.2.7

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.
@@ -1,250 +0,0 @@
1
- # TradingView ports — popular scripts, translated to the studio
2
-
3
- The most-used TradingView community scripts encode processes traders already trust. This file
4
- ports the **process** of each — regime filter → setup state → trigger → stop/exit engine — onto
5
- the studio's validated vocabulary. It never claims formula parity: where an indicator does not
6
- exist in the catalog, the substitution is named (the studio's rule: offer the nearest
7
- expressible thing **labelled as a substitute**, never as the thing itself). Headers below were
8
- validated live on 2026-08-28; re-discover before compiling.
9
-
10
- **Event columns caveat (read first).** `crossDetect` and event metrics (`MACD_cross`,
11
- `EMA5_13`) print `Bullish`/`Bearish` only on the bar a cross occurs and are null otherwise —
12
- null resolves a clause UNRESOLVED, not FALSE. Use them as *triggers* inside a carrier, and pair
13
- them with a persistent *state* (the spread's sign, `MAalign`) for regime, exactly as the source
14
- scripts separate trigger from filter.
15
-
16
- ## 0 · Daily-chart strategies — the pattern that carries every TV daily script
17
-
18
- Most TradingView strategies run on the daily chart. The studio's anchors top out intraday
19
- (discovery's `timeframes`), but **pinned timeframes** carry the daily thesis onto any anchor:
20
- `{abs: "1d"}` columns are valid wherever discovery's `rankedTimeframes` includes `1d`
21
- (validated), render with a `_1d` header suffix (`MAalign_1d`, `dist_SMA200_1d`, `RSI14_1d`),
22
- and ignore anchor retunes. Two dials make the port faithful:
23
-
24
- - **`offset: 1` on a pinned `value` column reads the last CLOSED daily bar** (`RSI14[t - 1]`,
25
- validated) — the strategy's daily inputs then change exactly once per daily close, so a
26
- required condition on them decides "on daily closes" even though the anchor cycle re-checks
27
- intraday. Offset 0 reads the forming daily bar (marked provisional).
28
- - **A 4h anchor's regime rung is the daily** (ladder successor), so `{rel: "regime"}` columns
29
- (`MAalign_htf`) and the `htf_*` signals already evaluate on 1d for 4h strategies.
30
-
31
- Recipe: anchor 4h → pinned-1d thesis section (trend, RSI, distance-to-MA at `offset: 1`) →
32
- `required: true` daily conditions gating every carrier → anchor-rung columns only for entry
33
- timing and risk. The result is arguably stronger than the TV original: decisions bind to daily
34
- closes while stops, trailing, and time decay keep managing the position intraday.
35
-
36
- ## Expressibility triage
37
-
38
- | TradingView script | Verdict | Port anchor |
39
- |---|---|---|
40
- | Squeeze Momentum [LazyBear] / TTM Squeeze | **Direct port** — `KC_SQUEEZE` reads the state itself | `KC_SQUEEZE`, `bollinger_squeeze` |
41
- | Supertrend / UT Bot Alerts | **Direct port** for the state; flip still substituted | `ST_LINE`, `ST_DIR`, `EMA5_13` for the flip, position-management trailing |
42
- | Chandelier Exit | Direct port of the *mechanism* | trailing from entry (`trailingTriggerR: 0`) |
43
- | MACD + 200 MA filter | Direct process port | `MACD_cross`, `dist_SMA200`, `macd_bull_cross` |
44
- | Golden / Death Cross | Direct process port | `SMA50_SMA200_spread` + `_trend` |
45
- | RSI-2 (Connors) | **Direct port** — `RSI2` is native | `RSI2`, `dist_SMA200`, time decay |
46
- | VWAP reversion | Direct process port | `dist_VWAP`, `dist_VWAP_rank_far` |
47
- | Donchian / Turtle breakout | Process port (N-bar channel → swing structure) | `zone`, `dist_swingHi`, `sr_resistance_break` |
48
- | ICT/SMC: FVG + Order Blocks | Direct process port of the zone logic | `STRUCT_ZONES` columns + `structure_*` signals |
49
- | WaveTrend, QQE, Hull Suite, Ichimoku, Parabolic SAR, Keltner | **All native since contract 46.1** — port directly | `WT1`/`WT2`, `QQE_RSI_MA`/`QQE_STOP`, `HMA20`, `ICHI_*`, `PSAR`, `KC_*` |
50
-
51
- ---
52
-
53
- ## 1 · Squeeze Momentum [LazyBear] (TTM Squeeze) — 4h
54
-
55
- **Source process.** Squeeze ON while Bollinger Bands sit inside Keltner Channels (volatility
56
- coiled); wait; when the squeeze releases, enter in the direction of the momentum histogram.
57
-
58
- **Port.** Keltner Channels are native (`KC_UPPER`/`KC_MID`/`KC_LOWER`), so the squeeze is the
59
- source's own definition: `BB_UPPER spread KC_UPPER` negative AND `BB_LOWER spread KC_LOWER`
60
- positive is bands-inside-Keltner. The board-relative proxy below remains serviceable but is no
61
- longer the only option — it substitutes
62
- *cross-sectional and absolute* Bollinger compression — a stricter, universe-aware read:
63
- `bbWidthPct_rank_lo lte 10` AND `ADX lt 20` as the `SQUEEZE_ON` building block. Momentum
64
- direction comes from the MACD histogram trajectory (`MACD_now gt 0` with `MACD_trend rising`
65
- for longs) instead of the LazyBear linreg histogram. Release = expansion bar with
66
- participation: `RVOL gte 1.5` and `pctB` beyond 0.85 / 0.15. This is Playbook 1
67
- (`playbooks.md`) — it *is* the LazyBear process under studio vocabulary; keep
68
- `bollinger_squeeze` at Critical-required (its `bandwidthPct` param is the absolute half of the
69
- detection) and `volatility_atr_expanding` as the release confirmation.
70
-
71
- ## 2 · Supertrend / UT Bot Alerts — 1h/4h
72
-
73
- **Source process.** An ATR-offset trailing line flips below/above price; entries on the flip,
74
- and the line itself is the stop for the life of the trade.
75
-
76
- **Port — the key insight: the studio's stop engine is native, not an indicator.** What the
77
- Pine script simulates with a plotted line, position management executes: enable trailing with
78
- `trailingTriggerR: 0` (trail from entry — the Supertrend/UT Bot behavior), `giveback` as the
79
- ATR-offset analog (30–40 tight like factor-2 Supertrend, 45–55 loose like factor-3), plus the
80
- stop band (`minStopLossAtrMultiple`/`max…`) bounding the initial distance. The *flip entry*
81
- is native: `ST_DIR` carries the direction and `ST_LINE` the plotted stop. **`ST_DIR` is a
82
- persisting state, not a flip event** — it reads the same on every bar of a trend, so the FLIP
83
- itself still needs an event column beside it. The named substitute for the flip is a trend-state
84
- change:
85
- `MAalign is "bullish"` (state) with the `EMA5_13 is "Bullish"` cross event as the trigger, and
86
- `ma_ema_bull_cross` / `ma_ema_aligned_bull` Critical/Important-required in `rules`. Say the
87
- substitution out loud when presenting the strategy.
88
-
89
- ```json
90
- "trailingEnabled": true, "trailingTriggerR": 0, "trailingGivebackPct": 35,
91
- "trailingBufferPct": 0.2, "breakEvenEnabled": false
92
- ```
93
-
94
- ## 3 · Chandelier Exit — any persona
95
-
96
- **Source process.** Stop trails the highest high since entry minus `3 × ATR(22)`; never widens.
97
-
98
- **Port.** Pure position-management mapping — trail from entry with a giveback sized to the
99
- chandelier distance: `trailingTriggerR: 0`, `trailingGivebackPct` ~45–55 (a 3×ATR pullback on
100
- a typical setup surrenders roughly half its open run — tune against the previewed `atrPct`),
101
- `maxStopLossAtrMultiple` near the structural cap so the initial stop can sit chandelier-wide.
102
- The studio stop also never widens; time decay stays off (chandelier gives trends room).
103
-
104
- ## 4 · MACD + 200 MA filter — 4h (the classic trend-following combo)
105
-
106
- **Source process.** Only long while price is above the 200-period average; enter on a MACD
107
- bullish cross; mirror for shorts below.
108
-
109
- **Port.** Regime as a required building block, cross as the carrier's trigger:
110
-
111
- ```json
112
- [
113
- { "conditionKey": "ABOVE_200", "name": "Above the 200 SMA",
114
- "definition": { "kind": "clause", "column": { "sectionKey": null, "header": "dist_SMA200" }, "op": "gt", "value": 0 },
115
- "verdict": null, "required": false },
116
- { "conditionKey": "MACD_LONG", "name": "MACD bull cross in uptrend",
117
- "definition": { "kind": "group", "op": "ALL", "members": [
118
- { "kind": "conditionRef", "conditionKey": "ABOVE_200" },
119
- { "kind": "clause", "column": { "sectionKey": null, "header": "MACD_cross" }, "op": "is", "label": "Bullish" } ] },
120
- "verdict": "UP", "required": false }
121
- ]
122
- ```
123
-
124
- Columns: `SMA200 distance` → `dist_SMA200`; `MACD crossDetect` → `MACD_cross` (event — TRUE
125
- only on the crossing bar, otherwise UNRESOLVED; that momentariness is faithful to the source,
126
- which also only fires on the cross). Rules: `macd_bull_cross`/`macd_bear_cross` 3 required ·
127
- `ma_sma200_above`/`ma_sma200_below` 2 required · `trend_adx_trending` 1. Gates ~0.6 / 2.
128
- Swing-trend geometry (1–2.5 ATR, RR 2, trail late).
129
-
130
- ## 5 · Golden Cross / Death Cross regime book — 4h position
131
-
132
- **Source process.** SMA50 crossing above SMA200 defines the bull regime; below, the bear.
133
-
134
- **Port.** The spread composition gives both the *state* (sign) and the *freshness* (trend):
135
- `SMA50 spread SMA200 × trajectory w4` → `SMA50_SMA200_spread_now` (>0 = golden regime) and
136
- `SMA50_SMA200_spread_trend` (`rising` = the cross is developing, not decaying). Carrier:
137
- `GOLDEN` verdict UP = `spread_now gt 0` AND `trend is "rising"`; add a market-breadth gate —
138
- the always-addressable `mktBreadth_crypto gte 0` (net % of the crypto field closing up) keeps
139
- the book out of single-name traps. Rules: `ma_sma200_above` 3 required, `ma_ema_aligned_bull`
140
- 2, `htf_ma_aligned_bull` 2. Position persona: wide stops (1.5–2.5 ATR), RR 2, trail
141
- 1.5R/giveback 50.
142
-
143
- ## 6 · RSI-2 (Larry Connors) — 1h mean reversion
144
-
145
- **Source process.** In an uptrend (close > 200 SMA), buy panic dips (RSI(2) < 10); exit fast
146
- (cross of the 5-period average / a few bars).
147
-
148
- **Port — direct.** `RSI2` is native as of contract 49.2, so this ports exactly and no substitution
149
- note is owed. `DIP_BUY` verdict UP = `dist_SMA200 gt 0` (ref a required `ABOVE_200`) AND
150
- `RSI2 lte 10`. Keep the literal `lte 10` as the gate: `RSI2 × classifyZone` exists and reads on the
151
- same Connors 10/90 bands, but a zone label is a fixed reading while the literal is a threshold the
152
- author can see and tune.
153
- Rules: `rsi_oversold` 3 required `{"threshold": 25}` (RSI14 gate tuned toward the fast-dip
154
- regime — read the signal schema first) · `ma_sma200_above` 2 required · `bollinger_lower_touch`
155
- 1. The source's fast exit is time, not price: `timeDecayEnabled: true`, grace 180, interval
156
- 60, tighten 15 → max 50, stale 20 — the studio's honest port of "if it hasn't bounced in a few
157
- bars, leave". RR 1.2–1.5, stops 1.5–2.5 ATR (dips need room), break-even 0.8R.
158
-
159
- ## 7 · VWAP reversion — 15m/1h intraday
160
-
161
- **Source process.** Fade stretches away from session VWAP back toward it; stand aside when the
162
- stretch is trend, not noise.
163
-
164
- **Port.** `VWAP distance` → `dist_VWAP` (signed %); the board-relative stretch is
165
- `VWAP distance × rank far` → `dist_VWAP_rank_far lte 5` (top-5 most stretched either way).
166
- `FADE_TO_VWAP` verdict from the sign: DOWN when `dist_VWAP gte 2` and `RSI14 gte 65`; UP when
167
- `dist_VWAP lte -2` and `RSI14 lte 35`; veto trend days with a required
168
- `NOT [ADX_state in ["trending","extreme"]]`. Rules: `rsi_overbought`/`rsi_oversold` 2 each,
169
- `bollinger_upper_touch`/`lower_touch` 2, `cvd_bear_divergence`/`bull_divergence` 1. Scalp
170
- geometry + aggressive time decay (VWAP reversion is a session trade — the anchor resets daily
171
- at 00:00 UTC, which the column's own gloss states).
172
-
173
- ## 8 · Donchian / Turtle breakout — 4h
174
-
175
- **Source process.** Buy the N-bar-high breakout, ride with a wide trailing stop, exit on the
176
- opposite channel.
177
-
178
- **Port.** The catalog's structural highs replace the fixed N-bar channel: `zone is
179
- "breakout high"` (price beyond the tracked swing high) with `dist_swingHi gte 0` as the
180
- numeric confirmation, `RVOL gte 1.5` for participation, and `sr_resistance_break` 3 required
181
- in rules (its own params define the break). Turtle exits are the trend preset: stops 1.5–2.5
182
- ATR, RR 2+, trail from 1R with giveback 50, no time decay. Mirror with `"breakdown low"` /
183
- `dist_swingLo` / `sr_support_break` for shorts. **Daily variant on any anchor:** pin the same
184
- structure at 1d — `zone_1d is "breakout high"`, `dist_swingHi_1d gte 0` (both validated) —
185
- which is the studio's daily-breakout condition. That pins the tracked *daily swing* pivot. For
186
- the literal previous-session extreme instead, author `PDH`/`PDL` directly — both are native
187
- structure metrics at the daily anchor, and both take `distance` and `crossDetect`, so
188
- `dist_PDH_1d gte 0` or a `crossDetect` on `PDH` expresses the prior-day break exactly. Pick by
189
- which level the source actually means; neither is a substitution for the other.
190
-
191
- ## 9 · ICT / Smart Money Concepts: FVG + Order Blocks — 15m/1h
192
-
193
- **Source process.** Establish higher-timeframe bias; wait for price to return into a fair
194
- value gap or order block aligned with that bias; enter on the reaction, stop beyond the zone.
195
-
196
- **Port — the zone half is native.** `STRUCT_ZONES` *is* the platform's FVG/order-block engine:
197
- `zones_htf_support_type` (`bullish FVG` / `bullish order block`), `zones_htf_support_dist`
198
- (signed %; support below price is negative — `between -1.5 0` = sitting on the zone),
199
- `zones_htf_support_age_h gte 12` (a standing zone, not the last move's shadow). Bias =
200
- `MAalign_htf is "bullish"` as a required building block. Carrier: bias + in-zone + a tape
201
- quorum (`N_OF(2)`: `buyPres gte 0.55`, `RVOL gte 1.2`, `closeChg gt 0`). Rules:
202
- `structure_fvg_approach` / `structure_ob_approach` 3/2 required (their `proximityPct` params
203
- are the "in the zone" dial), `structure_zone_confluence` 2, `sr_at_support` 2. Stops: tight
204
- band (0.5–1.5 ATR) — the zone's far edge is the invalidation, and the studio places stops by
205
- ATR/structure natively. **A grammar limit, not a missing metric** — a clause compares one column
206
- against a literal, so an ordered sequence of events has no expressible form at all: liquidity
207
- sweeps, displacement legs,
208
- killzone clocks, and Turtle-Soup false-break sequencing (ordering between events is outside
209
- the grammar) — offer this zone-reaction port as the nearest expressible neighbor, labelled.
210
-
211
- ## Now native — do not substitute for these
212
-
213
- WaveTrend (`WT1`/`WT2`), QQE (`QQE_RSI_MA`/`QQE_STOP`), Hull (`HMA20`), Ichimoku
214
- (`ICHI_CONV`/`ICHI_BASE`/`ICHI_SPAN_A`/`ICHI_SPAN_B`/`ICHI_LAG`), Parabolic SAR (`PSAR`), Keltner
215
- (`KC_UPPER`/`KC_MID`/`KC_LOWER`), daily pivots (`PIVOT_P`/`PIVOT_R1`–`R3`/`PIVOT_S1`–`S3`),
216
- Williams %R (`WILLR14`), Stochastic RSI (`STOCH_RSI14`), Bollinger boundaries
217
- (`BB_UPPER`/`BB_LOWER`), ADX components (`DI_PLUS`/`DI_MINUS`). All arrived with contract 46.1 —
218
- every one of them was listed as inexpressible in this file before it.
219
-
220
- Contract 49.2 did it again with seven more: Connors RSI-2 (`RSI2`, and `RSI2 × classifyZone` on its
221
- own 10/90 bands), the TTM squeeze state (`KC_SQUEEZE`), the 9/21/50 EMAs (`EMA9`/`EMA21`/`EMA50`)
222
- and the prior-day levels (`PDH`/`PDL`). Two of those were standing absence claims in this file:
223
- RSI-2 was called a named substitute, and the prior-day levels were said to need a grammar form no
224
- metric could supply — true of the `distance` offset it cited, and never a reason a PUBLISHED level
225
- could not exist. Author the prior-day levels at `1d` and nowhere else: a level computed from the
226
- prior daily bar has no reading on a 15-minute one, and construction refuses it rather than
227
- resolving empty.
228
-
229
- Re-read the absence section against the vendored digest before trusting any row in it. That check
230
- is `skill-contract.test.ts`, and it is the only thing that catches a claim which raises no error
231
- and merely tells a paying author their strategy cannot be built.
232
-
233
- ## Not expressible — the catalog keys this needs
234
-
235
- The one section where a claim that the catalog LACKS something may live, and every row names the key
236
- it denies so the claim stays checkable. A claim about the grammar's SHAPE (a clause compares one
237
- column against a literal; `distance` rejects an `offset`) is permanent and belongs in prose above.
238
- A claim that a metric is absent belongs here, or nowhere.
239
-
240
- Only a bare backticked key counts as the claim — write the neighbour as a column code or an
241
- expression, never as a lone key, or the row denies a metric that is in fact served.
242
-
243
- | Script / primitive | Key the catalog would need | Nearest expressible neighbour |
244
- |---|---|---|
245
- | Slow-baseline trend filters (100-period) | `SMA100` | `dist_SMA50` or `dist_SMA200`, whichever the source's horizon is nearer |
246
- | 200-period EXPONENTIAL baseline | `EMA200` | `dist_SMA200`. Deferred on measurement, not preference: at the platform's warmup floor an exponential 200 still carries 12.4% of its seed bar while a simple 200 is exact over the same window |
247
- | Prior-WEEK high/low | `PWH` / `PWL` | the prior-DAY levels at the daily anchor, or `zone_1w` structure |
248
-
249
- Never compile a "port" of these under the source's name without the substitution note — a
250
- player who asked for WaveTrend and silently got Stochastic has no way to learn otherwise.