修改ATR-RSI演示策略的仓位信号触发逻辑,避免出现仓位超过1时策略失去反应的情况
This commit is contained in:
parent
ab9d99d725
commit
c2a1a8be0c
@ -204,7 +204,7 @@ class AtrRsiStrategy(CtaTemplate):
|
||||
self.short(bar.close-5, 1)
|
||||
|
||||
# 持有多头仓位
|
||||
elif self.pos == 1:
|
||||
elif self.pos > 0:
|
||||
# 计算多头持有期内的最高价,以及重置最低价
|
||||
self.intraTradeHigh = max(self.intraTradeHigh, bar.high)
|
||||
self.intraTradeLow = bar.low
|
||||
@ -215,7 +215,7 @@ class AtrRsiStrategy(CtaTemplate):
|
||||
self.orderList.append(orderID)
|
||||
|
||||
# 持有空头仓位
|
||||
elif self.pos == -1:
|
||||
elif self.pos < 0:
|
||||
self.intraTradeLow = min(self.intraTradeLow, bar.low)
|
||||
self.intraTradeHigh = bar.high
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user