crowly001
crowly001

Reputation: 1

Calculation of volumes inside a candle

I'm trying to put together an indicator that would include several basic tools I need for analysis. I'm trying to assemble some kind of cluster by dividing the candle into equal parts and highlighting the location of the maximum delta volume on the candle. But it doesn't show up:

 // Volume profile length

length = 5

//Calculate the volumes inside the candle

upper_part_volume = sum(volume * (high == close ? 0.5 : close > high ? 1 : 0) / 3, length)
middle_part_volume = sum(volume * (high == close ? 0.5 : (low + high) / 2 > close and close > high ? 1 : 0) / 3, length)
lower_part_volume = sum(volume * (high == close ? 0.5 : low > close ? 1 : 0) / 3, length)


// Define the conditions for displaying points of different colors depending on the volume distribution inside the candle

yellow_dot_condition = upper_part_volume > middle_part_volume and upper_part_volume > lower_part_volume
blue_dot_condition = middle_part_volume > upper_part_volume and middle_part_volume > lower_part_volume
purple_dot_condition = lower_part_volume > upper_part_volume and lower_part_volume > middle_part_volume

// Draw a yellow dot if the yellow_dot_condition is met

plotshape(yellow_dot_condition ? low : na, style=shape.circle, location=location.abovebar, color=color.yellow, size=size.small)

// Draw a blue dot if the blue_dot_condition is met

plotshape(blue_dot_condition ? low : na, style=shape.circle, location=location.abovebar, color=color.blue, size=size.small)

// Draw a purple dot if the purple_dot_condition is met

plotshape(purple_dot_condition ? low : na, style=shape.circle, location=location.abovebar, color=color.purple, size=size.small)

Please help me fix the code? I think the variables upper_part_volume, middle_part_volume, lower_part_volume don't get numbers.

I expect to find where the maximum volume in the candle is.

Upvotes: 0

Views: 50

Answers (0)

Related Questions