交易开拓者sol策略源码

ool    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=MinMovePriceScale;//当前商品最小变动量当前商品的计数单位

    MyRealMp=GetGlobalVar(0); //获取MyRealMp全局变量值

    HighAfterlongEntry=GetGlobalVar(1);

    LowAfterShortEntry=GetGlobalVar(2);

    If(BarStatus==0 And (MyRealMp==InvalidNumeric||bInitStatus))  

    {MyRealMp=InitMyRealMp;}

    If(DateDate[1])

    {HighAfterlongEntry=High;

    LowAfterShortEntry=Low;

    MyRealMp=0;

    }Else

    {HighAfterlongEntry=Max(HighAfterlongEntry,High);

    LowAfterShortEntry=Min(LowAfterShortEntry,Low);}

    if (Time0 And HighAfterlongEntry-Low>=TrailingGridMinPoint And(High-Low=TrailingGridMinPoint And Close=TrailingGridMinPoint And (High-Low=TrailingGridMinPoint 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=(FirstGrid+MyRealMpAddGrid)MinPoint)//多单加仓

       {TmpPrice=Min(LowAfterShortEntry+(FirstGrid+MyRealMpAddGrid+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=(FirstGrid+Abs(MyRealMpAddGrid))MinPoint)//空单加仓

       {TmpPrice=Max(HighAfterLongEntry-(FirstGrid-Abs(MyRealMpAddGrid)-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;

       Sell(0,TmpPrice);

       MyRealMp=0;}

       If(MyRealMp<0)

       {TmpLots=Abs(MyRealMp*EveryLots);

       TmpPrice=Close;

       BuyToCover(0,TmpPrice);

       MyRealMp=0;}}

       SetGlobalVar(0,MyRealMp);

       SetGlobalVar(1,HighAfterLongEntry);

       SetGlobalVar(2,LowAfterShortEntry);

       Commentary("MyRealMp="+Text(MyRealMp));

       Commentary("HighAfterLLowAfterShortEntry="+Text(LowAfterShortEntry));

       End
交易技术, 交易策略, 源码



                                                    风险提示及免责条款

市场有风险,投资需谨慎。本文不构成个人投资建议,也未考虑到个别用户特殊的投资目标、财务状况或需要。用户应考虑本文中的任何意见、观点或结论是否符合其特定状况。据此投资,责任自负。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部