SetOrderMap2AppointedSymbol(symbols, multiples); ?
這個函數能不能在OnBar里使用,能不能多次使用。
如:
?Events
? ? onBar(ArrayRef<Integer> indexs)
? ? { ? ?
? ? //代碼正文
? ? //If(!CallAuctionFilter()) Return;
? ? symbols1 = fRollover[1][0];
?? ?symbols2 = fRollover[0][0];
?? ?multiples = 1;
? ? value1=xaverage(open,LengthShort)-xaverage(open,LengthLong); //value1是9周期指數移動平均減去45周期指數移動平均
? ? bias1=xaverage(value1,n); //bias1是value1的2周期平均
? ? bias=bias1[1];
? ??
? ? ma1=xaverage(open,LengthShort);
? ? ma2=xaverage(open,LengthLong);
? ??
? ? http://mp.weixin.qq.com/s/mddsIyfTK_IN3zn2ojoKaw?
? ??
? ? if (ma1[1]>=ma2[1] and MarketPosition==0 and Bias[2]>bias[1] and Bias[1] <Bias and Bias<BIASLength) //做多:condition1為真,倒數第二根k線的Bias變量>倒數第一根k線的Bias變量,倒數第一根k線的Bias變量<當前k線的Bias變量,Bias變量<6
? ??
? ? {
? ? ? ? SetOrderMap2AppointedSymbol(symbols2, multiples); ?? ?
? ? ?? ?Buy(0,open);//下一k線做多
? ? }
? ? if (ma1[1]<ma2[1])//平多:如果9周期指數移動平均下穿45周期指數移動平均
? ? {?
? ? ? ??
? ? ? ? sell (0,open); ?//下一k線平多
? ? }
? ??
? ? if (ma1[1]<=ma2[1] and MarketPosition==0 and Bias[2]<bias[1] and Bias[1] >Bias and Bias<BIASLength)//做空:condition2為真,倒數第二根k線的Bias變量<倒數第一根k線的Bias變量,倒數第一根k線的Bias變量>當前k線的Bias變量,Bias變量<6
? ? {
? ? ?? ?SetOrderMap2AppointedSymbol(symbols2, multiples);?
? ? ?? ?sellshort (0,open); //下一k線做空
? ? }
? ? if (ma1[1]>ma2[1])//平空:如果9周期指數移動平均上穿45周期指數移動平均
? ? {
? ? buytocover (0,open); //下一k線平空
? ? }
? ?If(GetDicTime(fRollover, 0) <> GetDicTime(fRollover, 1) And fRollover[0][1] <> InvalidString And fRollover[0][2] <> InvalidString) ? ? ? ? ? ?
?? ??? ??? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ??? ?PlotBool("換月", True);
?? ??? ??? ??? ??? ??? ??? ?//myRollover = rClose / Value(fRollover[0][2]);
?? ??? ??? ??? ??? ??? ??? ?Commentary("原合約收盤價:" + fRollover[0][1]);
?? ??? ??? ??? ??? ??? ??? ?Commentary("新合約收盤價:" + fRollover[0][2]);
?? ??? ??? ??? ??? ??? ??? ?Commentary("symbols:" + fRollover[1][0]);
?? ??? ??? ??? ??? ??? ??? ?Commentary("multiples:" + Text(multiples[1]));
?? ??? ??? ??? ??? ??? ??? ?
?? ??? ??? ??? ??? ??? ??? ?//Lots = Max(1, Round(CurrentContracts * Value(fRollover[0][1]) / Value(fRollover[0][2]),0));
? ? ? ? ? ? ? ? ? ? ? ? ? ??
?? ??? ??? ??? ??? ??? ??? ?If(MarketPosition == 1)
?? ??? ??? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ??? ??? ?SetOrderMap2AppointedSymbol(symbols1, multiples);
?? ??? ??? ??? ??? ??? ??? ??? ?Sell(0, Value(fRollover[0][1]),Enum_Signal_UnCorrectPrice);
?? ??? ??? ??? ??? ??? ??? ??? ?SetOrderMap2AppointedSymbol(symbols2, multiples);
?? ??? ??? ??? ??? ??? ??? ??? ?Buy(0, Value(fRollover[0][2]),Enum_Signal_UnCorrectPrice);
?? ??? ??? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ??? ??? ?Else If(MarketPosition == -1)
?? ??? ??? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ??? ??? ?SetOrderMap2AppointedSymbol(symbols1, multiples);
?? ??? ??? ??? ??? ??? ??? ??? ?BuyToCover(0, Value(fRollover[0][1]),Enum_Signal_UnCorrectPrice);
?? ??? ??? ??? ??? ??? ??? ??? ?SetOrderMap2AppointedSymbol(symbols2, multiples);
?? ??? ??? ??? ??? ??? ??? ??? ?SellShort(0, Value(fRollover[0][2]),Enum_Signal_UnCorrectPrice);
?? ??? ??? ??? ??? ??? ??? ?} ?
?? ??? ??? ? ? ? ? ? ??? ??
? ? }}
?