Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

pine script - How to learn volume changes sec by sec in a 1min candle at pinescript?

i am very new to pinescript. I have a very simple question.

I am watching 1min charts. The volume of 1mins charts changing between 100 - 300 I want to learn what was the exactly time when volume become 100

for example 1. candle become 100 volume at 25sec 2. candle become 100 volume at 59sec

or reverse question can we learn exactly volume for seconds changes ?

for example we are trying to find the volume at the 20th second of the 1min candle.

  1. candle has 35 volume in th 20th sec
  2. candle hans 55 volume in the 20th sec

is it possible ?

question from:https://stackoverflow.com/questions/65876997/how-to-learn-volume-changes-sec-by-sec-in-a-1min-candle-at-pinescript

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can see volume on the one second chart, though I can't speak to its accuracy. On the one minute chart, your script is executed per bar until the closing bar, and you cannot access lower timeframes.

On the current bar, it is possible to track the data, but as far as I know, not possible to commit or save the data. For example

//@version=4
study(title="My Indicator", overlay=false)
var int sec = 0

if barstate.isrealtime
    if barstate.isnew
        sec := 0
    if volume <= 100
        sec := (timenow - time) / 1000

plotchar(sec,'sec','')

You can see seconds increasing in the data window, but at the point of reaching volume this is reset to 0.

This is because prior to every execution of the realtime bar variables are rolled back. So as far as I know currently, your only option is to work with the 1 second timeframe and calculate volume per minute.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...