欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → 帮我看看移动停损怎么不行?

   

欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。    


  共有5025人关注过本帖树形打印复制链接

主题:帮我看看移动停损怎么不行?

帅哥哟,离线,有人找我吗?
guotx2010
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:蜘蛛侠 帖子:1366 积分:5210 威望:0 精华:7 注册:2010/12/11 18:00:33
帮我看看移动停损怎么不行?  发帖心情 Post By:2011/1/7 11:00:46    Post IP:113.116.94.172[只看该作者]

//根据笔方向,向上笔做多,向下笔做空,周期以3周期为限,以确保笔已基本形成。

//参数说明:DuoKong 决定做多还是做空
DuoKong:=1;     {多空,1-都做,2-只做多,3-只做空}
OrdVol:=1;     {开仓手数}

var1:="chzhshch@kxian";  {处理K线}
var2:="chzhshch@bi";  {处理笔关系}
var3:="chzhshch@duan";  {处理段关系}

B1:=barslast(var3<>0);  //段最后一次信号后的周期
B2:=ref(var3,b1);   //段信号 -1为下跌段结束点  +1为上涨段结束点

A1:=barslast(var2<>0);  //笔最后一次信号后的周期
A2:=ref(var2,a1);   //笔信号 -1为下跌笔结束点  +1为上涨笔结束点
AA1:=ref(a1+1,1);    //最后信号到现在的周期
AA2:=-ref(a2,1);   //最近信号取反,如果是-1,就变为+1
AA3:=AA1+REF(AA1+1,AA1); //倒数第二个端点的周期
AA4:=AA3+REF(AA1+1,AA3); //倒数第三个端点的周期
H1:=barslast(var2=1);  //高点到现在的周期
H2:=ref(var2,H1);   //高点笔方向 +1
HH1:=ref(H1+1,1);    //最后高点信号到现在的周期
HH2:=-ref(H2,1);   //高点方向取反 -1
L1:=barslast(var2=-1);
L2:=ref(var2,L1);
LL1:=ref(L1+1,1);
LL2:=-ref(L2,1);
//G1-G5为倒数的第一至第五个高点的价位
G:=REF(H,h1);    //所有高点连线
G1:=REF(H,HH1);
G2:=REF(G1,HH1);
G3:=REF(G2,HH1);
G4:=REF(G3,HH1);
G5:=REF(G4,HH1);
//D1-D5为倒数的第一至第五个低点的价位
D:=REF(L,l1);    //所有低点连线
D1:=REF(L,LL1);
D2:=REF(D1,LL1);
D3:=REF(D2,LL1);
D4:=REF(D3,LL1);
D5:=REF(D4,LL1);

//下跌笔结束做多
Long:=A2=-1 AND A1=4; {多单进场条件}
Short:=A2=1 AND A1=4; {空单进场条件}

开仓以来最低价:=LLV(L,ENTERBARS);
开仓以来最高价:=HHV(H,ENTERBARS);
//多单
If DuoKong=1 Or DuoKong=2 then begin
 //多单进场
 IF Long and holding<0 then begin
  {平空}sellshort(1,0,market);
  {开多}Buy(Long,OrdVol,market);
 end
End 
//画出多单止损线
partline(holding>0,D1,Colorred);

If Holding>0 Then Begin 
 //多单如果盈利超过5点了,回撤3点就止盈
 if 开仓以来最高价-Enterprice>5 then begin
  多保:sell(开仓以来最高价-H<3,0,limitr,H);
 end 
 //就是下面这段用于移动止损的,如果有利润,并且大于3,就应该自动设置高一点的止损位,可是,没有起作用
 Dts:=D1;  //否则就使用D1作为止损点
 If Enterprice-D1>10 then //如果开仓价与低点相差大于10点,就设置止损8点
  Dts:=Enterprice-8;
 else if H-Enterprice>3 then
  Dts:=Enterprice+0.6;
 else if H-Enterprice>6 then
  Dts:=Enterprice+3;
 else if H-Enterprice>10 then
  Dts:=Enterprice+6;
 else if H-Enterprice>15 then
  Dts:=Enterprice+10;
 else if H-Enterprice>20 then
  Dts:=Enterprice+15;
 else if H-Enterprice>25 then
  Dts:=Enterprice+20;
  
 多停损:sell(1,0,stopr,Dts);
  
 //多单平仓
 LongY:=C<G1 And A2=1 AND A1=4; {价格低于前一个高点,多单止赢}
 If LongY then begin
  {多单平仓}Sell(1,0,market);
  end
End
//空单
If DuoKong=1 Or DuoKong=3 then begin
 //空单进场
 If Short then Begin
  {平多}Sell(holding>0,0,market);
  {开空}BuyShort(Short,OrdVol,market);
 end
End 
//画出空单止损线
partline(holding<0,G1,ColorGreen);

If Holding<0 Then Begin
 //空单如果盈利超过5点了,回撤3点就止盈
 if Enterprice-开仓以来最低价>5 then begin
  空保:sell(L-开仓以来最低价<3,Holding,limitr,l);
 end 
 
 Kts:=G1;  //否则就使用G1作为止损点
 If G1-Enterprice>10 then //如果开仓价与低点相差大于10点,就设置止损8点
  Kts:=Enterprice+8;
 else if Enterprice-l>3 then
  Kts:=Enterprice-0.6;
 else if Enterprice-l>3 then
  Kts:=Enterprice-0.6;
 else if Enterprice-l>6 then
  Kts:=Enterprice-3;
 else if Enterprice-l>10 then
  Kts:=Enterprice-6;
 else if Enterprice-l>15 then
  Kts:=Enterprice-10;
 else if Enterprice-l>20 then
  Kts:=Enterprice-15;
 else if Enterprice-l>25 then
  Kts:=Enterprice-20;
 
 空停损:sellshort(1,0,stopr,Kts);

 //空单止盈
 //If Enterprice-L>KDZyDs then Begin
 // {空单止赢}SellShort(Holding<0,Holding,market);  
 //End 
 
 //空单平仓
 ShortY:=C>D1 And A2=-1 AND A1=4; {价格高于前一个低点,空单止赢}
 If ShortY then begin
  {空单平仓}SellShort(1,0,market);
  end
End 

可用现金:CASH(0),LINETHICK0;
持仓:HOLDING,LINETHICK0;
资产:ASSET,LINETHICK0;

 

[此贴子已经被作者于2011-1-7 11:09:32编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
admin
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:7302 积分:32559 威望:1000 精华:45 注册:2003/12/30 16:34:32
  发帖心情 Post By:2011/1/7 11:19:58    Post IP:58.246.57.26[只看该作者]

不要再实盘交易中使用

空停损:sellshort(1,0,stopr,Kts);

这样的写法,会导致不停的发止损单

应该将stopr改成market,通过条件控制下单来实现止损

建义楼主看看精华贴,很多止损的范例


 回到顶部