class EntryLine(bt.Indicator): lines = (‘entryprice’,) plotinfo = dict(subplot=False)…
- User
class EntryLine(bt.Indicator): lines = (‘entryprice’,) plotinfo = dict(subplot=False) plotlines = dict(entryprice=dict(ls=‘-’, lw=1, color=‘red’))
def init(self): self.addminperiod(self.data.size())
def prenext(self): self.lines.entryprice[0] = float(‘nan’)
def next(self): self.lines.entryprice[0] = float(‘nan’)
def set_entryprice(self, price): for index in range(-1, -self.data.size() - 1, -1): self.lines.entryprice[index] = price改成任意直接,传入的是K线的时间截和收盘价
- Assistant
class EntryLine(bt.Indicator): lines = ('entryprice',) plotinfo = dict(subplot=False) plotlines = dict(entryprice=dict(ls='-', lw=1, color='red'))
def __init__(self, time, price): self.time = time self.price = price super().__init__() def prenext(self): self.lines.entryprice[0] = float('nan') def next(self): self.lines.entryprice[0] = float('nan') def set_entryprice(self, time, price): time_index = self.data.datetime.date(-1).toordinal() - time.toordinal() if time_index >= -self.data.size(): self.lines.entryprice[time_index] = price
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.