I am trying to import the VWAP indicator from pandas_ta and test a simple strategy utilizing it with vectorbt. My code so far is:
import vectorbt as vbt
binance_data = vbt.BinanceData.load('ADABUSD_1m')
high = binance_data.get('High')
low = binance_data.get('Low')
close = binance_data.get('Close')
volume = binance_data.get('Volume')
vwap = vbt.pandas_ta('VWAP').run(high, low, close, volume, 14)
I am not sure if it works properly. When I run it it does not return any errors. Just a warning: "Converting to PeriodArray/Index representation will drop timezone information.".
Can I plot it somehow? "vwap.plot().show()" returns an error.
Assuming it works. How can I set an entry signal for when the closing price crosses above the VWAP line and exits for when it crosses below?
I tried:
entries = vwap.close_above(vwap)
exits = vwap.close_below(vwap)
But when I plotted with:
portfolio = vbt.Portfolio.from_signals(close, entries, exits, init_cash=1000)
portfolio.plot().show()
There were no trades. I use ".load" to get the data from a file I downloaded and saved first.