backtrader is an ecosystem and the indicators included in the package are tightly integrated in the platform. They are not TA-Lib like indicators/functions, which expose a call, take input buffers and parameters and return output buffers.
========================================== This is where the indicator is used. Can you please suggest?
params = (
def log(self, txt, dt=None):
''' Logging function fot this strategy'''
dt = dt or self.datas.datetime.date(0)
print('%s, %s' % (dt.isoformat(), txt))
# Keep a reference to the "close" line in the data dataseries
self.dataclose = self.datas.close
self.slope = toroOLS(period=20)
# Simply log the closing price of the series from the reference
self.log('Close, %.2f' % self.dataclose)
self.log('Slope, %.10f' % self.slope)
And will database such as sqlite be supported for storing data in the future?
backtrader has no provisions for data collection/storage. Nothing prevents collecting data from the on-line sources, but how to actually store it is entirely up to the user. The sources contain a tool called rewrite-data which simply takes one of the inputs and outputs a csv in the expected default format for backtrader. The same data could be written to an sqlite database with a simple schema.
Plotting a vertical line is actually not there, neither on the data nor on the indicator. Your best bets:
Having an observer plotting markers on the data based on the value of an indicator. The BuySell observer looks into buy/sell orders to plot the markers. This would allow you to plot on the data but would be the most ad-hoc solution.
Having an indicator plotting markers. For the markers you can look into the BuySell observer or the ParabolicSAR indicator. In your case and since you only want the marker when your indicator is 1, you only assign a value to the indicator when that's the case (and leave the 0 case untouched)
where there is no need to specify the (0), because the reference is implicit in the operation
Although @ntguardian is right and (1) points to the future, this can be used for real reasons. For example to push values from the future into the past as it is done in the Ichimoku indicator. For example:
for i in self.data1['Date'] and self.data2['Date']:
This seems to be a pandas-like syntax expectation. backtrader is not pandas. The expectation of your statement there is really a mistery here. Data feeds (like other lines objects) support integer indexing. See Docs - Platform Concepts