以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  jinzhe 老师 帮我再修改一个小问题  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=65859)

--  作者:qichao371
--  发布时间:2014/6/6 9:07:48
--  jinzhe 老师 帮我再修改一个小问题
dd:=if(date>1130301,1,1);
trr:=max(max((high-low),abs((ref(close,1)-high))),abs((ref(close,1)-low)))*dd;
hh:=c+trr*dd*倍数/10,colorgray;
ll:=c-trr*dd*倍数/10,colorgray;
llxx:=ref(hhv(ll,5),1)*dd;
hlxx:=ref(llv(hh,5),1)*dd;
chxx:=cross(c,hlxx*1.000001); 
clxx:=(0-cross(llxx*0.999999,c)); 
tfxx:=if(chxx,chxx,if(cross(llxx*0.999999,c),clxx,0)); 
udxx:=ref(tfxx,barslast(tfxx));
llxxx:=hhv(ll,barslast(udxx<0));
hlxxx:=llv(hh,barslast(udxx>0));
chxxx:=cross(c,hlxxx*1.000001); 
clxxx:=(0-cross(llxxx*0.999999,c)); 
tfxxx:=if(chxxx,chxxx,if(cross(llxxx*0.999999,c),clxxx,0)); 
udxxx:=ref(tfxxx,barslast(tfxxx));
llxxxx:=min(hhv(ll,barslast(udxxx<0)),llxxx);
hlxxxx:=max(llv(hh,barslast(udxxx>0)),hlxxx);
chxxxx:=cross(c,hlxxxx*1.000001); 
clxxxx:=(0-cross(llxxxx*0.999999,c)); 
tfxxxx:=if(chxxxx,chxxxx,if(cross(llxxxx*0.999999,c),clxxxx,0)); 
udxxxx:=ref(tfxxxx,barslast(tfxxxx));
llxxxxx:=min(hhv(ll,barslast(udxxxx<0)),llxxxx);
hlxxxxx:=max(llv(hh,barslast(udxxxx>0)),hlxxxx);
chxxxxx:=cross(c,hlxxxxx*1.000001);
clxxxxx:=(0-cross(llxxxxx*0.999999,c));
tfxxxxx:=if(chxxxxx,chxxxxx,if(cross(llxxxxx*0.999999,c),clxxxxx,0));
udxxxxx:=ref(tfxxxxx,barslast(tfxxxxx));
llxxxxxx:=min(hhv(ll,barslast(udxxxxx<0)),llxxxxx);
hlxxxxxx:=max(llv(hh,barslast(udxxxxx>0)),hlxxxxx);
bbx:=llxxxxxx*0.999999;
ssx:=hlxxxxxx*1.000001;
b1x:=if(cross(c,ssx),1,if(cross(bbx,c),-1,0))*dd;
b2x:=ref(b1x,barslast(b1x))*dd;
w:=if(b2x=1,bbx,if(b2x=-1,ssx,c))*dd,coloryellow;
bbx:=ema(llv(l,3),5)*0.999999*dd;
ssx:=ema(hhv(h,3),5)*1.000001*dd;
b1x:=if(cross(c,ssx),1,if(cross(bbx,c),-1,0));
b2x:=ref(b1x,barslast(b1x));
多空转折线:=if(b2x=1,bbx,if(b2x=-1,ssx,0))*dd;
w,coloryellow,linethick2;
ll:=bbx;
hl:=ssx;
ch:=cross(c,hl); 
cl:=(0-cross(ll,c)); 
tf:=if(ch,ch,if(cross(ll,c),cl,0)); 
ud:=ref(tf,barslast(tf));
lll:=ema(llv(l,3),5)*dd;
hhh:=ema(hhv(h,3),5)*dd;
kkk:=(barslast(cross(ref(llv(l,25),1)*0.99999,llv(c,25)))-barslast(cross(hhv(c,25),ref(hhv(h,25),1)*1.00001)))*dd,nodraw;
stickline(kkk>0,o,c,6,0),colorred;
stickline(kkk>0,h,l,0,0),colorred;
stickline(kkk>0 and c>o,o,c,6,1),colorred;
stickline(kkk<0,o,c,6,0),color00aa00;
stickline(kkk<0,h,l,0,0),color00aa00;
stickline(kkk<0 and c>o,o,c,6,1),color00aa00;
partline(c>w and not(cross(c,w)),w),colormagenta,linethick2;
partline(c<w and not(cross(w,c)),w),colorcyan,linethick2;

