您现在的位置:程序化交易>> 期货公式>> 交易开拓者(TB)>> 开拓者公式>>正文内容

K线追踪_1Hour交易策略[开拓者公式]

此模型收益不高,盈亏比还可以,但是,模型包含了,止损,浮动阶段回撤止盈。此模型没有包含资金开仓管理,下一个公开的将包含,加仓、减仓,止盈、止损等内容,等下一篇再细说吧,废话不多说,源码如下:
源码后有模型设置方法,不过,有些图线可以去掉,自行处理吧

希望转载引用此文的童鞋们将此文的链接一并复制,并记住新浪上有一个叫“金融疯子”的王童鞋

 

//------------------------------------------------------------------------
// 简称: Sanxian2  金融疯子 分享
// 名称: 三线2
// 类别: 公式应用
// 类型: 用户应用
// 输出: 代编模型QQ 1145508240
//------------------------------------------------------------------------

Params
    Numeric TakePoint0(62);
Vars
    Numeric Lots(1);
 Numeric LossPoint;
    NumericSeries times;
    Numeric ZSPrice;
    NumericSeries BasedpriceUp;
 NumericSeries Basedpricedown;
 NumericSeries Basedprice;
 Numeric HighDDPrice;
 Numeric LowDprice;
 NumericSeries DownLineK;
 NumericSeries UpLineK;
 NumericSeries KZhu;
 NumericSeries KZhu0;
 Numeric EndTime;
    Numeric BarsSToday;
 NumericSeries RedK;
 NumericSeries GreenK;
 NumericSeries YellowK;
 NumericSeries BuyHighAfterEntry;
 NumericSeries SellHighAfterEntry;
 NumericSeries LowAfterEntry;
 NumericSeries HighAfterEntry;
 Numeric BuyHighestPosiPro;
 Numeric SellHighestPosiPro;
 Numeric BuyReverseHighestPosiPro;
 Numeric SellReverseHighestPosiPro;
 Numeric ZYPrice;
 Numeric retrdpiont0;
 Numeric retrdpiont1;
 Numeric retrdpiont2;
 Numeric retrdpiont3;
 Numeric retrdpiont4;
 Numeric retrdpiont5;
    Numeric TakePoint1;
    Numeric TakePoint2;
    Numeric TakePoint3;
    Numeric TakePoint4;
    Numeric TakePoint5;
 Numeric K(3);
 Numeric TODAYBARS;
    Numeric DateDay(20131211);
Begin
    TODAYBARS=BarsSinceToday+1;
     If(TODAYBARS==1)
      {
         PlotString("周期提醒:",SymbolName+":1H");
      }
   If(TODAYBARS==1&&Date>=DateDay&&Date<=DateDay+5)
 {
  PlotString("授权","授权时间即将过期",0);
 }
    If(TODAYBARS==1&&Date>DateDay+3)
 {
  PlotString("授权","授权时间已经过期",0);
 }
 If(Date>DateDay+5)
 {
  Return;
 }
        If(BarType == 1)
    {
       If(Left(Symbol,2) == "IF")
       {
             EndTime = 0.1515 - 0.0001*BarInterval;
    }Else
       {
             EndTime = 0.1460 - 0.0001*BarInterval;
    }
    }
    If(Time>=EndTime&&MarketPosition<>0)
    {
     BuyToCover(0,o);
     Sell(0,o);
     //PlotString("平仓","平仓"+Text(ExitPrice),Low,Yellow);
     Return;
    }// 代编模型QQ 1145508240
 LossPoint=TakePoint0/5;
    TakePoint1=TakePoint0+LossPoint;
    TakePoint2=TakePoint1+LossPoint;
    TakePoint3=TakePoint2+LossPoint;
    TakePoint4=TakePoint3+LossPoint;
    TakePoint5=TakePoint4+LossPoint;

    retrdpiont0=LossPoint/2;
    retrdpiont1=retrdpiont0+LossPoint/2;
    retrdpiont2=retrdpiont1+LossPoint/2;
    retrdpiont3=retrdpiont2+LossPoint/2;
    retrdpiont4=retrdpiont3+LossPoint/2;
    retrdpiont5=retrdpiont4+LossPoint/2;
//初始化数据 www.cxh99.com
    Basedprice=CloseD(1);
    HighDDPrice=HighD(0);
 LowDprice=LowD(0);
//绘制第一根线
If(Date!=Date[1])
  {
    If(Close>Basedprice&&Low>=BasedpriceDown)
  {
         PlotNumeric("涨版:",Basedprice,Close,Red);
   RedK=RedK+1;
   GreenK=0;
   YellowK=0;
   Return;
     }
    If(Close<=BasedpriceUp)
      {
         PlotNumeric("跌版:",Close,Basedprice,Green);
   GreenK=GreenK+1;
   RedK=0;
   YellowK=0;
   Return;
      }
    If(Close==Basedprice)
      {
        UnPlot("涨版:");
     UnPlot("跌版:");
      }
  }
