Back to Community
Adding VWAP and moving average into an intraday 1min candlestick plot

Hi, I've been struggling to find an answer for this, but if anyone can help, it would be very appreciable. I am looking to adding VWAP and exponential moving average (EMA) into an intraday 1min candlestick. I can't find any solution about adding VWAP and EMA in this community. Thank you so much in advance for your contribution. Attached is the code I have so far, credited to Daniel. I'd like to add VWAP and EMA on it.

Loading notebook preview...
3 responses

I'd suggest, Harry to search for VWAP and EMA in Quantopian Help to see what may work for you..

Cheers

Thank you for your reply. I tried, but couldn't figure it out... Do you know any reference?

Hi Harry,

I use a VWAP function on day's close and no EMA - not for 1min intervals - feel free to adapt for your purpose:

def getVWAP(ohlcv, bar): # OHLCV data in ascending order  
    avgPrice = (ohlcv['High'] + ohlcv['Low'] + ohlcv['Close']) / 3.0  
    if np.nansum(ohlcv['Volume'][:bar]) > 0:  
        return (avgPrice * ohlcv['Volume']).rolling(window=bar).sum() / (ohlcv['Volume']).rolling(window=bar).sum()  
    else: return (ohlcv['High'][-1] + ohlcv['Low'][-1] + ohlcv['Close'][-1]) / 3.0  

Hope this helps.