drawtext(cross(hhv(c,25),ref(hhv(h,25),1)*1.00001),bbx*0.9995,\'开多\'),colorred;
drawtext(cross(ref(llv(l,25),1)*0.99999,llv(c,25)),ssx*1.0005,\'开空\'),colorgreen;
kd:barslast(((cross(w,c) and c>多空转折线) or (cross(多空转折线,c) and c>w) or (cross(多空转折线,c) and cross(w,c))) and kkk>0)-barslast(cross(hhv(c,25),ref(hhv(h,25),1)*1.00001)),nodraw;
kk:barslast(((cross(c,w) and c<多空转折线) or (cross(c,多空转折线) and c<w) or (cross(c,多空转折线) and cross(c,w))) and kkk<0)-barslast(cross(ref(llv(l,25),1)*0.99999,llv(c,25))),nodraw;
drawtext(cross(0,kd) and kkk>0,w,\'平多\'),coloryellow;
drawtext(cross(0,kk) and kkk<0,w,\'平空\'),coloryellow;

kdss:=5;//开多手数
jdss:=2;//加多手数
kkss:=5;//开空手数
jkss:=2;//加空手数

if cross(hhv(c,25),ref(hhv(h,25),1)*1.00001) and holding=0 then begin
    buy(holding=0,kdss,thisclose);
end
 
if cross(hhv(c,25),ref(hhv(h,25),1)*1.00001) and holding>0 and enterbars>0 then begin
    buy(holding>0,jdss,market);
end
 
if cross(ref(llv(l,25),1)*0.99999,llv(c,25)) and holding=0 then begin
    buyshort(holding=0,kkss,thisclose);
end
 
if cross(ref(llv(l,25),1)*0.99999,llv(c,25))  and holding<0  and enterbars>0 then begin
    buyshort(holding<0,jkss,market);
end
 
if cross(0,kd) and kkk>0 then sell(1,0,market);
if cross(0,kk) and kkk<0 then sellshort(1,0,market);








还是上次的指标,感谢您的修改。目前发现一个问题。就是如果指标出现了:“开多”     而第二根线没有出现“平多”   而是直接“开空”了 ,    目前指标没有平多开空。  我想让它能在信号发生变化时,即使不出现平多,平空    也要反手。比如开空后 接着出现开多   那么就反手多,相反  开空后  如果开多   那就反手多

--  作者:jinzhe
--  发布时间:2014/6/6 9:30:44
--  
开多后必然会先平多再开空的,你看错了
--  作者:qichao371
--  发布时间:2014/6/6 9:40:40
--  
您看下这个图。  是尾盘的最后一根线开多了。然后第二天突然开空。可是它仍然保持开多的持仓。没有动作。而且后面也在就信号没了
图片点击可在新窗口打开查看此主题相关图片如下:qq截图20140523150005.jpg
图片点击可在新窗口打开查看

--  作者:qichao371
--  发布时间:2014/6/6 9:42:39
--  
这个也是出现同样问题
图片点击可在新窗口打开查看此主题相关图片如下:qq截图20140523150005.jpg
图片点击可在新窗口打开查看

--  作者:jinzhe
--  发布时间:2014/6/6 10:01:56
--  

那不就是对了,就是有提示,并没有开仓,这个是正确的,希望反手就自己写在代码里面


--  作者:qichao371
--  发布时间:2014/6/6 10:25:34
--  
我意思    开多  后  出现开空, 然后就平掉多单,然后开空。。否则信号就断了。jinzhe老师帮我添加一下 吧   我不会写啊。
--  作者:jinzhe
--  发布时间:2014/6/6 10:31:54
--  
if cross(hhv(c,25),ref(hhv(h,25),1)*1.00001) and holding=0 then begin
    sellshort(1,0,market);
    buy(holding=0,kdss,thisclose);
end
 
if cross(hhv(c,25),ref(hhv(h,25),1)*1.00001) and holding>0 and enterbars>0 then begin
    sellshort(1,0,market);
    buy(holding>0,jdss,market);
end
 
if cross(ref(llv(l,25),1)*0.99999,llv(c,25)) and holding=0 then begin
    sell(1,0,market);
    buyshort(holding=0,kkss,thisclose);
end
 
if cross(ref(llv(l,25),1)*0.99999,llv(c,25))  and holding<0  and enterbars>0 then begin
    sell(1,0,market);
    buyshort(holding<0,jkss,market);
end

--  作者:qichao371
--  发布时间:2014/6/6 10:41:15
--  
这个是替换  还是加在下面
--  作者:jinzhe
--  发布时间:2014/6/6 10:43:16
--  
替换原来的
--  作者:qichao371
--  发布时间:2014/6/6 10:44:55
--  

图片点击可在新窗口打开查看此主题相关图片如下:qq截图20140523150005.jpg
图片点击可在新窗口打开查看