OPEN-SOURCE SCRIPT

FIL Grid Indicator [3Commas]

238
FIL Grid Indicator [3Commas]

🔷 What it does:
This is a signal-only indicator that mirrors a FIL / USDT price-grid workflow on a pre-defined ladder of levels between two fixed bounds. It tracks one virtual grid position at a time: when price crosses down through a level, the indicator opens one slot; when price subsequently crosses up through the level immediately above an owned slot, that slot is closed for a fixed round-trip profit. The grid is generated geometrically by default, so spacing adapts to the price scale. The indicator computes running average entry, deployed capital, open PnL, and lifetime realized PnL — all derived from honest fill-by-fill bookkeeping. Every fill and close emits a webhook-ready JSON alert payload tagged with the specific grid slot for direct DCA Bot consumption.
- Up to 36 simultaneous virtual long slots at default settings, each sized as a fixed fraction of the configured Total Investment.
- Geometric ladder with ~1.0% per step across the default 1.0151 / 0.7099 range (−30.07%).
- No trailing exit, no stop loss — each slot's exit is the level immediately above its entry.
- Per-slot reference exposure ~2.78% of equity at default settings.
- Honest virtual bookkeeping: avg entry, deployed capital, Open PnL, and cumulative realized net profit displayed live on the chart.

🔷 Who is it for:
- Swing traders harvesting volatility on FIL in range-bound regimes who want a chart-driven signal source.
- Bot operators looking for per-slot webhook JSON ready to drive a DCA Bot configured for grid execution.
- Range traders who prefer mechanical, level-based execution over discretionary entries.
- Traders who want strategy-tester-equivalent insight (live realized/unrealized PnL) without running a backtest engine.

🔷 How does it work:
Grid Construction: On script load, the indicator computes N price levels between the configured High and Low bounds. In Geometric mode (default), level k is at High × (Low/High)^(k/(N-1)), giving constant percent spacing — approximately 1.0% per step at default settings. In Arithmetic mode, levels are linearly spaced by absolute price.
Per-Slot Logic: Each grid level is an independent slot tracked by a boolean ownership flag. When bar close moves price down through an empty slot's level, the indicator marks a virtual long opened at that level for one slot's worth of capital (Investment / N) and dispatches its buy webhook. When bar close moves price up through the level immediately above an owned slot, that slot is closed, the round-trip profit between the two adjacent levels is realized, and the close webhook fires.
Honest Virtual Bookkeeping: Total cost and qty are updated incrementally on every event, so the avg entry, deployed capital, Open PnL, and realized net profit displayed in the status table reflect the actual broker-equivalent position state — no shortcut, no synthetic averaging.
Lifetime Realized PnL: Each closed slot accumulates its round-trip profit into a persistent counter. The status table displays both Open PnL (current unrealized state) and cumulative realized net profit (how much the grid has actually earned, in USDT and % of starting capital), so live performance is visible directly on the chart.
Capital Bounds: Total virtual deployed capital cannot exceed the configured Investment. When all 36 slots are filled, no new slots open until price rises and starts closing slots. This structural cap is the indicator's primary risk control.

🔷 Why it's unique:
- Per-Level Webhook Ledger: Every fill and close emits a fully-formed JSON alert payload tagged with the specific grid slot ("Grid_BUY_L5" / "Grid_TP_L5"). One TradingView alert with "Any alert() function call" drives a DCA Bot configured for grid emulation end-to-end, with each level tracked independently downstream.
- Pre-Allocated State: All up to 200 slot ledgers live in fixed-size arrays, so state lookups are constant-time and the chart can render every active slot with no performance overhead.
- Live PnL Tracking: Open PnL and cumulative realized net profit are displayed live on the chart — the indicator gives strategy-tester-equivalent insight without running a backtest.
- Calibrated for FIL 15m: Default bounds, level count, and step size are set against FIL's recent observed range. The 36-level geometric ladder gives roughly 1.0% per step — wide enough to clear taker fees on each round-trip, granular enough to keep catching 15m swings inside the range.

