以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://www.weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://www.weistock.com/bbs/list.asp?boardid=4)
----  新手求教后台下单问题  (http://www.weistock.com/bbs/dispbbs.asp?boardid=4&id=52911)

--  作者:wdbbs
--  发布时间:2013/6/9 8:14:07
--  新手求教后台下单问题
在后台下单时,多策略同品种的干扰情况,看了阿火的写的东西,他是利用后台不执行前台指令,那么中间有一个<0.5和>-0.5是什么意思呢,如果金字塔能够把后台改进一下就好,用前台指定的仓位,然后直接后台下单又简单,又方便,对于我们这些新手,买了机构版,浪费了后台下单功能,后台下单比前台占用资源少,所以下单快.请管理最好能改进下,要不先搞个简单的模板也行呀,先用着
--  作者:jinzhe
--  发布时间:2013/6/9 10:17:10
--  
能不能把阿火的代码都帖一下?
--  作者:wdbbs
--  发布时间:2013/6/9 12:17:23
--  
runmode:0;
Globalvariable:hold=drawnull;
……//这里添加上你自己的模型
……//这里添加上你自己的模型
cc800988:=holding;//这句放在信号稳定的地方
drawtextex(1,1,800,0,\'虚拟持仓为:\'+numtostr(cc800988,0));//在图表上输入虚拟持仓以便监控
if not(islastbar) or workmode<>1 then exit;
xiadan800988:=cc800988-hold;
if xiadan800988>0.5 then begin
 cang:=min(xiadan800988,abs(hold));
 if hold<0 then begin
  tsellshort(1,cang,mkt,0,0,\'800988\'),allowrepeat;
  debugfile(\'D:\\800988.txt\',numtostr(hold,0)+\' \'+numtostr(cc800988,0)+\' 平空 %.0f\',cang);
 end
 cang:=xiadan800988+min(hold,0);
 if cang>0 then begin
  tbuy(1,cang,mkt,0,0,\'800988\'),allowrepeat;
  debugfile(\'D:\\800988.txt\',numtostr(hold,0)+\' \'+numtostr(cc800988,0)+\' 开多 %.0f\',cang);
 end
end
if xiadan800988<-0.5 then begin
 cang:=min(abs(xiadan800988),abs(hold));
 if hold>0 then begin
  tsell(1,cang,mkt,0,0,\'800988\'),allowrepeat;
  debugfile(\'D:\\800988.txt\',numtostr(hold,0)+\' \'+numtostr(cc800988,0)+\' 平多 %.0f\',cang);
 end
 cang:=abs(xiadan800988)-max(hold,0);
 if cang>0 then begin
  tbuyshort(1,cang,mkt,0,0,\'800988\'),allowrepeat;
  debugfile(\'D:\\800988.txt\',numtostr(hold,0)+\' \'+numtostr(cc800988,0)+\' 开空 %.0f\',cang);
 end
end
hold:=cc800988;
 
 
 
 
完整实例如下:
实例一、 K线走完模式的模型
Globalvariable:hold=drawnull;
cc800988:=holding;//这句放在信号稳定的地方
//蓝色部分改为你自己的模型(K线走完模型)
buycond:=count(c>o,2)=2;
sellcond:=count(c<o,2)=2;
if holding>0 and sellcond then sell(1,1,thisclose);
if holding<0 and buycond then sellshort(1,1,thisclose);
if holding=0 and buycond then buy(1,1,thisclose);
if holding=0 and sellcond then buyshort(1,1,thisclose);
 
drawtextex(1,1,800,0,\'虚拟持仓为:\'+numtostr(cc800988,0));//在图表上输入虚拟持仓以便监控
if not(islastbar) or workmode<>1 then exit;
xiadan800988:=cc800988-hold;
if xiadan800988>0.5 then begin
 cang:=min(xiadan800988,abs(hold));
 if hold<0 then begin
  tsellshort(1,cang,mkt,0,0,\'800988\'),allowrepeat;
  debugfile(\'D:\\800988.txt\',numtostr(hold,0)+\' \'+numtostr(cc800988,0)+\' 平空 %.0f\',cang);
 end
 cang:=xiadan800988+min(hold,0);
 if cang>0 then begin
  tbuy(1,cang,mkt,0,0,\'800988\'),allowrepeat;
  debugfile(\'D:\\800988.txt\',numtostr(hold,0)+\' \'+numtostr(cc800988,0)+\' 开多 %.0f\',cang);
 end
end
if xiadan800988<-0.5 then begin
 cang:=min(abs(xiadan800988),abs(hold));
 if hold>0 then begin
  tsell(1,cang,mkt,0,0,\'800988\'),allowrepeat;
  debugfile(\'D:\\800988.txt\',numtostr(hold,0)+\' \'+numtostr(cc800988,0)+\' 平多 %.0f\',cang);
 end
 cang:=abs(xiadan800988)-max(hold,0);
 if cang>0 then begin
  tbuyshort(1,cang,mkt,0,0,\'800988\'),allowrepeat;
  debugfile(\'D:\\800988.txt\',numtostr(hold,0)+\' \'+numtostr(cc800988,0)+\' 开空 %.0f\',cang);
 end
end
hold:=cc800988;

 
 
 
实例二、即时下单模型(固定时间间隔)
Globalvariable:hold=drawnull;
//蓝色部分改为你自己的模型
buycond:=h>ref(hhv(h,10),1);
sellcond:=l<ref(llv(l,10),1);
if holding>0 and sellcond then sell(1,1,market);
if holding<0 and buycond then sellshort(1,1,market);
if holding=0 and buycond then buy(1,1,market);
if holding=0 and sellcond then buyshort(1,1,market);
cc800988:=holding;//这句放在信号稳定的地方

drawtextex(1,1,800,0,\'虚拟持仓为:\'+numtostr(cc800988,0));//在图表上输入虚拟持仓以便监控
if not(islastbar) or workmode<>1 then exit;
xiadan800988:=cc800988-hold;
if xiadan800988>0.5 then begin
 cang:=min(xiadan800988,abs(hold));
 if hold<0 then begin
  tsellshort(1,cang,mkt,0,0,\'800988\'),allowrepeat;
  debugfile(\'D:\\800988.txt\',numtostr(hold,0)+\' \'+numtostr(cc800988,0)+\' 平空 %.0f\',cang);
 end
 cang:=xiadan800988+min(hold,0);
 if cang>0 then begin
  tbuy(1,cang,mkt,0,0,\'800988\'),allowrepeat;
  debugfile(\'D:\\800988.txt\',numtostr(hold,0)+\' \'+numtostr(cc800988,0)+\' 开多 %.0f\',cang);
 end
end
if xiadan800988<-0.5 then begin
 cang:=min(abs(xiadan800988),abs(hold));
 if hold>0 then begin
  tsell(1,cang,mkt,0,0,\'800988\'),allowrepeat;
  debugfile(\'D:\\800988.txt\',numtostr(hold,0)+\' \'+numtostr(cc800988,0)+\' 平多 %.0f\',cang);
 end
 cang:=abs(xiadan800988)-max(hold,0);
 if cang>0 then begin
  tbuyshort(1,cang,mkt,0,0,\'800988\'),allowrepeat;
  debugfile(\'D:\\800988.txt\',numtostr(hold,0)+\' \'+numtostr(cc800988,0)+\' 开空 %.0f\',cang);
 end
end
hold:=cc800988;



--  作者:双保险
--  发布时间:2013/6/9 14:33:13
--  
同问。图片点击可在新窗口打开查看
--  作者:jinzhe
--  发布时间:2013/6/13 10:20:49
--  

不明白这个相减再和0.5比较是什么意思。。。

等阿火来说明一下


--  作者:多,额
--  发布时间:2013/6/13 12:58:24
--  
呵呵, 火老大要出手了。