麻烦解答一下
如图所示,试着写了一个策略,即均线金叉后,价格发生回调(K线低点降低)时,确立前高。当后续价格突破前高时,开仓做多。以回调的最低点做为止损点。很明显,写出来的策略明显是不对的,突破价位不对,止损价位也是不对的。Vars //此处添加变量 Series<Numeric> fast_ema; Series<Numeric> slow_ema; Series<Numeric> Highprice; //记录最高价 Series<Numeric> Lowprice; //记录最低价 Series<Numeric> breakout_price; //需要突破的价格 Series<Numeric> breakdown_price; //需要跌破的价格 Global Numeric StopLossprice; //止损价格 Series<Bool> condition_long(False); Series<Bool> condition_short(False); fast_ema = XAverage(Close,fast_ema_length); slow_ema = XAverage(Close,slow_ema_length); PlotNumeric(ema1,fast_ema); PlotNumeric(ema2,slow_ema); condition_long = CrossOver(fast_ema,slow_ema) and fast_ema[1]>fast_ema[2] and slow_ema[1]>=slow_ema[2];IF(condition_long) { long_trade=0; highprice=highest(high,5); //Lowprice=lowest(low,2); } If(fast_ema[1]>slow_ema[1]) { //long_count=long_count+1; Highprice=max(Highprice[1],high); Lowprice=lowest(low,2); If(Lowprice[1]<Lowprice[2]) { breakout_price=Highprice[1]; } } Else breakout_price=0; //开多 If(MarketPosition==0 and long_trade[1]==0 and breakout_price[1]!=0) { If(High[2]<breakout_price[1] and High[1]>breakout_price[1]) { Buy(lots,open); long_trade=1; StopLossprice=lowest(Lowprice,2); } } //平多 If(MarketPosition>0) { //止损 If(Close[1]<=StopLossprice) { Sell(lots,open); } //止盈 If(Close[1]<slow_ema[1] and Close[2]>slow_ema[2]) { Sell(lots,open); } }求大神解答一下,谢谢!