-
Notifications
You must be signed in to change notification settings - Fork 51
/
Volume Supply and Demand Zones Indicator
105 lines (93 loc) · 5.81 KB
/
Volume Supply and Demand Zones Indicator
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//@version=3
//
// GitHub: https://github.com/Heavy91/TradingView_Indicators
//
// TradingView: https://www.tradingview.com/u/Heavy91/#published-scripts
//
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// If you like my work, you can support me with a donation:
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// €: http://pinescripts.fetchapp.com/sell/d15d4740
//
// $: http://pinescripts.fetchapp.com/sell/0f9153a5
//
// BTC: bc1q8e4wav3t55plp6ar0xc7gh4uqrzlxc7g97ywrg
//
// LTC: ltc1qagcys3pyluke3xdlq94qx8p7fd3z3mj2w32grs
//
// ----------------------------------------------------------------------------
// Volume Supply and Demand Zones
// ----------------------------------------------------------------------------
// Draws supply and demand zones based on 3 different volume threshold parameters.
// The timeframe of the script is fixed (you can change it in the options),
// e.g. it is possible to keep Daily S/D zones while looking at 1h chart.
study(title="Volume Supply and Demand Zones", shorttitle="Vol S/D Zones V1", precision=0, overlay=true)
def_color_big = aqua
def_fill_color_big = aqua
def_color_mid = aqua
def_fill_color_mid = teal
def_color_small = aqua
def_fill_color_small = navy
TF = input(title="Timeframe (W, D, [minutes])", type=string, defval="D")
length = input(5, minval=1)
change = volume/volume[1] - 1
stdev = stdev(change, length)
difference = change / stdev[1]
signal = abs(difference)
Threshold_big = input(15, title="Threshold_Big_Vol")
Threshold_mid = input(10, title="Threshold_Mid_Vol")
Threshold_small = input(5, title="Threshold_Small_Vol")
//-----------------------------------------------------------------------------------------
leveluphi_big = security(tickerid, TF, valuewhen(signal > Threshold_big,high[1],0))
leveluplo_big = security(tickerid, TF, valuewhen(signal > Threshold_big,low[1],0))
p1 = plot(leveluphi_big,style=circles,color=def_color_big)
p2 = plot(leveluplo_big,style=circles,color=def_color_big)
fill(p1,p2,color=def_fill_color_big,transp=70)
leveluphi_big2 = security(tickerid, TF, valuewhen(signal > Threshold_big,high[1],1))
leveluplo_big2 = security(tickerid, TF, valuewhen(signal > Threshold_big,low[1],1))
p12 = plot(leveluphi_big2,style=circles,color=def_color_big)
p22 = plot(leveluplo_big2,style=circles,color=def_color_big)
fill(p12,p22,color=def_fill_color_big,transp=70)
leveluphi_big3 = security(tickerid, TF, valuewhen(signal > Threshold_big,high[1],2))
leveluplo_big3 = security(tickerid, TF, valuewhen(signal > Threshold_big,low[1],2))
p13 = plot(leveluphi_big3,style=circles,color=def_color_big)
p23 = plot(leveluplo_big3,style=circles,color=def_color_big)
fill(p13,p23,color=def_fill_color_big,transp=70)
leveluphi_big4 = security(tickerid, TF, valuewhen(signal > Threshold_big,high[1],3))
leveluplo_big4 = security(tickerid, TF, valuewhen(signal > Threshold_big,low[1],3))
p14 = plot(leveluphi_big4,style=circles,color=def_color_big)
p24 = plot(leveluplo_big4,style=circles,color=def_color_big)
fill(p14,p24,color=def_fill_color_big,transp=70)
//-----------------------------------------------------------------------------------------
leveluphi_mid = security(tickerid, TF, valuewhen((signal > Threshold_mid)and(signal <= Threshold_big),high[1],0))
leveluplo_mid = security(tickerid, TF, valuewhen((signal > Threshold_mid)and(signal <= Threshold_big),low[1],0))
p3 = plot(leveluphi_mid,style=circles,color=def_color_mid,transp=65)
p4 = plot(leveluplo_mid,style=circles,color=def_color_mid,transp=65)
fill(p3,p4,color=def_fill_color_mid,transp=70)
leveluphi_mid2 = security(tickerid, TF, valuewhen((signal > Threshold_mid)and(signal <= Threshold_big),high[1],1))
leveluplo_mid2 = security(tickerid, TF, valuewhen((signal > Threshold_mid)and(signal <= Threshold_big),low[1],1))
p32 = plot(leveluphi_mid2,style=circles,color=def_color_mid,transp=65)
p42 = plot(leveluplo_mid2,style=circles,color=def_color_mid,transp=65)
fill(p32,p42,color=def_fill_color_mid,transp=70)
leveluphi_mid3 = security(tickerid, TF, valuewhen((signal > Threshold_mid)and(signal <= Threshold_big),high[1],2))
leveluplo_mid3 = security(tickerid, TF, valuewhen((signal > Threshold_mid)and(signal <= Threshold_big),low[1],2))
p33 = plot(leveluphi_mid3,style=circles,color=def_color_mid,transp=65)
p43 = plot(leveluplo_mid3,style=circles,color=def_color_mid,transp=65)
fill(p33,p43,color=def_fill_color_mid,transp=70)
leveluphi_mid4 = security(tickerid, TF, valuewhen((signal > Threshold_mid)and(signal <= Threshold_big),high[1],3))
leveluplo_mid4 = security(tickerid, TF, valuewhen((signal > Threshold_mid)and(signal <= Threshold_big),low[1],3))
p34 = plot(leveluphi_mid4,style=circles,color=def_color_mid,transp=65)
p44 = plot(leveluplo_mid4,style=circles,color=def_color_mid,transp=65)
fill(p34,p44,color=def_fill_color_mid,transp=70)
//------------------------------------------------------------------------------------------------
leveluphi_small = security(tickerid, TF, valuewhen((signal > Threshold_small)and(signal <= Threshold_mid),high[1],0))
leveluplo_small = security(tickerid, TF, valuewhen((signal > Threshold_small)and(signal <= Threshold_mid),low[1],0))
p5 = plot(leveluphi_small,style=circles,color=def_color_small,transp=70)
p6 = plot(leveluplo_small,style=circles,color=def_color_small,transp=70)
fill(p5,p6,color=def_fill_color_small,transp=70)
leveluphi_small2 = security(tickerid, TF, valuewhen((signal > Threshold_small)and(signal <= Threshold_mid),high[1],1))
leveluplo_small2 = security(tickerid, TF, valuewhen((signal > Threshold_small)and(signal <= Threshold_mid),low[1],1))
p52 = plot(leveluphi_small2,style=circles,color=def_color_small,transp=70)
p62 = plot(leveluplo_small2,style=circles,color=def_color_small,transp=70)
fill(p52,p62,color=def_fill_color_small,transp=70)
//-------------------------------------------------------------------------------------------------------