开拓者期货期权程序化系统交易论坛

标题: 这个模型没有未来函数,为何有信号闪烁问题?请高手帮我改改。 [打印本页]

作者: 杨民    时间: 2013-1-29 18:44:33     标题: 这个模型没有未来函数,为何有信号闪烁问题?请高手帮我改改。

Params
    Bool    bInitStatus(false);//初始化标志,修改初始仓位时需设置为True
    Numeric InitMyRealMp(0);//初始当前仓位,正数表示多单,负数表示空单
    Numeric FirstGrid(10);//第一笔交易的间距,最小跳动
    Numeric AddGrid(30);//加仓间距,最小跳动
    Numeric TotalGrids(10);//最大交易次数
    Numeric TrailingGrid(10);//移动止损间距,最小跳动
    Numeric EveryLots(1);//每次开仓手数
    Numeric OffSet(1);//委托价偏差,默认买卖价偏差1个滑点
    Numeric ExitOnCloseMins(15.00);//收盘平仓时间
Vars
    Numeric HighAfterlongEntry;
    Numeric  LowAfterShortEntry;
    Numeric    MyRealMp(0);
    Numeric   MinPoint;
    Numeric  TmpPrice;
    Numeric   TmpLots;
Begin
    MinPoint=MinMove*PriceScale;//当前商品最小变动量*当前商品的计数单位
    MyRealMp=GetGlobalVar(0); //获取MyRealMp全局变量值
    HighAfterlongEntry=GetGlobalVar(1);
    LowAfterShortEntry=GetGlobalVar(2);
    If(BarStatus==0 And (MyRealMp==InvalidNumeric||bInitStatus))  
    {MyRealMp=InitMyRealMp;}
    If(Date<>Date[1])
    {HighAfterlongEntry=High;
    LowAfterShortEntry=Low;
    MyRealMp=0;
    }Else
    {HighAfterlongEntry=Max(HighAfterlongEntry,High);
    LowAfterShortEntry=Min(LowAfterShortEntry,Low);}
    if (Time<ExitOnCloseMins/100)
    {If(MyRealMp>0 And HighAfterlongEntry-Low>=TrailingGrid*MinPoint And(High-Low<TrailingGrid*MinPoint Or (High-Low>=TrailingGrid*MinPoint And Close<Open)))
      {TmpPrice=Max(HighAfterLongEntry-(TrailingGrid-OffSet)*MinPoint,Low);
      TmpLots=Abs(MyRealMp*EveryLots);
      Sell(TmpLots,TmpPrice);
      MyRealMp=0;
      LowAfterShortEntry=Low;
    }else
      If(MyRealMp<0 And High-LowAfterShortEntry>=TrailingGrid*MinPoint And (High-Low<TrailingGrid*MinPoint Or (High-Low>=TrailingGrid*MinPoint And Close>Open)))
      {TmpPrice=Min(LowAfterShortEntry+(TrailingGrid+OffSet)*MinPoint,High);
       TmpLots=Abs(MyRealMp*EveryLots);
       BuyToCover(TmpLots,TmpPrice);
       MyRealMp=0;
       HighAfterLongEntry=0;}
       If(MyRealMp==0 And High-LowAfterShortEntry>=FirstGrid*MinPoint)//第一笔多单开仓
       {TmpPrice=Min(LowAfterShortEntry+(FirstGrid+OffSet)*MinPoint,High);
       TmpLots=EveryLots;
       Buy(TmpLots,TmpPrice);
       MyRealMp=1;
       HighAfterLongEntry=High;
       }Else
       If(MyRealMp>0 And MyRealMp<TotalGrids And High-LowAfterShortEntry>=(FirstGrid+MyRealMp*AddGrid)*MinPoint)//多单加仓
       {TmpPrice=Min(LowAfterShortEntry+(FirstGrid+MyRealMp*AddGrid+OffSet)*MinPoint,High);
       TmpLots=EveryLots;
       Buy(TmpLots,TmpPrice);
       MyRealMp=MyRealMp+1;
       }else
       If(MyRealMp==0 And HighAfterLongEntry-Low>=FirstGrid*MinPoint)//第一笔空单开仓
       {TmpPrice=Max(HighAfterLongEntry-(FirstGrid-OffSet)*MinPoint,Low);
       TmpLots=EveryLots;
       SellShort(TmpLots,TmpPrice);
       MyRealMp=-1;
       LowAfterShortEntry=Low;
       }else
       If(MyRealMp<0 And -1*MyRealMp<TotalGrids And HighAfterLongEntry-Low>=(FirstGrid+Abs(MyRealMp*AddGrid))*MinPoint)//空单加仓
       {TmpPrice=Max(HighAfterLongEntry-(FirstGrid-Abs(MyRealMp*AddGrid)-OffSet)*MinPoint,Low);
       TmpLots=EveryLots;
       SellShort(TmpLots,TmpPrice);
       MyRealMp=MyRealMp-1;}
       }else
       If(Time>=ExitOnCloseMins/100)
       {If(MyRealMp>0)
       {TmpLots=Abs(MyRealMp*EveryLots);
       TmpPrice=close[1];
       Sell(0,TmpPrice);
       MyRealMp=0;}
       If(MyRealMp<0)
       {TmpLots=Abs(MyRealMp*EveryLots);
       TmpPrice=close[1];
       BuyToCover(0,TmpPrice);
       MyRealMp=0;}}
       SetGlobalVar(0,MyRealMp);
       SetGlobalVar(1,HighAfterLongEntry);
       SetGlobalVar(2,LowAfterShortEntry);
       Commentary("MyRealMp="+Text(MyRealMp));
       Commentary("HighAfterLLowAfterShortEntry="+Text(LowAfterShortEntry));
       End





