BitcoinCounterFlow
  • 차트
    마켓 차트All indicators in one place.
    대시보드Data-riched mini-charts.
    SuperChartAdvanced multi-panel view.
    OmniFlow 모델Market regime identification.
    청산 히트맵Identify liquidity clusters.
    ETF 추적기Wall Street capital flows.
  • 도구
    백테스트 및 모델Build your own quants.
    ScannerSearch historical triggers across timeframes.
    포지션 시그널AI-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.
    확장 프로그램Live data in your browser.
  • 리소스
    계산기Calculators and planning tools.
    리포트Monthly market analysis.
    학습Master the indicators.
    AcademyThe complete learning library.
    아티클Latest news and insights.
    ChangelogProduct updates and improvements.
    ClockWatchGlobal market sessions.
  • 커뮤니티
  • API
  • MCP
  • 가격

지표 만들기

모드
스타일
시그널 선
기준선
수평선으로 극단값(예: RSI 70/30)을 표시하세요. 지표가 선을 통과하면 가격 패널에 마커가 나타납니다.

0/4 사용자 지정 패널 활성

지표 보기캔들 로딩 중…
지표 스캐너
자산BTCUSDT
시간 간격
~0 candles
Opening market data channel06%
지표 결과
0 saved preview panels

차트 설정

테마
캔들 색상
선형 · 현지 · Pure Gray

내 지표

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.