以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  关于后台持仓同步  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=182164)

--  作者:linanmeng
--  发布时间:2020/9/14 9:58:29
--  关于后台持仓同步
请教:以下代码,是阿火的后台持仓同步模版,前5行是否并不是后台用的模版?只是一个图表的开仓程序?
然后,程序中是指定账户下单,如何改成所有账户都能下单(用于机构版多账户)

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

--  作者:FireScript
--  发布时间:2020/9/14 10:07:03
--  
 1.是的。前面部分其实是图表的代码。
2.多账号可以 用多账号组的方式去下单。这样就会对所有账号组下面的账号下单。
进入多账号设置里面把多个账号设成一个组管理就可以了。 你下单语句里面的参数填写账号组的名称就行了。

图片点击可在新窗口打开查看此主题相关图片如下:temp.png
图片点击可在新窗口打开查看



--  作者:linanmeng
--  发布时间:2020/9/14 10:53:43
--  
关于2,因为后台程序里的语句是指定账户的,
比如:ac:=\'800988\';//下单账户
wt:=tremainqty(0,ac,stklabel);
这些语句怎么改成所有账户的?我试着把第二句改成 wt:=tremainqty(0,stklabel);好像是报错!

--  作者:wenarm
--  发布时间:2020/9/14 10:57:02
--  

 

//ac:=\'800988\';//下单账户
wt:=tremainqty(0,\'\',stklabel);

 

 

您蹦到的报错信息,都是语法错误,建议你自己针对错误,查看相关的函数说明

[此贴子已经被作者于2020/9/14 10:57:48编辑过]