策略无法平仓的问题
简单写了一个自动平仓策略,计划手动开仓后打开自动交易平仓。所以策略里面没有开仓信号,只有平仓信号。但实践后发现平仓信号无法触发,想问下哪个地方出现了问题。 Params Numeric FastLength(12); Numeric SlowLength(26); Numeric MACDLength(9); Vars Numeric fast; Numeric slow; Numeric MACDValue; Bool con1; Bool con2; Events OnBar(ArrayRef<Integer> indexs) { Range[DataSourceSize() - 1] { fast = XAverage( Close, FastLength ) - XAverage( Close, SlowLength ) ; slow = XAverage(fast,MACDLength); MACDValue = fast - slow; con1 = CrossOver(fast[1], slow[1]) con2 = CrossUnder(fast[1], slow[1]) If(con1 and marketposition==-1) { buytoCover(0, max(open, close)); //金叉平空 } If(con2 and marketposition== 1) { sell(0, min(open, close)); //死叉平多 } } }