-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathtrend.lua
More file actions
28 lines (21 loc) · 1.09 KB
/
trend.lua
File metadata and controls
28 lines (21 loc) · 1.09 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
instrument { name = "Supertrend", overlay = true }
period = input (7, "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)
print(trend)
print(trend_up)
print(trend_down)
--plot_shape(trend_up - trend , "long", shape_style.triangleup, shape_size.large, 'green', shape_location.belowbar,0,'BUY', 'green')
plot (tsl, "Supertrend", trend () and up_color or down_color, width)