以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (http://weistock.com/bbs/index.asp) -- 公式模型编写问题提交 (http://weistock.com/bbs/list.asp?boardid=4) ---- [求助]图表转化为后台自动下单 (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=82197) |
-- 作者:jason123 -- 发布时间:2015/8/10 8:06:36 -- [求助]图表转化为后台自动下单 图表程序结构如下 if cond0 then begin ... if cond1 and (holding=0)then begin BUY(1,B04,LIMITR,A01,1); 开盘开多:=1; ... end if cond2 then begin BUYSHORT(1,B04,LIMITR,A01,1); 开盘开空:=1; ... end GOTO CONTINUELINE@; end if cond3 then begin SELL(1,B04,LIMITR,A02,1); 开盘开多后平多:=1; ... if cond4 then begin BUYSHORT(1,B04,LIMITR,A01,1); 平多后开空:=1; ... end end if cond5 then begin SELLSHORT(1,B04,LIMITR,A02,1); 开盘开空后平空:=1; ... if cond6 then begin BUY(1,B04,LIMITR,A01,1); 平空后开多:=1; ... end end CONTINUELINE@; ...
|
-- 作者:jason123 -- 发布时间:2015/8/10 8:08:02 -- 现在想利用这个模板 ,实现后台持仓自动同步 //注意:不勾选软件自带追单功能,此模型自带 |
-- 作者:jason123 -- 发布时间:2015/8/10 8:17:15 -- 请问如何结合起来呢?目前我两个思路 1 把下单模板红色部分换成//我自定义的 if cond0 then begin ... if cond1 and (holding=0)then begin BUY(1,B04,LIMITR,A01,1); 开盘开多:=1; ... end if cond2 then begin BUYSHORT(1,B04,LIMITR,A01,1); 开盘开空:=1; ... end GOTO CONTINUELINE@; end if cond3 then begin SELL(1,B04,LIMITR,A02,1); 开盘开多后平多:=1; ... if cond4 then begin BUYSHORT(1,B04,LIMITR,A01,1); 平多后开空:=1; ... end end if cond5 then begin SELLSHORT(1,B04,LIMITR,A02,1); 开盘开空后平空:=1; ... if cond6 then begin BUY(1,B04,LIMITR,A01,1); 平空后开多:=1; ... end end CONTINUELINE@; cc:=holding;
if holding>0 and c<ref(c,1) then sell(1,1,market);//开盘开多后平多:=1 if holding<0 and c>ref(c,1) then sellshort(1,1,market);//开盘开空后平空:=1 if holding=0 and c>ref(c,1) then buy(1,1,market); //开盘开多:=1; 平空后开多:=1; if holding=0 and c<ref(c,1) then buyshort(1,1,market);//开盘开空:=1; if not(islastbar) or workmode<>1 then exit; tm:=30;//撤单时间 ac:=\'800988\';//下单账户 wt:=tremainqty(0,ac,stklabel); buyhold:=tbuyholdingex(ac,stklabel,1); sellhold:=tsellholdingex(ac,stklabel,1); if wt>0.5 and tsubmit(0)>tm then tcancelex(1,0,ac,stklabel);//如果用软件自带的撤单功能,这句删除。 if wt<0.5 then begin kc1:=max(cc,0)-buyhold; kc2:=abs(min(cc,0))-sellhold; if kc1<-0.5 then tsell(1,abs(kc1),mkt,0,0,ac),allowrepeat; if kc2<-0.5 then tsellshort(1,abs(kc2),mkt,0,0,ac),allowrepeat; if sellhold<0.5 and kc1>0.5 then tbuy(1,kc1,mkt,0,0,ac),allowrepeat; if buyhold<0.5 and kc2>0.5 then tbuyshort(1,kc2,mkt,0,0,ac),allowrepeat; end |
-- 作者:jason123 -- 发布时间:2015/8/10 8:40:28 -- 思路2,把下单模板插到每个 if then语句里 if cond0 then begin ... if cond1 and (holding=0)then begin //BUY(1,B04,LIMITR,A01,1); 开盘开多:=1; cc:=holding; if holding=0 and 开盘开多then buy(1,1,market); if not(islastbar) or workmode<>1 then exit; tm:=30;//撤单时间 ac:=\'800988\';//下单账户 wt:=tremainqty(0,ac,stklabel); buyhold:=tbuyholdingex(ac,stklabel,1); sellhold:=tsellholdingex(ac,stklabel,1); if wt>0.5 and tsubmit(0)>tm then tcancelex(1,0,ac,stklabel);//如果用软件自带的撤单功能,这句删除。 if wt<0.5 then begin kc1:=max(cc,0)-buyhold; kc2:=abs(min(cc,0))-sellhold; if kc1<-0.5 then tsell(1,abs(kc1),mkt,0,0,ac),allowrepeat; if kc2<-0.5 then tsellshort(1,abs(kc2),mkt,0,0,ac),allowrepeat; if sellhold<0.5 and kc1>0.5 then tbuy(1,kc1,mkt,0,0,ac),allowrepeat; if buyhold<0.5 and kc2>0.5 then tbuyshort(1,kc2,mkt,0,0,ac),allowrepeat; end ... end if cond2 then begin BUYSHORT(1,B04,LIMITR,A01,1); 开盘开空:=1; ... cc:=holding; if holding=0 and 开盘开空 then buyshort(1,1,market); if not(islastbar) or workmode<>1 then exit; tm:=30;//撤单时间 ac:=\'800988\';//下单账户 wt:=tremainqty(0,ac,stklabel); buyhold:=tbuyholdingex(ac,stklabel,1); sellhold:=tsellholdingex(ac,stklabel,1); if wt>0.5 and tsubmit(0)>tm then tcancelex(1,0,ac,stklabel);//如果用软件自带的撤单功能,这句删除。 if wt<0.5 then begin kc1:=max(cc,0)-buyhold; kc2:=abs(min(cc,0))-sellhold; if kc1<-0.5 then tsell(1,abs(kc1),mkt,0,0,ac),allowrepeat; if kc2<-0.5 then tsellshort(1,abs(kc2),mkt,0,0,ac),allowrepeat; if sellhold<0.5 and kc1>0.5 then tbuy(1,kc1,mkt,0,0,ac),allowrepeat; if buyhold<0.5 and kc2>0.5 then tbuyshort(1,kc2,mkt,0,0,ac),allowrepeat; end end GOTO CONTINUELINE@; end if cond3 then begin //SELL(1,B04,LIMITR,A02,1); 开盘开多后平多:=1; ... cc:=holding; if holding=0 and 开盘开多后平多 then sell(1,1,market); if not(islastbar) or workmode<>1 then exit; tm:=30;//撤单时间 ac:=\'800988\';//下单账户 wt:=tremainqty(0,ac,stklabel); buyhold:=tbuyholdingex(ac,stklabel,1); sellhold:=tsellholdingex(ac,stklabel,1); if wt>0.5 and tsubmit(0)>tm then tcancelex(1,0,ac,stklabel);//如果用软件自带的撤单功能,这句删除。 if wt<0.5 then begin kc1:=max(cc,0)-buyhold; kc2:=abs(min(cc,0))-sellhold; if kc1<-0.5 then tsell(1,abs(kc1),mkt,0,0,ac),allowrepeat; if kc2<-0.5 then tsellshort(1,abs(kc2),mkt,0,0,ac),allowrepeat; if sellhold<0.5 and kc1>0.5 then tbuy(1,kc1,mkt,0,0,ac),allowrepeat; if buyhold<0.5 and kc2>0.5 then tbuyshort(1,kc2,mkt,0,0,ac),allowrepeat; end |
-- 作者:jinzhe -- 发布时间:2015/8/10 9:23:56 -- cc:=holding;
粗体的写原来的图表代码,后面的直接照抄,
|
-- 作者:jason123 -- 发布时间:2015/8/10 9:39:38 -- 图表代码有很多条件语句,开仓平仓都在条件语句里面,是否把下单模板插到不同的条件语句里,还是在条件语句定义cond,然后统一在后面下单模板执行? |
-- 作者:jinzhe -- 发布时间:2015/8/10 9:47:02 -- 我的意思是前面的图表代码照抄,而后面的只写一遍,那段同步持仓代码,只要写一遍 |
-- 作者:jason123 -- 发布时间:2015/8/10 10:00:02 -- 那图表代码里面的 开仓平仓语句需要去掉吗? 例如 buy sell这些 |
-- 作者:jinzhe -- 发布时间:2015/8/10 10:02:07 -- 不去掉,原来的照抄 |
-- 作者:jason123 -- 发布时间:2015/8/10 10:20:25 -- 但我要自定义cond 替换掉模板里面的条件如 c>ref(c,1),对吧? |