系统四周有关回测与实盘问题

//------------------------------------------------------------------------

// 简称: DemoFourweekTrade

// 名称: 四周交易

// 类别: 策略应用

// 类型: 内建应用

// 输出: Void

//------------------------------------------------------------------------

//编写注意:与普通的交易策略相比,仅仅有两处不一样:

//            1、使用IsAllPickCondition()判断当前Bar是否满足选股表达式,pickCond = IsAllPickCondition();

//          2、开仓时加上是否选中的条件。pickCond[1]

Params

   Numeric money(100);  //开仓市值:单位万元

   Numeric length(20);  //四周的周期

   Numeric hcrate(15);     //价格回撤%

Vars

   Series<bool> pickCond; //是否满足选股表达式

   Series<Numeric> highline;

   Series<Numeric> lowline;

   Series<Numeric> buylasthigh(0,2);    //买持仓价格峰值

   Series<Numeric> selllastlow(0,2);    //卖持仓价格低谷

Events

   OnBar(ArrayRef<Integer> indexs)

   {

       Integer i = 0;

       range[i = 0:datacount-1]

       {

           //使用IsAllPickCondition()判断当前Bar是否满足选股表达式,

           pickCond = IsAllPickCondition();

           Numeric TempUnitMoney=Open/rollover*ContractUnit*BigPointValue;

           numeric lots=Round(10000*money/TempUnitMoney/baseshares,0)*baseshares;

           highline=Highest(High[1],length);

           lowline=Lowest(Low[1],length);

           if(MarketPosition==1 and Low<=buylasthigh*(1-0.01*hcrate) and buylasthigh>EntryPrice*(1+0.01*6))

               {Sell(0,Min(Open,buylasthigh*(1-0.01*hcrate)));Return;}

           if(MarketPosition==-1 and High>=selllastlow*(1+0.01*hcrate) and selllastlow<EntryPrice*(1-0.01*6))

               {BuyToCover(0,Max(Open,selllastlow*(1+0.01*hcrate)));Return;}

           If(MarketPosition<>1 And High>=highline and pickCond[1])   //在开仓的时候确认下是否被选中

               Buy(lots,Max(Open,highline));

           If(MarketPosition<>-1 And Low<=lowline)

               SellShort(0,Min(Open,lowline));

           If(MarketPosition==1)

           {

               If(BarsSinceEntry==0)

                   buylasthigh=EntryPrice;

               Else

                   buylasthigh=Max(High,buylasthigh);

           }

           If(MarketPosition==-1)

           {

               If(BarsSinceEntry==0)

                   selllastlow=EntryPrice;

               Else

                   selllastlow=Min(Low,selllastlow);

           }

       }

   }    

//问题如下------------------------------------------------------------------------

{Sell(0,Min(Open,buylasthigh*(1-0.01*hcrate)));Return;}这里的Min(Open,buylasthigh*(1-0.01*hcrate),用于策略研究的回测,当根先涨后跌触发了回撤止盈条件,会选择open价格,如果buylasthigh不是当根的最高下一根用它没问题。在实盘中这些就不是问题,但这样回测的数据影响如何能否告知,或者有更接近的办法也请告知。

实盘和回测的问题
【回测与实盘】- 跨公式分离策略信号产生和实盘委托处理的思路
回测和实盘问题
回测无信号闪烁,实盘中出现信号问题。
回测与实盘开仓价不一致
策略报告与实盘当日盈亏差异问题
回测报告的平仓价格是开盘价,实盘交易的平仓价格是突破价。请问如何回测不准的问题?
有关策略报告汇总问题
回测问题
实盘不触发的问题请教