-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathSuper SuperTrend.pine
40 lines (34 loc) · 2.15 KB
/
Super SuperTrend.pine
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
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Zettt
// Inspired by this YouTube video: https://youtu.be/peCdKOcD8iM?t=143
//@version=4
study(title="Super SuperTrend", shorttitle="Super SuperTrend", overlay=true)
st1len = input(title="SuperTrend 1 Length", type=input.integer, defval=10)
st1mult = input(title="SuperTrend 1 Multiplier", type=input.integer, defval=1)
st2len = input(title="SuperTrend 2 Length", type=input.integer, defval=11)
st2mult = input(title="SuperTrend 2 Multiplier", type=input.integer, defval=2)
st3len = input(title="SuperTrend 3 Length", type=input.integer, defval=12)
st3mult = input(title="SuperTrend 3 Multiplier", type=input.integer, defval=3)
[st1, dir1] = supertrend(st1mult, st1len)
[st2, dir2] = supertrend(st2mult, st2len)
[st3, dir3] = supertrend(st3mult, st3len)
// plotting (optional and off by default)
// plotting st1
col1Resistance = dir1 == 1 and dir1 == dir1[1] ? color.new(color.maroon, 0) : color.new(color.maroon, 100)
col1Support = dir1 == -1 and dir1 == dir1[1] ? color.new(color.green, 0) : color.new(color.green, 100)
plot(st1, color = col1Resistance, linewidth=1, display=display.none)
plot(st1, color = col1Support, linewidth=1, display=display.none)
// plotting st2
col2Resistance = dir2 == 1 and dir2 == dir2[1] ? color.new(color.maroon, 0) : color.new(color.maroon, 100)
col2Support = dir2 == -1 and dir2 == dir2[1] ? color.new(color.green, 0) : color.new(color.green, 100)
plot(st2, color = col2Resistance, linewidth=1, display=display.none)
plot(st2, color = col2Support, linewidth=1, display=display.none)
// plotting st3
col3Resistance = dir3 == 1 and dir3 == dir3[1] ? color.new(color.maroon, 0) : color.new(color.maroon, 100)
col3Support = dir3 == -1 and dir3 == dir3[1] ? color.new(color.green, 0) : color.new(color.green, 100)
plot(st3, color = col3Resistance, linewidth=1, display=display.none)
plot(st3, color = col3Support, linewidth=1, display=display.none)
uptrend = dir1 == 1 and dir2 == 1 and dir3 == 1
downtrend = dir1 == -1 and dir2 == -1 and dir3 == -1
theBarColor = uptrend ? color.maroon : downtrend ? color.green : na
barcolor(color=theBarColor)