//绘制第二根线
 If(Date!=Date[1])
   {
     times=0;
     YellowK=0;
     RedK=0;
     GreenK=0;
  BasedpriceUp=HighDDPrice;
  Basedpricedown=LowDprice;
  UpLineK=0;
  DownLineK=0;
  KZhu=0;
  KZhu0=1;
   }Else
   {
  times=times[1];
     UpLineK=UpLineK[1];
  DownLineK=DownLineK[1];
  KZhu=KZhu[1];
  KZhu0=KZhu0[1];
  YellowK=YellowK[1];
  RedK=RedK[1];
  GreenK=GreenK[1];
   }
If(BarStatus>0)
  {
//记录上涨数据
 If(Close[1]>BasedpriceUp)
   {
      BasedpriceUp=Close[1];
   Basedpricedown=Low[1];
   UpLineK=UpLineK+1;
   RedK=RedK+1;
   GreenK=0;
   YellowK=0;
   DownLineK=0;
   KZhu=1;
   PlotNumeric("红版:",Open[1],BasedpriceUp,Red);
   }
//记录下跌数据
 If(Close[1]<Basedpricedown[1])
   {
      BasedpriceUp=High[1];
   Basedpricedown=Close[1];
   DownLineK=DownLineK+1;
   GreenK=GreenK+1;
   YellowK=0;
   RedK=0;
   UpLineK=0;
   KZhu=1;
   PlotNumeric("绿版:",BasedpriceUp,Open[1],Green);
   }
 }
    If(Close[1]>Basedpricedown&&Close[1]<BasedpriceUp[1])
   {
      BasedpriceUp=BasedpriceUp[1];
   Basedpricedown=Basedpricedown[1];
   KZhu=0;
   PlotNumeric("平版:",Close[1],Open[1],Yellow);
   YellowK=YellowK+1;
   GreenK=0;
   RedK=0;
   }
 If(KZhu==1)
   {
      KZhu0=1;
   }Else
   {
      KZhu0=0;
   }
 
    If(KZhu0==0&&BarsSToday>1)
      {
        PlotNumeric("平版:",Close[1],Open[1],Yellow);
  GreenK=0;
  RedK=0;
      }

 if(RedK<>0)
   {
     PlotString("RedK:",Text(RedK),o);
   }
 if(YellowK<>0)
   {
     PlotString("YellowK:",Text(YellowK),o);
   }
if(GreenK<>0)
   {
     PlotString("GreenK:",Text(GreenK),o);
   }
if(MarketPosition==0&&Time<0.1450)
{
if(RedK>=K)
  {
     Buy(Lots,o);
  times=times[1]+1;
  HighAfterEntry=High;
  LowAfterEntry=Low;
  Return;
  }
if(GreenK>=K)
  {
     SellShort(Lots,o);
  times=times[1]+1;
  HighAfterEntry=High;
  LowAfterEntry=Low;
  Return;
  }
}
    If(MarketPosition==1&&(LastEntryPrice-Low>=LossPoint))
  {
   ZSPrice=Min(open,LastEntryPrice-LossPoint);
   Sell(0,ZSPrice);
   Return;
  }
 
 If(MarketPosition==-1&&(High-LastEntryPrice>=LossPoint))
  {
     ZSPrice=Max(open,LastEntryPrice+LossPoint);
     BuyToCover(0,ZSPrice);
     Return;   
  }

   //止盈止损计算 ww.cxh99.com

  If(BarsSinceEntry>=1)
 {
    If(High>HighAfterEntry[1])
       {
       HighAfterEntry=High;
    }else
    {
      HighAfterEntry=HighAfterEntry[1];
    }
    If(Low<LowAfterEntry[1])
       {
       LowAfterEntry=Low;
    }else
    {
       LowAfterEntry=LowAfterEntry[1];
    }
  }

     BuyHighestPosiPro=HighAfterEntry[1]-EntryPrice;
     SellHighestPosiPro=EntryPrice-LowAfterEntry[1];

     BuyReverseHighestPosiPro=HighAfterEntry[1]-Low;
     SellReverseHighestPosiPro=High-LowAfterEntry[1];
