分享

一个策略实例,包含进场、平仓及止盈、止损

 Manstein99 2011-07-18

//此策略以当前价格突破为进场条件,进场之后记录价格变动的最高、最低,并计算回撤点数,当参数设置启动了回撤止盈时,符合条件就会平仓。

//有止损设置,赚钱超过3点时,如果价格回撤,系统会保留1.2点的盈利退出,这样至少可以保住手续费。

//作者:guotx2010  日期:2011-03-21

EMA13:=EMA(C,10),COLORWHITE;
EMA21:=EMA(C,21),COLORYELLOW;
EMA34:=EMA(C,34),COLORFF00FF;
EMA60:=MA(C,55),COLORFFCC66;
X1:=(C+L+H)/3;
X2:=EMA(X1,5);
X3:=EMA(X2,4);
STICKLINE(X2>X3 AND C>EMA13,LOW,HIGH,0.1,1),COLORRED;
STICKLINE(X2>X3 AND C>EMA13,CLOSE,OPEN,3,1),COLORRED;
STICKLINE(X2<X3 AND C<EMA13,LOW,HIGH,0.1,1),COLORFFFF52;
STICKLINE(X2<X3 AND C<EMA13,CLOSE,OPEN,3,0),COLORFFFF52;

Buy1:=Filter(X2>X3 And C>EMA13,4);
Sell1:=Filter(X2<X3 And C<EMA13,4);

//使用系列模式时
//{开多} ENTERLONG:Buy1,TFILTER;
//{平多}EXITLONG:Sell1 ,TFILTER;
//
//{开空}ENTERSHORT:Sell1 ,TFILTER;
//{平空}EXITSHORT:Buy1 ,TFILTER;

//使用逐K线模式时
variable:DuoKong=0;
Tsfs:=0;     {停损反手,1-反手 0-不反手}
OrdVol:=1;     {开仓手数}
ZsDs:=10;     {止损点数}
//以下变量用于移动止盈,,移动止盈只能保证你尽可能稳健盈利,却不能保证盈利最大化,如果不想使用,可是将总开关设置为0
variable:YdZy=1;     {移动止盈总开关,1为开,0为关}
variable:HighPrice=0,LowPrice=0; {保存开仓后的最高价、最低价}
variable:DHcDs=3,KHcDs=3;   {多、空单回撤点数}
variable:DYlDs=7,KYlDs=7;   {多、空单盈利点数,当盈利点数达到这个标准后,如果回撤达到上面的参数值就平仓}
variable:Z3B1:=1;     {赚3保1开关}

DuoKong:=1;

//持有空单
If Holding<0 then Begin
 If Buy1 then begin   //平空单
  空平:SellShort(1,0,mkt),orderqueue;
 End
 
 //止损
 If C-Enterprice>=ZsDs then begin
  空损:SellShort(1,0,mkt),orderqueue;
 End
 
 //移动止盈
 If YdZy=1 then begin
  //每周期判断是否创新低
  If L<LowPrice then begin
   LowPrice:=L;
  End 
  
  //如果盈利超过10点之后回撤达到3点,就平仓,保住盈利
  If Enterprice-LowPrice>=KYlDs then begin
   If L-LowPrice>=KHcDs Then Begin  //回撤超过3点
    空赢:SellShort(1,0,market);
   End 
  End
 End
 
 //赚3保1
 If Z3B1=1 then begin
  If Enterprice-LowPrice>=3 then begin
   If Enterprice-L<=1.2 then begin
    空保:SellShort(1,0,market);
   End
  End
 End
End

//开多单
If holding=0 then begin
 If DuoKong=1 Or DuoKong=2 then begin
  If Buy1 then begin
   多开:Buy(1=1,ordVol,mkt);
   HighPrice:=Enterprice;  //将开仓价保存到最高价
  End 
 End
end

//持有多单
If Holding>0 then Begin
 If Sell1 then begin  {平多单}
  多平:Sell(1,0,mkt),orderqueue;
 End
 
 //多单管理
 //止损
 If Enterprice-C>=ZsDs then begin
  多损:Sell(1,0,mkt),orderqueue;
 End

 //移动止盈
 If YdZy=1 then begin
  //每周期判断是否创新高
  If H>HighPrice then begin
   HighPrice:=H;
  End 
 
  //如果盈利超过10点之后回撤达到3点,就平仓,保住盈利
  If HighPrice-Enterprice>=DYlDs then begin
   If HighPrice-H>=DHcDs Then Begin  //回撤超过3点
    多赢:Sell(1,0,market);
   End 
  End
 End

 //赚3保1
 If Z3B1=1 then begin
  If HighPrice-Enterprice>=3 then begin
   If H-Enterprice<=1.2 then begin
    多保:Sell(1,0,market);
   End
  End
 End
End

//开空单
If holding=0 then begin
 If DuoKong=1 Or DuoKong=3 then begin
  If Sell1 then begin
   空开:BuyShort(1=1,ordVol,mkt);
   LowPrice:=enterprice;
  End 
 End
