The TV platform has an interesting Delta indicator for cluster analysis of candles:
enter image description here
I would like to make a small modification to the code and test it in my strategy, but it doesn’t work out for me.
The idea is to display above the candles the number of the cluster where the maximum volume was and the value of this volume (negative – sellers, positive buyers).
I found a place in the code where it determines in which cluster the maximum volume is located, who it belongs to, and paints this cluster in the desired color, highlighting it:
enter image description here
for i = 0 to array.size(calcCoord.finBox) - 1
var iTrack = .0
if array.get(finBoxFloat, i) >= 0
if matrix.get(calcCoord.value, i, 0) != matrix.get(calcCoord.value, i, 1)
box.set_bgcolor(array.get(calcCoord.finBox, i), color.from_gradient(array.get(finBoxFloat, i), matrix.get(calcCoord.value, i, 1),
matrix.get(calcCoord.value, i, 0),
color.new(c, 90), color.new(c, 10)))
else
box.set_bgcolor(array.get(calcCoord.finBox, i), color.new(c, 10))
if matrix.get(calcCoord.value, i, 0) >= math.abs(matrix.get(calcCoord.value, i, 2)) and iTrack != array.get(finBoxFloat, i)
if array.get(finBoxFloat, i) == matrix.get(calcCoord.value, i, 0)
box.set_border_color(array.get(calcCoord.finBox, i), c2)
iTrack := array.get(finBoxFloat, i)
else
if matrix.get(calcCoord.value, i, 2) != matrix.get(calcCoord.value, i, 3)
box.set_bgcolor(array.get(calcCoord.finBox, i), color.from_gradient(array.get(finBoxFloat, i),
matrix.get(calcCoord.value, i, 2), matrix.get(calcCoord.value, i, 3),
color.new(c1, 10), color.new(c1, 90)))
else
box.set_bgcolor(array.get(calcCoord.finBox, i), color.new(c1, 10))
if math.abs(matrix.get(calcCoord.value, i, 2)) >= matrix.get(calcCoord.value, i, 0) and iTrack != array.get(finBoxFloat, i)
if array.get(finBoxFloat, i) == matrix.get(calcCoord.value, i, 2)
box.set_border_color(array.get(calcCoord.finBox, i), c2)
iTrack := array.get(finBoxFloat, i)
namely in this block:
if math.abs(matrix.get(calcCoord.value, i, 2)) >= matrix.get(calcCoord.value, i, 0) and iTrack != array.get(finBoxFloat, i)
if array.get(finBoxFloat, i) == matrix.get(calcCoord.value, i, 2)
box.set_border_color(array.get(calcCoord.finBox, i), c2)
iTrack := array.get(finBoxFloat, i)
I tried to take ready-made data for the desired cluster from here and display it like this:
if math.abs(matrix.get(calcCoord.value, i, 2)) >= matrix.get(calcCoord.value, i, 0) and iTrack != array.get(finBoxFloat, i)
if array.get(finBoxFloat, i) == matrix.get(calcCoord.value, i, 2)
box.set_border_color(array.get(calcCoord.finBox, i), c2)
iTrack := array.get(finBoxFloat, i)
label.new(bar_index, high, str.tostring(array.get(finBoxFloat, i)), color=color.red, textcolor=color.white, style=label.style_label_down)
but this doesn’t work:
- not displayed on every candle
- shows the maximum volume and not the cluster number
I would take the data from here:
array.get(calcCoord.finBox, i)
but I can’t process the Box type and turn it into a float.
Please help me fulfill my plan. Thank you.