If(MarketPosition==1 and BarsSinceLastEntry>1)
  {
      If(BuyHighestPosiPro>=TakePoint0&&SellHighestPosiPro>=retrdpiont0)
        {
           ZYPrice=Min(open,HighAfterEntry[1]-retrdpiont0);
     SellShort(Lots,ZYPrice);
     //PlotString("多止赢","多止赢"+Text(ExitPrice),Low,Yellow);
     Return;
  }// www.cxh99.com
      If(BuyHighestPosiPro>=TakePoint1&&SellHighestPosiPro>=retrdpiont1)
        {
           ZYPrice=Min(open,HighAfterEntry[1]-retrdpiont1);
     SellShort(Lots,ZYPrice);
     //PlotString("多止赢","多止赢"+Text(ExitPrice),Low,Yellow);
     Return;
  }
   If(BuyHighestPosiPro>=TakePoint2&&SellHighestPosiPro>=retrdpiont2)
        {
           ZYPrice=Min(open,HighAfterEntry[1]-retrdpiont2);
     SellShort(Lots,ZYPrice);
     //PlotString("多止赢","多止赢"+Text(ExitPrice),Low,Yellow);
     Return;
  }
   If(BuyHighestPosiPro>=TakePoint3&&SellHighestPosiPro>=retrdpiont3)
        {
           ZYPrice=Min(open,HighAfterEntry[1]-retrdpiont3);
     SellShort(Lots,ZYPrice);
     //PlotString("多止赢","多止赢"+Text(ExitPrice),Low,Yellow);
     Return;
  }
   If(BuyHighestPosiPro>=TakePoint4&&SellHighestPosiPro>=retrdpiont4)
        {
           ZYPrice=Min(open,HighAfterEntry[1]-retrdpiont4);
     SellShort(Lots,ZYPrice);
     //PlotString("多止赢","多止赢"+Text(ExitPrice),Low,Yellow);
     Return;
  }
   If(BuyHighestPosiPro>=TakePoint5&&BuyReverseHighestPosiPro>retrdpiont5)
        {
           ZYPrice=Min(open,HighAfterEntry[1]-retrdpiont5);
     SellShort(Lots,ZYPrice);
     //PlotString("多止赢","多止赢"+Text(ExitPrice),Low,Yellow);
     Return;
  }
  }
If(MarketPosition==-1 and BarsSinceLastEntry>1)
  {
      If(SellHighestPosiPro>=TakePoint0&&SellHighestPosiPro>=retrdpiont0)
        {
           ZYPrice=Max(open,LowAfterEntry[1]+retrdpiont0);
     Buy(Lots,ZYPrice);
     //PlotString("空止赢","空止赢"+Text(ExitPrice),High,Yellow);
     Return;
  }
      If(SellHighestPosiPro>=TakePoint1&&SellHighestPosiPro>=retrdpiont1)
        {
           ZYPrice=Max(open,LowAfterEntry[1]+retrdpiont1);
     Buy(Lots,ZYPrice);
     //PlotString("空止赢","空止赢"+Text(ExitPrice),High,Yellow);
     Return;
  }
   If(SellHighestPosiPro>=TakePoint2&&SellHighestPosiPro>=retrdpiont2)
        {
           ZYPrice=Max(open,LowAfterEntry[1]+retrdpiont2);
     Buy(Lots,ZYPrice);
     //PlotString("空止赢","空止赢"+Text(ExitPrice),High,Yellow);
     Return;
  } // www.cxh99.com
   If(SellHighestPosiPro>=TakePoint3&&SellHighestPosiPro>=retrdpiont3)
        {
           ZYPrice=Max(open,LowAfterEntry[1]+retrdpiont3);
     Buy(Lots,ZYPrice);
     //PlotString("空止赢","空止赢"+Text(ExitPrice),High,Yellow);
     Return;
  }
   If(SellHighestPosiPro>=TakePoint4&&SellHighestPosiPro>=retrdpiont4)
        {
           ZYPrice=Max(open,LowAfterEntry[1]+retrdpiont4);
     Buy(Lots,ZYPrice);
     //PlotString("空止赢","空止赢"+Text(ExitPrice),High,Yellow);
     Return;
  }
   If(SellHighestPosiPro>=TakePoint5&&SellReverseHighestPosiPro>retrdpiont5)
        {
           ZYPrice=Max(open,LowAfterEntry[1]+retrdpiont5);
     Buy(Lots,ZYPrice);
     //PlotString("空止赢","空止赢"+Text(ExitPrice),High,Yellow);
     Return;
  }
 }
End

//------------------------------------------------------------------------
// 编译版本 GS2010.12.08
// 用户版本 2013/01/21 11:43
// 版权所有 baoshan6997  www.cxh99.com
// 更改声明 TradeBlazer Software保留对TradeBlazer平台
//   每一版本的TrabeBlazer公式修改和重写的权利
//------------------------------------------------------------------------

 

 

将最后一图中的前7个都设置为柱线,线宽设置为最粗,OK

 

有思路,想编写各种指标公式,程序化交易模型,选股公式,预警公式的朋友

可联系技术人员 QQ: 1145508240  点击这里给我发消息进行 有偿 编写!不贵!点击查看价格!

 


【字体: 】【打印文章】【查看评论

相关文章

    没有相关内容