-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.pinescript
More file actions
46 lines (35 loc) · 2.79 KB
/
main.pinescript
File metadata and controls
46 lines (35 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// © sergejos
//@version=6
indicator("EMA ± ATR Channel (True Range) — with Inputs & Help", shorttitle="EMA ± ATR Channel", overlay=true)
// ── Inputs ────────────────────────────────────────────────────────────────────
emaLength = input.int(20, "EMA Length", minval=1,
tooltip="EMA period for the channel midline. Shorter = more responsive, longer = smoother.\n\nTips:\n• 10–20 for volatile/short-term\n• 20–50 for swing\n• 50–200 for trend context")
atrLength = input.int(14, "ATR Length", minval=1,
tooltip="ATR lookback (Wilder’s ATR based on True Range). Shorter = reacts to recent spikes; longer = steadier widths.")
atrMult = input.float(2.0, "ATR Multiplier", minval=0.1, step=0.1,
tooltip="How wide the channel is relative to ATR.\nCommon: 1.5–2.5 for high-volatility names.")
showHelp = input.bool(false, "Show Practical Combos help panel",
tooltip="Toggle to show/hide the ‘Practical Combos for Volatile Stocks’ cheat sheet on the chart.")
// ── Core Calculations (True Range ATR) ────────────────────────────────────────
emaMid = ta.ema(close, emaLength)
atrTR = ta.atr(atrLength) // Wilder’s ATR using True Range
upper = emaMid + atrMult * atrTR
lower = emaMid - atrMult * atrTR
// ── Plots ────────────────────────────────────────────────────────────────────
plot(emaMid, "EMA Mid", color=color.yellow, linewidth=2)
pU = plot(upper, "Upper (EMA + ATR×Mult)", color=color.new(color.green, 0))
pL = plot(lower, "Lower (EMA - ATR×Mult)", color=color.new(color.red, 0))
fill(pU, pL, color=color.new(color.blue, 85), title="Channel Fill")
// ── Practical Combos Help Panel ──────────────────────────────────────────────
var table helpTbl = na
helpText = "Practical Combos for Volatile Stocks:\n" +
"• EMA 20 + ATR 14 × 2.0 → most common swing trading setup.\n" +
"• EMA 10 + ATR 14 × 1.5 → very responsive, good for intraday/high-beta names.\n" +
"• EMA 20 + ATR 20 × 2.5 → smoother, wider channel, helps avoid whipsaws in chaotic stocks."
if barstate.isfirst
helpTbl := table.new(position.bottom_right, 1, 1, border_width=1)
if barstate.islast
if showHelp
table.cell(helpTbl, 0, 0, helpText, text_color=color.white, text_size=size.small, bgcolor=color.new(color.blue, 0))
else
table.cell(helpTbl, 0, 0, "") // hide contents when toggled off