You are on page 1of 1

instrument { name = "Eng+Supertrend", overlay = true }

period = input (10, "front.period", input.integer, 1)


multiplier = input (3, "front.newind.multiplier", input.double, 0.01, 100, 0.01)

input_group {
"front.ind.dpo.generalline",
up_color = input { default = "#25E154", type = input.color },
down_color = input { default = "#FF6C58", type = input.color },
width = input { default = 1, type = input.line_width }
}

offset = rma (tr, period) * multiplier

up = hl2 - offset
down = hl2 + offset

trend_up = iff (not na(trend_up) and close [1] > trend_up [1], max (up, trend_up
[1]), up)
trend_down = iff (not na(trend_down) and close [1] < trend_down [1], min (down,
trend_down [1]), down)

trend = iff (close > trend_down [1], true, iff (close < trend_up [1], false,
nz(trend [1], true)))
tsl = iff (trend, trend_up, trend_down) -- supertrend line

plot (tsl, "Supertrend", trend () and up_color or down_color, width)

Buy = open[1] > close[1] and open < close and open <= close[1] and close > open[1]
and close > tsl
Sell = open[1] < close[1] and open > close and open >= close[1] and close < open[1]
and close < tsl

plot_shape(Buy, "Buy", shape_style.arrowup, shape_size.huge, "green",


shape_location.belowbar, 0, "", "green")
plot_shape(Sell, "Sell", shape_style.arrowdown, shape_size.huge, "red",
shape_location.abovebar, 0, "", "red")

You might also like