统计开仓后的最高低最低价
(
intra_trade_hight
intra_trade_low
)
源码的写法是不是有误
统计范围包括了成交前那一根k线了
def on_15min_bar(self, bar: BarData):
""""""
self.cancel_all()
am = self.am
am.update_bar(bar)
if not am.inited:
return
self.boll_up, self.boll_down = am.boll(self.boll_window, self.boll_dev)
self.boll_mid = am.sma(self.boll_window)
self.atr_value = am.atr(self.atr_window)
if self.pos == 0:
self.buy(self.boll_up, self.fixed_size, True)
self.short(self.boll_down, self.fixed_size, True)
self.intra_trade_high = bar.high_price
self.intra_trade_low = bar.low_price
elif self.pos > 0:
if bar.close_price <= self.boll_mid:
self.sell(bar.close_price - 5, abs(self.pos))
self.intra_trade_high = max(self.intra_trade_high, bar.high_price)
self.intra_trade_low = bar.low_price
self.long_sl = self.intra_trade_high - self.atr_value * self.atr_multiplier
self.sell(self.long_sl, abs(self.pos), True)
elif self.pos < 0:
if bar.close_price >= self.boll_mid:
self.cover(bar.close_price + 5, abs(self.pos))
self.intra_trade_low = min(self.intra_trade_low, bar.low_price)
self.intra_trade_high = bar.high_price
self.short_sl = self.intra_trade_low + self.atr_value * self.atr_multiplier
self.cover(self.short_sl, abs(self.pos), True)
self.put_event()