Editor
Write the indicator you’re missing.
Start from a template, describe what you want, or convert a Pine script. Press Run and it draws on your chart.
BTC Main
ETH PerpsBINANCE.FBTCUSDT15m1h83,926.4+1.08%TradeIndicators 0/10Panels
BTCUSDTBitcoin
1h
1hO 84068.00H 84446.81L 83911.16C 83926.40-141.60 (-0.17%)
Vol 2.2K
SMA with a box 20 0.1583,558.50
82500.0082750.0083000.0083250.0083500.0083750.0084250.0084446.8182330.3383926.40
1112
SMA with a box
DocsRunOpen as window
1// The SMA lesson plus a shaded band: one box() per bar between two outputs.
2param.int("period",20, { min: 1,max: 200, label:"Period in bars" });
3param.number("band_pct", 0.15,{ min:0, max: 20,step: 0.05, label:"Band half-width in percent" });
4param.color("band_color", "#38bdf833", { label: "Band colour"});
5output("sma", line,overlay, {label:"Moving average" });
6const upper= output("upper", none);// the band's top edge
7const lower= output("lower", none);// the band's bottom edge
8const above= output("above", none);// 1 on bars where the close is above the average
9box("band", { top: upper,bottom: lower, when:above, from: -0.5, to:0.5, color: "@band_color", opacity:1, borderWidth: 0 });
10
11let sma =new Sma(20);
12let halfBand: f64 =0.01;
13
14function onStart():void { sma= new Sma(i32(p_period()));halfBand =p_band_pct()/ 100.0;}
15function onBar():void {
16const close= bar.close(); constvalue = sma.update(close);if (isNaN(value)) return;
17out_sma(value); out_upper(value *(1.0 +halfBand)); out_lower(value * (1.0 -halfBand));
18out_above(close >value ? 1.0: 0.0);
19}
1/101 slotLn 2, Col 23
CONSOLERESOURCES
› run “SMA with a box” on BTCUSDT · 1h
✓ Ready in 38 ms · 72 bars · 1 slot
PlusAgentsUTC14:48:417ms


