以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  [求助] 为什么平多以后 还是马上开多 怎么才能止损以后 不在开同向的仓 , 知道反向信号出现在开仓  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=58698)

--  作者:yuefei227
--  发布时间:2013/11/12 18:44:31
--  [求助] 为什么平多以后 还是马上开多 怎么才能止损以后 不在开同向的仓 , 知道反向信号出现在开仓

if barpos = 0 then
 stopprice := l - stopnum;
if aspect = 0 then begin
//多头处理
if l <= stopprice   then begin
 sell(holding>0,holding,0);

 aspect:= 1;
 stopprice := h+stopnum;
end
//处理移动的底部
if l - stopnum > stopprice then
 stopprice := l-stopnum;
end
if aspect = 1 then begin
//空头处理
if h >= stopprice then begin
 sellshort(holding<0,holding,0);


 aspect:= 0;
 stopprice := l-stopnum;
end
//处理移动的底部
if h + stopnum < stopprice then
 stopprice := h+stopnum;
end
dt:=Buy(开仓时间 AND NOT(TYPE(1)=1) and h>=UpperBand and (HOLDING=0)  ,lots,LIMITR,Max(Open,UpperBand)+1*MINDIFF),orderqueue;
kt:=BuyShort(开仓时间 and  NOT(TYPE(3)=1) and l<=LowerBand  and (HOLDING=0) ,lots,LIMITR,Min(Open,LowerBand)-1*MINDIFF),orderqueue;

     
if dt then begin

buy(dt and NOT(TYPE(1)=1),10%,0);
end;
if kt then begin

buyshort(kt and NOT(TYPE(1)=3),10%,0);
end;


--  作者:yuefei227
--  发布时间:2013/11/12 19:04:48
--  

图片点击可在新窗口打开查看此主题相关图片如下:6h(%n$8ie9yl~15@5v5wnl2.jpg
图片点击可在新窗口打开查看

--  作者:jinzhe
--  发布时间:2013/11/13 9:08:01
--  

variable:n=0;

variable:m=0;

if barpos = 0 then
 stopprice := l - stopnum;
if aspect = 0 then begin
//多头处理
if l <= stopprice   then begin
 sell(holding>0,holding,0);

 aspect:= 1;
 stopprice := h+stopnum;

 n:=1;

 m:=0;
end
//处理移动的底部
if l - stopnum > stopprice then
 stopprice := l-stopnum;
end
if aspect = 1 then begin
//空头处理
if h >= stopprice then begin
 sellshort(holding<0,holding,0);


 aspect:= 0;
 stopprice := l-stopnum;

 m:=1;

 n:=0;
end
//处理移动的底部
if h + stopnum < stopprice then
 stopprice := h+stopnum;
end;


dt:=开仓时间 AND NOT(TYPE(1)=1) and h>=UpperBand and (HOLDING=0);

kt:=开仓时间 and  NOT(TYPE(3)=1) and l<=LowerBand  and (HOLDING=0);   

 
if dt  and m=1 then begin

buy(1,10%,0);
end;
if kt  and n=1 then begin

buyshort(1,10%,0);
end;

 

 

这两句用来是干什么的?

dt:=Buy(开仓时间 AND NOT(TYPE(1)=1) and h>=UpperBand and (HOLDING=0)  ,lots,LIMITR,Max(Open,UpperBand)+1*MINDIFF),orderqueue;
kt:=BuyShort(开仓时间 and  NOT(TYPE(3)=1) and l<=LowerBand  and (HOLDING=0) ,lots,LIMITR,Min(Open,LowerBand)-1*MINDIFF),orderqueue;

这样的胡乱赋值有什么意义?

[此贴子已经被作者于2013/11/13 9:08:10编辑过]

--  作者:yuefei227
--  发布时间:2013/11/13 18:40:40
--  
不好意思我新学的, 有的地方还是不太懂    现在又出来一个问题, if h >= stopprice then begin
 sellshort(holding<0,holding,0); 会平空  不在开空  但是 l <= stopprice  会开空    我的 策略是  最低价突破下轨做空  h >= stopprice  时平空 不在开仓 直到 最低价突破下轨在做空
--  作者:jinzhe
--  发布时间:2013/11/14 9:07:13
--  

l <= stopprice  上面代码里面哪里有根据这个判断条件开仓的?不都是l<=LowerBand  才开仓的?


--  作者:yuefei227
--  发布时间:2013/11/15 9:54:21
--  

但是确实开仓啦? 没有在最低价突破下轨处开仓   却在  l <= stopprice  时开空了   

开仓时间:=time>opentime(1) and time<closetime(0);
平仓时间:=not(islastbar) and time=190000 or islastbar and currenttime>185905;
收盘平多:sell(平仓时间 and holding>0, 0, thisclose);
收盘平空:sellshort(平仓时间 and holding<0,0,thisclose);
variable:n=0;

variable:m=0;

if barpos = 0 then
 stopprice := l - stopnum;
if aspect = 0 then begin
//多头处理
if l <= stopprice   then begin
 sell(holding>0,holding,0);

 aspect:= 1;
 stopprice := h+stopnum;

 n:=1;

 m:=0;
end
//处理移动的底部
if l - stopnum > stopprice then
 stopprice := l-stopnum;
end
if aspect = 1 then begin
//空头处理
if h >= stopprice then begin
 sellshort(holding<0,holding,0);


 aspect:= 0;
 stopprice := l-stopnum;

 m:=1;

 n:=0;
end
//处理移动的底部
if h + stopnum < stopprice then
 stopprice := h+stopnum;
end;


dt:=开仓时间 AND NOT(TYPE(1)=1) and  h>=UpperBand and (HOLDING=0);

kt:=开仓时间 and  NOT(TYPE(3)=1) and l<=LowerBand  and (HOLDING=0);  

 
if dt  and m=1 then begin

buy(1,LOTS,LIMITR,Max(Open,UpperBand)+1*MINDIFF),orderqueue;
end;
if kt  and n=1 then begin

buyshort(1,lots,LIMITR,Min(Open,LowerBand)-1*MINDIFF),orderqueue;
end;
//画线

PARTLINE( aspect = 0, stopprice , colorrgb(255,0,0));

PARTLINE( aspect = 1, stopprice , colorrgb(0,255,0));

 

这是部分代码


此主题相关图片如下:搜狗截图13年11月15日0950_1.png
按此在新窗口浏览图片

--  作者:jinzhe
--  发布时间:2013/11/15 9:56:20
--  

没有代码是在l <= stopprice  条件下开仓的,

你觉得这个条件下开仓要么就是感觉错误,要么就是这个时候l<=LowerBand  也满足了


--  作者:yuefei227
--  发布时间:2013/11/15 9:59:46
--  
哦   我明白了    改成最低价与下轨交叉时在开仓   不知道这样可行不  老师
--  作者:jinzhe
--  发布时间:2013/11/15 10:19:11
--  

if cross(LowerBand,stopprice) then buyshort(holding=0,1,market);

if cross(stopprice,UpperBand) then buy(holding=0,1,market);

 

在上面的策略里面加上这样的代码