커뮤니티
수식 부탁드립니다
지표식, 시스템식 부탁 드립니다.
//──────────────────────────────
// INPUTS
//──────────────────────────────
length = input.int(12, "Trend Length")
multATR = input.float(0.3, "ATR Multiplier", step = 0.1)
//──────────────────────────────
// FUNCTION
//──────────────────────────────
calc_mb_avg(len) =>
o = ta.ema(open, len)
c = ta.ema(close, len)
h = ta.ema(high, len)
l = ta.ema(low, len)
haclose = (o + h + l + c) / 4
haopen = na(haclose[1]) ? (o + c) / 2 : (haclose[1] + (o + c) / 2) / 2
hahigh = math.max(h, math.max(haopen, haclose))
halow = math.min(l, math.min(haopen, haclose))
h2 = ta.ema(hahigh, len)
l2 = ta.ema(halow, len)
(h2 + l2) / 2
//──────────────────────────────
// ATR
//──────────────────────────────
atr_value = ta.sma(ta.atr(200), 200) * multATR
//──────────────────────────────
// BAND
//──────────────────────────────
mb_avg = calc_mb_avg(length)
sma_high = mb_avg + atr_value
sma_low = mb_avg - atr_value
//──────────────────────────────
// TREND LOGIC
//──────────────────────────────
var bool trend = na
if ta.crossover(close, sma_high) and barstate.isconfirmed
trend := true
if ta.crossunder(close, sma_low) and barstate.isconfirmed
trend := false
trend_value = trend ? sma_low : sma_high
//──────────────────────────────
// TREND LINE
//──────────────────────────────
plot(trend ? trend_value : na, title="UpTrend", style=plot.style_linebr, color=trend ? color.green : na, linewidth=2)
plot(not trend ? trend_value : na, title="DownTrend", style=plot.style_linebr, color=not trend ? color.red : na, linewidth=2)
//──────────────────────────────
// SIGNAL MARKERS
//──────────────────────────────
signal_up = ta.change(trend) and not trend[1]
signal_down = ta.change(trend) and trend[1]
sigUp = signal_up ? low - atr_value * 2 : na
sigDn = signal_down ? high + atr_value * 2 : na
plotshape(sigUp, "", shape.triangleup, location.absolute, color.green, size=size.small)
plotshape(sigDn, "", shape.triangledown, location.absolute, color.red, size=size.small)