Skip to content

Instantly share code, notes, and snippets.

@tripolskypetr
Created March 10, 2026 07:09
Show Gist options
  • Select an option

  • Save tripolskypetr/e8f6fe3c004587704d6e63fd91d4c470 to your computer and use it in GitHub Desktop.

Select an option

Save tripolskypetr/e8f6fe3c004587704d6e63fd91d4c470 to your computer and use it in GitHub Desktop.
//@version=5
indicator("SuperTrend", overlay=true)
plotcandle(open, high, low, close,
color = close > open ? color.new(color.green, 70) : color.new(color.red, 70),
wickcolor = color.new(color.gray, 70),
bordercolor = color.new(color.gray, 70))
atrPeriod = input(10, "ATR Period")
factor = input(3.0, "Factor")
confirmBars = input.int(15, "Confirm Bars")
[supertrend, direction] = ta.supertrend(factor, atrPeriod)
dir = int(direction)
var int trend = 0
var int counter = 0
dirChanged = dir != trend
if dirChanged
counter := counter + 1
if counter >= confirmBars
trend := dir
counter := 0
else
counter := 0
// Серый пока набираем confirmBars, цвет как только подтвердили
lineColor = dirChanged and counter < confirmBars ? color.gray : dir < 0 ? color.green : color.red
plot(close, "SuperTrend", color = lineColor, linewidth = 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment