How to plot arbitrary values?
-
I'm calculating support/resistance on X period close prices.
I'd like to plot this on the output chart and i saw the code from here, but I believe backtrader is looking for time series data for this to work.
import backtrader as bt import backtrader.indicators as btind class SR_Indicator(bt.Indicator): lines = ('sr',) def __init__(self): self.lines.sr = self.data
In strategy init:
self.tf_0_sr = [ 0.15112, 0.15332, .....] self.lower_tf_sr = SR_Indicator(self.tf_0_sr)
(Doesn't work)
-
How would I plot arbitrary horizontal lines on the output chart?
-
If i have two supports and resistances (one for each time frame I'm analyzing), how do I indicate the right indicator for the right time frame? This is how I added /resampled the data
df = csv_to_pandas(args.data, timeframe=bt.TimeFrame.Minutes) #convert bid / ask to OHLC
base_data = bt.feeds.PandasData(dataname=df, timeframe= bt.TimeFrame.Minutes) #1 minute
cerebro.adddata(base_data )cerebro.resampledata(base_data, timeframe=bt.TimeFrame.Minutes, compression=15) #15 minutes
-
-
@Taewoo-Kim said in How to plot arbitrary values?:
- How would I plot arbitrary horizontal lines on the output chart?
See Docs - Plotting and
plothlines
and/orplotyticks
under Object-wide plotting options. You can find examples in theStochastic
andRSI
indicators.- If i have two supports and resistances (one for each time frame I'm analyzing), how do I indicate the right indicator for the right time frame? This is how I added /resampled the data
There is context (sample code) missing for a real answer, but the guess if you have to specifically tell the indicator with which data it has to work, either
data0
ordata1
(seems you only have 2 data feeds) -
Thank you. Will give it a try