Compute cumulative volume from start of day


Category:
0
0

Hello, Im trying to turn these conditions for buying and selling volume into a two line plot study that adds upon itself (recursion) that starts over each market open. im sure I can figure out the recursion part but dont know how to start the study at the beginning op each session (ding ding ding).

def O = open;
def H = high;
def C = close;
def L = low;
def V = volume;
def buying = V * (C – L) / (H – L);
def selling = V * (H – C) / (H – L);

def Buyers = buying;

def Sellers = selling;

 

 

Marked as spam
Posted by (Questions: 11, Answers: 15)
Asked on August 11, 2021 7:26 pm
119 views
0
Private answer

There was a typo in your question title so I updated the title of your question to provide a bit more context about your request. This should help other viewers searching for this solution to locate it using the search function.

The code you included in your request is not fully functional. So I will provide my own fully functional chart study that demonstrates how to compute and plot cumulative volume for only the current trading session:

def currentDay = GetLastDay() == GetDay();
rec cummulativeVolume = if currentDay and !currentDay[1] then volume else if currentDay then cummulativeVolume[1] + volume else Double.NaN;
plot data = cummulativeVolume;

FYI, there are several examples of this technique used throughout this Q&A Forum. But I think this solution narrows the scope so that anyone familiar with thinkscript language will be able to easily apply this to their own projects.

Marked as spam
Posted by (Questions: 37, Answers: 4086)
Answered on August 12, 2021 7:32 am
0
I just cant reference my Buying condition correctly. Am I missing AbsValue maybe, Ive tried a few things. can ever return a value.. declare lower; def O = open; def H = high; def C = close; def L = low; def V = volume; def buying = V*(C-L)/(H-L); def currentDay = GetLastDay() == GetDay(); rec cummulativeBuying = if currentDay and !currentDay[1] then Buying else if currentDay then cummulativeBuying[1] + Buying else cummulativeBuying[1]; Plot Data = CummulativeBuying;
( at August 12, 2021 8:49 pm)
0
Your code works perfectly fine when I test it.
( at August 12, 2021 9:01 pm)
0
I.. cannot seem to get this to work. some tickers it works, but most it won't. For this last Friday (7,14,2021) ticker NOV reads out, but others on my scanners ..PFE F OXY RUN JKS won't return any data. ( I still need to test this when markets are open.. could be the issue?). All I see for most every stock, is the value line at 0, thats stops at the date change before today ( Friday.. its Saturday today). Im glad your getting it to work. Its something sill on my end ( probably me ). Thanks again!
( at August 14, 2021 5:29 pm)
0
You need to remove extended hours trade data from your charts.
( at August 14, 2021 7:59 pm)