end

//此策略以当前价格突破为进场条件,进场之后记录价格变动的最高、最低,并计算回撤点数,当参数设置启动了回撤止盈时,符合条件就会平仓。

//有止损设置,赚钱超过3点时,如果价格回撤,系统会保留1.2点的盈利退出,这样至少可以保住手续费。

//作者:guotx2010  日期:2011-03-21

EMA13:=EMA(C,10),COLORWHITE;
EMA21:=EMA(C,21),COLORYELLOW;
EMA34:=EMA(C,34),COLORFF00FF;
EMA60:=MA(C,55),COLORFFCC66;
X1:=(C+L+H)/3;
X2:=EMA(X1,5);
X3:=EMA(X2,4);
STICKLINE(X2>X3 AND C>EMA13,LOW,HIGH,0.1,1),COLORRED;
STICKLINE(X2>X3 AND C>EMA13,CLOSE,OPEN,3,1),COLORRED;
STICKLINE(X2<X3 AND C<EMA13,LOW,HIGH,0.1,1),COLORFFFF52;
STICKLINE(X2<X3 AND C<EMA13,CLOSE,OPEN,3,0),COLORFFFF52;

Buy1:=Filter(X2>X3 And C>EMA13,4);
Sell1:=Filter(X2<X3 And C<EMA13,4);

//使用系列模式时
//{开多} ENTERLONG:Buy1,TFILTER;
//{平多}EXITLONG:Sell1 ,TFILTER;
//
//{开空}ENTERSHORT:Sell1 ,TFILTER;
//{平空}EXITSHORT:Buy1 ,TFILTER;

//使用逐K线模式时
variable:DuoKong=0;
Tsfs:=0;     {停损反手,1-反手 0-不反手}
OrdVol:=1;     {开仓手数}
ZsDs:=10;     {止损点数}
//以下变量用于移动止盈,,移动止盈只能保证你尽可能稳健盈利,却不能保证盈利最大化,如果不想使用,可是将总开关设置为0
variable:YdZy=1;     {移动止盈总开关,1为开,0为关}
variable:HighPrice=0,LowPrice=0; {保存开仓后的最高价、最低价}
variable:DHcDs=3,KHcDs=3;   {多、空单回撤点数}
variable:DYlDs=7,KYlDs=7;   {多、空单盈利点数,当盈利点数达到这个标准后,如果回撤达到上面的参数值就平仓}
variable:Z3B1:=1;     {赚3保1开关}

DuoKong:=1;

//持有空单
If Holding<0 then Begin
 If Buy1 then begin   //平空单
  空平:SellShort(1,0,mkt),orderqueue;
 End
 
 //止损
 If C-Enterprice>=ZsDs then begin
  空损:SellShort(1,0,mkt),orderqueue;
 End
 
 //移动止盈
 If YdZy=1 then begin
  //每周期判断是否创新低
  If L<LowPrice then begin
   LowPrice:=L;
  End 
  
  //如果盈利超过10点之后回撤达到3点,就平仓,保住盈利
  If Enterprice-LowPrice>=KYlDs then begin
   If L-LowPrice>=KHcDs Then Begin  //回撤超过3点
    空赢:SellShort(1,0,market);
   End 
  End
 End
 
 //赚3保1
 If Z3B1=1 then begin
  If Enterprice-LowPrice>=3 then begin
   If Enterprice-L<=1.2 then begin
    空保:SellShort(1,0,market);
   End
  End
 End
End

//开多单
If holding=0 then begin
 If DuoKong=1 Or DuoKong=2 then begin
  If Buy1 then begin
   多开:Buy(1=1,ordVol,mkt);
   HighPrice:=Enterprice;  //将开仓价保存到最高价
  End 
 End
end

//持有多单
If Holding>0 then Begin
 If Sell1 then begin  {平多单}
  多平:Sell(1,0,mkt),orderqueue;
 End
 
 //多单管理
 //止损
 If Enterprice-C>=ZsDs then begin
  多损:Sell(1,0,mkt),orderqueue;
 End

 //移动止盈
 If YdZy=1 then begin
  //每周期判断是否创新高
  If H>HighPrice then begin
   HighPrice:=H;
  End 
 
  //如果盈利超过10点之后回撤达到3点,就平仓,保住盈利
  If HighPrice-Enterprice>=DYlDs then begin
   If HighPrice-H>=DHcDs Then Begin  //回撤超过3点
    多赢:Sell(1,0,market);
   End 
  End
 End

 //赚3保1
 If Z3B1=1 then begin
  If HighPrice-Enterprice>=3 then begin
   If H-Enterprice<=1.2 then begin
    多保:Sell(1,0,market);
   End
  End
 End
End

//开空单
If holding=0 then begin
 If DuoKong=1 Or DuoKong=3 then begin
  If Sell1 then begin
   空开:BuyShort(1=1,ordVol,mkt);
   LowPrice:=enterprice;
  End 
 End
