-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVolume_MA.tosts
More file actions
40 lines (32 loc) · 1.14 KB
/
Volume_MA.tosts
File metadata and controls
40 lines (32 loc) · 1.14 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
29
30
31
32
33
34
35
36
37
38
39
40
# Volume Based Coloured Bars
declare real_size;
declare on_volume;
input length = 21;
def avrg = SimpleMovingAvg(volume, length);
# Define conditions for downward volume and upward volume
def volDownCondition = close < open;
def volUpCondition = close > open;
# Define volume conditions
def highVolume = volume > avrg * 1.5;
def midVolume = volume >= avrg * 0.5 and volume <= avrg * 1.5;
def lowVolume = volume < avrg * 0.5;
# Define color conditions
def downHighVol = highVolume and volDownCondition;
def downMidVol = midVolume and volDownCondition;
def downLowVol = lowVolume and volDownCondition;
def upHighVol = highVolume and volUpCondition;
def upMidVol = midVolume and volUpCondition;
def upLowVol = lowVolume and volUpCondition;
# Assign colors based on conditions
plot Vol = volume;
Vol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Vol.SetLineWeight(4);
Vol.AssignValueColor(
if downHighVol then Color.RED
else if downMidVol then Color.DARK_RED
else if downLowVol then Color.DARK_RED
else if upHighVol then Color.UPTICK
else if upMidVol then Color.DARK_GREEN
else if upLowVol then Color.DARK_GREEN
else Color.CYAN
);