I have build an indicator ('A') that uses other indicators for calculate itself (B, C, D). However I see only the main indicator ('A') when printing, but I want to see also the other indicators (B, C, and D). I tried adding 'plotforce' and LinePlotterIndicator like written in https://www.backtrader.com/docu/induse/ without success...
Latest posts made by יהודה שפירא
plotting indicators that are inside another indicator
RE: help with indicators mark signals based on future data
so, it I change
self.lines.swingline[-self.mean_range] = -1
self.lines.swingline = -1
it is "valid" indicator (will signal in the current date about what happened in the past). no?
help with indicators mark signals based on future data
I am trying to build a strategy with indicators which do calculation and signal their own line in the "past". For example, I build a swing indicator (found it here in some question) which look like this:
class SwingInd(bt.Indicator): lines = ('swingline',) params = (('period', 5),) def __init__(self): self.swing_range = (self.params.period * 2) + 1 self.mean_range = self.params.period # this is needed to tell when there is enough data to start signaling self.addminperiod(self.swing_range) def next(self): # crude swing up highs = self.data.get(size=self.swing_range) lows = self.data.get(size=self.swing_range) if highs.pop(self.mean_range) >= max(highs): self.lines.swingline[-self.mean_range] = 1 elif lows.pop(self.mean_range) <= min(lows): self.lines.swingline[-self.mean_range] = -1 else: self.lines.swingline[-self.mean_range] = 0
and I see that its mark the self.lines.swingline[-self.mean_range] in the "past" with a val.
in my strategy I am looking at this indicator in the 'next' function with data (current) and check if should I buy/sell based on
if self.swing1 == -1/1: buy ....
but in order to self.swing1 to have values of 1/-1 it needs to have future data already in order to mark current as 'swing'. Am I wrong ? How should I use this indicators that need 'future' data to signal in the current 'next' ?