end

//此策略以当前价格突破为进场条件,进场之后记录价格变动的最高、最低,并计算回撤点数,当参数设置启动了回撤止盈时,符合条件就会平仓。

//有止损设置,赚钱超过3点时,如果价格回撤,系统会保留1.2点的盈利退出,这样至少可以保住手续费。

//作者:guotx2010  日期:2011-03-21

EMA13:=EMA(C,10),COLORWHITE;
EMA21:=EMA(C,21),COLORYELLOW;
EMA34:=EMA(C,34),COLORFF00FF;
EMA60:=MA(C,55),COLORFFCC66;
X1:=(C+L+H)/3;
X2:=EMA(X1,5);
X3:=EMA(X2,4);
STICKLINE(X2>X3 AND C>EMA13,LOW,HIGH,0.1,1),COLORRED;
STICKLINE(X2>X3 AND C>EMA13,CLOSE,OPEN,3,1),COLORRED;
STICKLINE(X2<X3 AND C<EMA13,LOW,HIGH,0.1,1),COLORFFFF52;
STICKLINE(X2<X3 AND C<EMA13,CLOSE,OPEN,3,0),COLORFFFF52;

Buy1:=Filter(X2>X3 And C>EMA13,4);
Sell1:=Filter(X2<X3 And C<EMA13,4);

//使用系列模式时
//{开多} ENTERLONG:Buy1,TFILTER;
//{平多}EXITLONG:Sell1 ,TFILTER;
//
//{开空}ENTERSHORT:Sell1 ,TFILTER;
//{平空}EXITSHORT:Buy1 ,TFILTER;

//使用逐K线模式时
variable:DuoKong=0;
Tsfs:=0;     {停损反手,1-反手 0-不反手}
OrdVol:=1;     {开仓手数}
ZsDs:=10;     {止损点数}
//以下变量用于移动止盈,,移动止盈只能保证你尽可能稳健盈利,却不能保证盈利最大化,如果不想使用,可是将总开关设置为0
variable:YdZy=1;     {移动止盈总开关,1为开,0为关}
variable:HighPrice=0,LowPrice=0; {保存开仓后的最高价、最低价}
variable:DHcDs=3,KHcDs=3;   {多、空单回撤点数}
variable:DYlDs=7,KYlDs=7;   {多、空单盈利点数,当盈利点数达到这个标准后,如果回撤达到上面的参数值就平仓}
variable:Z3B1:=1;     {赚3保1开关}

DuoKong:=1;

//持有空单
If Holding<0 then Begin
 If Buy1 then begin   //平空单
  空平:SellShort(1,0,mkt),orderqueue;
 End
 
 //止损
 If C-Enterprice>=ZsDs then begin
  空损:SellShort(1,0,mkt),orderqueue;
 End
 
 //移动止盈
 If YdZy=1 then begin
  //每周期判断是否创新低
  If L<LowPrice then begin
   LowPrice:=L;
  End 
  
  //如果盈利超过10点之后回撤达到3点,就平仓,保住盈利
  If Enterprice-LowPrice>=KYlDs then begin
   If L-LowPrice>=KHcDs Then Begin  //回撤超过3点
    空赢:SellShort(1,0,market);
   End 
  End
 End
 
 //赚3保1
 If Z3B1=1 then begin
  If Enterprice-LowPrice>=3 then begin
   If Enterprice-L<=1.2 then begin
    空保:SellShort(1,0,market);
   End
  End
 End
End

//开多单
If holding=0 then begin
 If DuoKong=1 Or DuoKong=2 then begin
  If Buy1 then begin
   多开:Buy(1=1,ordVol,mkt);
   HighPrice:=Enterprice;  //将开仓价保存到最高价
  End 
 End
end

//持有多单
If Holding>0 then Begin
 If Sell1 then begin  {平多单}
  多平:Sell(1,0,mkt),orderqueue;
 End
 
 //多单管理
 //止损
 If Enterprice-C>=ZsDs then begin
  多损:Sell(1,0,mkt),orderqueue;
 End

 //移动止盈
 If YdZy=1 then begin
  //每周期判断是否创新高
  If H>HighPrice then begin
   HighPrice:=H;
  End 
 
  //如果盈利超过10点之后回撤达到3点,就平仓,保住盈利
  If HighPrice-Enterprice>=DYlDs then begin
   If HighPrice-H>=DHcDs Then Begin  //回撤超过3点
    多赢:Sell(1,0,market);
   End 
  End
 End

 //赚3保1
 If Z3B1=1 then begin
  If HighPrice-Enterprice>=3 then begin
   If H-Enterprice<=1.2 then begin
    多保:Sell(1,0,market);
   End
  End
 End
End

//开空单
If holding=0 then begin
 If DuoKong=1 Or DuoKong=3 then begin
  If Sell1 then begin
   空开:BuyShort(1=1,ordVol,mkt);
   LowPrice:=enterprice;
  End 
 End
end

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多