BitcoinCounterFlow
  • Grafik
    Grafik pasarAll indicators in one place.
    DasborData-riched mini-charts.
    SuperChartAdvanced multi-panel view.
    Model OmniFlowMarket regime identification.
    Peta panas likuidasiIdentify liquidity clusters.
    Pelacak ETFWall Street capital flows.
  • Alat
    Backtest & ModelBuild your own quants.
    ScannerSearch historical triggers across timeframes.
    Sinyal posisiAI-powered trade signals.
    Custom IndicatorsBuild Superchart indicators visually.
    ScriptingWrite and understand indicator scripts.
    Indicator ScannerRank indicators that read tops and bottoms.
    Anomaly DetectionExplore unusual Bitcoin market moves.
    EkstensiLive data in your browser.
  • Sumber
    KalkulatorCalculators and planning tools.
    LaporanMonthly market analysis.
    BelajarMaster the indicators.
    AcademyThe complete learning library.
    ArtikelLatest news and insights.
    ChangelogProduct updates and improvements.
    ClockWatchGlobal market sessions.
  • Komunitas
  • API
  • MCP
  • Harga

Buat indikator

Mode
Gaya
Garis sinyal
Garis referensi
Tandai nilai ekstrem (misalnya RSI 70/30) dengan garis horizontal. Penanda muncul di panel harga saat indikator melintasinya.

0/4 panel kustom aktif

Tampilan indikatorMemuat candlestick…
Pemindai indikator
AsetBTCUSDT
Kerangka waktu
~0 candles
Opening market data channel06%
Hasil indikator
0 saved preview panels

Pengaturan grafik

Tema
Warna candlestick
Linear · Lokal · Pure Gray

Indikator saya

Saving indicators to your account requires a Maxi plan or above. You can still build and copy the script.

Ask AI to write this for you

Copy this and paste it into ChatGPT, Claude, or any AI, then paste the JavaScript it gives you back into the editor on the left.

You are helping write a custom indicator script for BitcoinCounterFlow's Custom Indicators builder.

## Contract

You write the body of a JavaScript function that receives one argument, `api`, and must `return` an array of series.

- `api.candles`: array of candle objects, oldest first, one per bar. Every candle has `time` (unix seconds), `open`, `high`, `low`, `close`, `volume`, plus whichever of the fields below have data for the loaded window — a field can be missing on some candles, so check with `Number.isFinite(c.someField)` before using it.
- `api.log(...)`: prints to a debug console inside the app. Optional, for your own testing.
- Return an array of 1 or more series objects:
  `{ name: string, type: 'line' | 'histogram', color?: string, data: Array<number | null> }`
  `data` MUST have exactly one entry per candle, same order as `api.candles`. Use `null` for a gap (warmup, missing data) — never `0` or a made-up number as a stand-in for "no data".
- Plain JavaScript only: no `import`, no `require`, no `fetch`, no DOM or `window` access.

## Available candle fields

Price & Volume: close, open, high, low, volume, volumeUsd, price_change, volatility, drawdown, drawdown_cycle
Technical: rsi, atr, macd, macd_signal, macd_histogram, stoch_k, stoch_d, bbands_upper, bbands_middle, bbands_lower, bbands_pctb, bbands_bandwidth, sma20, sma50, sma200, rsi_divergence
Momentum & Volume: williams_r, cci, roc, trix, ao, adx, plus_di, minus_di, mfi, obv, adl, force_index
Trend & Channels: atr_pct, supertrend, supertrend_dir, psar, keltner_upper, keltner_middle, keltner_lower, donchian_upper, donchian_middle, donchian_lower, vwap, vwap_upper, vwap_lower
Cycle Tools: mayer_multiple, pi_cycle_gap, bmsb_mid, bmsb_distance, two_year_ma_mult, hash_ribbon_gap
Order Flow: taker_delta, taker_delta_pctl, cvd, cvd_change, taker_buy_ratio
Derivatives: funding_rate, funding_pctl, open_interest, oi_change, long_short_ratio, long_short_ratio_change, lsr_change_pctl, net_longs, net_longs_pctl, net_shorts, net_shorts_pctl, crowding
Liquidations: liquidations_long, liquidations_short, liquidations_total, liquidations_skew, liquidations_pctl, liquidations_long_pctl, liquidations_short_pctl, liquidations_streak
On-chain: mvrv, nupl, sopr, puell, vdd, hash_rate, hash_rate_pctl, realized_pl, realized_pl_pctl, dominance
Sentiment & Flow: fear_greed, google_trends, etf_inflow, etf_flow_pctl, etf_flow_streak
Macro & Cycle: m2, m2_change, dxy, dxy_change, cycle_phase, cycle_progress, cycle_year

### Example 1 — single field, moving average

return [{
  name: 'Funding SMA 20',
  type: 'line',
  data: api.candles.map((c, i) => {
    if (i < 19) return null;
    let sum = 0;
    for (let j = i - 19; j <= i; j++) {
      const v = Number(api.candles[j].funding_rate);
      if (!Number.isFinite(v)) return null;
      sum += v;
    }
    return sum / 20;
  })
}];

### Example 2 — two fields, two panels

return [
  {
    name: 'Close',
    type: 'line',
    data: api.candles.map((c) => (Number.isFinite(c.close) ? c.close : null))
  },
  {
    name: 'Funding Rate',
    type: 'histogram',
    color: '#e6c160',
    data: api.candles.map((c) => (Number.isFinite(c.funding_rate) ? c.funding_rate : null))
  }
];

## Task

Write a script that satisfies the contract above. Reply with ONLY the JavaScript code (no markdown fences, no explanation) — the body that goes where the examples' `return [...]` appears.