作者: zhoubinbo8    时间: 2013-1-29 22:23:48

条件中存在类似 Close<Open 这样的条件,在实盘中 此条件是变化的;会导致信号消失
作者: 杨民    时间: 2013-1-30 10:34:24

那如何改呀?
作者: JPMorgan    时间: 2013-2-5 13:43:41

杨民 发表于 2013-1-30 10:34
那如何改呀?

你先说下你的思路吧,close < open 的
作者: flyfish    时间: 2013-2-5 14:34:50

把所有判断close和open关系的都用close[1]和open[1]代替
作者: JPMorgan    时间: 2013-2-5 22:10:08

flyfish 发表于 2013-2-5 14:34
把所有判断close和open关系的都用close[1]和open[1]代替

这个未必是他的真实意思的表达的
作者: 小水滴    时间: 2013-2-9 15:26:28

这个模型我正在研究,导致信号闪烁的原因很多,并不一定是模型中引用了未来函数这一种,可能是引用了实时行情数据等原因。
作者: 天崖    时间: 2013-2-11 18:43:44

有哪位高手,帮助把1#的交易模型修改一下啊~~~~~~~~~~~~~~~~~~~~~
作者: 仲孝    时间: 2013-2-18 19:44:55

这个模型问题很大的,截拳道上面的,用了很多的现价指令
作者: TRANS-AM    时间: 2013-2-18 23:00:29

仲孝 发表于 2013-2-18 19:44
这个模型问题很大的,截拳道上面的,用了很多的现价指令

一般没什么问题又好用的模型不会有人发源码出来的
作者: Lxq_lxq    时间: 2013-2-27 21:36:06

close就相当于未来函数
作者: 天崖    时间: 2013-2-27 22:29:00

一般没什么问题又好用的模型不会有人发源码出来
作者: faseman886    时间: 2015-4-13 09:43:29

这个模型问题是很大




欢迎光临 开拓者期货期权程序化系统交易论坛 (http://bbs.tb18.net/) Powered by Discuz! X2