Hello everyone,

I'd like to implent VWAP in my algorithm and I'm wondering about two things.

On my trading platform I can apply VWAP to a chart without specifying anything else. I think it's calculated from the beginning of every day as a cumulative indicator. I'd like to have the same VWAP in my algorithm. What should I take as a time period? Is it even possible to do it as on my platform?

I've tried to implent VWAP using a dictionary for the values of each stock I want to trade as I do with my rolling windows but something is not working. If I log it there is a value for VWAP but when I change

if (last_bar > 0 and second_bar > 0 and third_bar > 0 and last_min_open < last_close):

to

if (last_bar > 0 and second_bar > 0 and third_bar > 0 and last_min_open < vwap < last_close):

I get an error "Cannot get managed object". What am I doing wrong?

Attached is the working version of the algorithm without the change.

Thank you in advance!

Kind regards,

Christian Lauer

Author