Anuj
Anuj

Reputation: 1

How to get the highest Volume value of 1 minute Time frame of the present day

I want a function that can identify the Highest volume bar of the present day in a 1-minute time frame. For that 1 minute candle, I want to change the candle stick color to say WHITE. If, later in the day again, a candle with higher volume forms than the previous volume, it should color that candle too. Now, the actual usage for Entries: This highest 1-minute volume value is the benchmark; if a candle stick with a volume above 50% of the highest volume forms, I'd like the color of the bar to change to Yellow; otherwise, the default. The entire calculation starts with a new session and ends with the session

I am new to Pine, I tried to do it, but I couldn't make a script due to its complexity.

This one I found here didn't work



indicator("highest daily volume", overlay = true)

var highest_volume = volume
var label_array = array.new_label(100000)

var index = 0

if ta.change(time("D"))
highest_volume := volume
array.set(label_array, index, label.new(bar_index, high, str.tostring(highest_volume)))
index += 1
else
highest_volume := math.max(highest_volume, volume)
if highest_volume != highest_volume[1]
    label.set_x(array.get(label_array, index - 1), bar_index)
plot(close)

Upvotes: 0

Views: 542

Answers (1)

vitruvius
vitruvius

Reputation: 21342

You need to use the request.security_lower_tf() to get the volume data from the 1-min timeframe.

request.security_lower_tf(symbol, timeframe, expression, ignore_invalid_symbol, currency) → array<type>

As you can see, it returns an array. So, you can call array.max() on the return value to find the maximum volume.

Upvotes: 0

Related Questions