🔷 Considerations Before Using the Indicator:
Market Selection & Range Validity: Grid tools are most profitable in range-bound, mean-reverting markets. On strong directional trends below the configured Low, slots will keep loading as price falls and won't close until price reverses. The default High/Low (1.0151 / 0.7099) was set against FIL's recent observed range; update both whenever the regime changes.
Aggregate Drawdown: Per-slot reference risk is moderate (~2.78% of equity), but if price collapses below the Low bound, aggregate unrealized loss can grow further — the companion strategy's backtest reached a 15.13% maximum equity drawdown. Match the indicator's per-slot allocation and Investment to your bot's configuration to keep the avg-entry and PnL display honest.
No Stop Loss: There is no exit signal on adverse moves below the lowest grid level. Slots whose entry sits above current market simply wait until price comes back. Risk is structurally capped by the bounded per-slot allocation; if a hard exchange-side stop is required, configure it on the bot directly.
Cross Detection Granularity: Slot fills and closes are evaluated on bar close. A bar that spikes through a level and returns within the same bar may be missed by design — this matches realistic polling behavior and avoids over-signaling on intra-bar wicks.
Live vs Historical State: The virtual grid state is rebuilt from chart history each time the indicator is recompiled. If the indicator is added mid-deployment or the live bot diverges from the signal stream (manual interventions, partial fills), the indicator state may not match the live bot. Toggle the indicator off and on to reset.
Backtesting Note: This is an indicator, not a strategy. There is no built-in P&L tester — but the live realized-profit counter in the status table gives a running approximation. For full metrics over the reference ~13.8-month sample (1,294 closed trades, 57.96% win rate, 15.13% max drawdown, profit factor 1.434, +16.24% net return over May 1, 2025 – June 26, 2026), use the companion strategy version on identical parameters.

🔷 How to Use It:
🔸 Add the indicator to a 15m FIL / USDT chart.
🔸 Set the High and Low bounds to a range you expect FIL to respect, pick Geometric (default, recommended) or Arithmetic spacing, and set Grid Levels (7–200) and Total Investment to match your bot's configuration (the indicator's avg-entry and PnL display becomes meaningful when virtual sizing matches real sizing).
🔸 In the DCA Bot Webhook group, paste the Bot ID, Email Token, and Pair (QUOTE_BASE format, e.g., USDT_FIL).
🔸 Create an alert on the indicator with "Any alert() function call". Paste the DCA Bot's webhook URL into the alert's Webhook field. The indicator will emit a dedicated JSON payload for every grid-level buy and grid-level close, tagged with the slot index — formatted for direct DCA Bot consumption.

🔷 INDICATOR SETTINGS
High Price: Top of the grid. The highest level a slot can be created from.
Low Price: Bottom of the grid. The lowest level a slot can be created from.
Grid Levels: Number of price levels between High and Low (default 36, range 7–200).
Spacing Mode: Geometric (constant percent step) or Arithmetic (constant absolute step).
Total Investment (USDT): Total virtual capital allocated across all slots. Per-slot size = Investment / Grid Levels.
DCA Bot Webhook: Bot ID, Email Token, and Pair fields injected into every alert payload.
Visualization: Toggle grid lines, range box, HIGH/LOW labels, avg entry plot, fill labels, signal triangles, status table (shows range, levels, owned slots, investment, per-slot size, open PnL, and cumulative realized net profit).
Brand Watermark: Configurable text, position, size, and transparency.

👨🏻‍💻💭 We hope this tool helps enhance your trading. Your feedback is invaluable, so feel free to share any suggestions for improvements or new features you'd like to see implemented.

__
The information and publications within the 3Commas TradingView account are not meant to be and do not constitute financial, investment, trading, or other types of advice or recommendations supplied or endorsed by 3Commas and any of the parties acting on behalf of 3Commas, including its employees, contractors, ambassadors, etc.

כתב ויתור

המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.