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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → [求助]图表转化为后台自动下单

   

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


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

主题:[求助]图表转化为后台自动下单

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


加好友 发短信
等级:论坛游民 帖子:246 积分:0 威望:0 精华:0 注册:2015/7/20 9:05:58
[求助]图表转化为后台自动下单  发帖心情 Post By:2015/8/10 8:06:36    Post IP:125.91.24.242[只看该作者]

图表程序结构如下

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
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游民 帖子:246 积分:0 威望:0 精华:0 注册:2015/7/20 9:05:58
  发帖心情 Post By:2015/8/10 8:08:02    Post IP:125.91.24.242[只看该作者]

现在想利用这个模板 ,实现后台持仓自动同步

//注意:不勾选软件自带追单功能,此模型自带
//固定1秒轮询
cc:=holding;
if holding>0 and c<ref(c,1) then sell(1,1,market);
if holding<0 and c>ref(c,1) then sellshort(1,1,market);
if holding=0 and c>ref(c,1) then buy(1,1,market);
if holding=0 and c<ref(c,1) 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



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


加好友 发短信
等级:论坛游民 帖子:246 积分:0 威望:0 精华:0 注册:2015/7/20 9:05:58
  发帖心情 Post By:2015/8/10 8:17:15    Post IP:125.91.24.242[只看该作者]

请问如何结合起来呢?目前我两个思路
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
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游民 帖子:246 积分:0 威望:0 精华:0 注册:2015/7/20 9:05:58
  发帖心情 Post By:2015/8/10 8:40:28    Post IP:125.91.24.242[只看该作者]

思路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
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:罗宾汉 帖子:46311 积分:50819 威望:0 精华:2 注册:2011/3/23 8:50:25
  发帖心情 Post By:2015/8/10 9:23:56    Post IP:58.246.57.26[只看该作者]

cc:=holding;
if holding>0 and c<ref(c,1) then sell(1,1,market);
if holding<0 and c>ref(c,1) then sellshort(1,1,market);
if holding=0 and c>ref(c,1) then buy(1,1,market);
if holding=0 and c<ref(c,1) 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

 

粗体的写原来的图表代码,后面的直接照抄,

 



金字塔—专业程序化交易量化投资平台

客户服务部

----------------------------------------------------------- 欢迎您参加我公司的技术培训,具体培训需求请发邮件到service@weistock.com

您的宝贵建议或者投诉,请发往邮箱:weiwei@weistock.com

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


加好友 发短信
等级:论坛游民 帖子:246 积分:0 威望:0 精华:0 注册:2015/7/20 9:05:58
  发帖心情 Post By:2015/8/10 9:39:38    Post IP:125.91.24.242[只看该作者]

图表代码有很多条件语句,开仓平仓都在条件语句里面,是否把下单模板插到不同的条件语句里,还是在条件语句定义cond,然后统一在后面下单模板执行?

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


加好友 发短信
等级:罗宾汉 帖子:46311 积分:50819 威望:0 精华:2 注册:2011/3/23 8:50:25
  发帖心情 Post By:2015/8/10 9:47:02    Post IP:58.246.57.26[只看该作者]

我的意思是前面的图表代码照抄,而后面的只写一遍,那段同步持仓代码,只要写一遍



金字塔—专业程序化交易量化投资平台

客户服务部

----------------------------------------------------------- 欢迎您参加我公司的技术培训,具体培训需求请发邮件到service@weistock.com

您的宝贵建议或者投诉,请发往邮箱:weiwei@weistock.com

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


加好友 发短信
等级:论坛游民 帖子:246 积分:0 威望:0 精华:0 注册:2015/7/20 9:05:58
  发帖心情 Post By:2015/8/10 10:00:02    Post IP:125.91.24.242[只看该作者]

那图表代码里面的 开仓平仓语句需要去掉吗? 例如 buy sell这些

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


加好友 发短信
等级:罗宾汉 帖子:46311 积分:50819 威望:0 精华:2 注册:2011/3/23 8:50:25
  发帖心情 Post By:2015/8/10 10:02:07    Post IP:58.246.57.26[只看该作者]

不去掉,原来的照抄


金字塔—专业程序化交易量化投资平台

客户服务部

----------------------------------------------------------- 欢迎您参加我公司的技术培训,具体培训需求请发邮件到service@weistock.com

您的宝贵建议或者投诉,请发往邮箱:weiwei@weistock.com

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


加好友 发短信
等级:论坛游民 帖子:246 积分:0 威望:0 精华:0 注册:2015/7/20 9:05:58
  发帖心情 Post By:2015/8/10 10:20:25    Post IP:125.91.24.242[只看该作者]

但我要自定义cond 替换掉模板里面的条件如 c>ref(c,1),对吧?

 回到顶部
总数 25 1 2 3 下一页