以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (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=139349)

--  作者:zwdqx
--  发布时间:2016/9/8 15:54:30
--  以下内容是版主以前的一个模板,初学有点看不懂,请老师解读一下,特别是红色的部分。谢谢!

Global variable: hold=drawnull;

cc800988:=holding;//这句放在信号稳定的地方,

MA5:MA(CLOSE,5);

MA10:MA(CLOSE,10);

buycond:= CROSS(MA5,MA10);
sellcond:= CROSS(MA10,MA5);

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;      怎么在最后定义?不解

[此贴子已经被作者于2016-9-8 15:56:23编辑过]

--  作者:jinzhe
--  发布时间:2016/9/8 16:31:48
--  
这个模版是用来实现什么目的的?
--  作者:zwdqx
--  发布时间:2016/9/8 16:57:45
--  

我是在论坛里找来学习的,想用后台交易做股票,没有找到股票的示范程序。

 

请老师帮我写一个股票程序化交易的程序,用Tbuy这种后台交易语言编写,分析标的:所有股票,用日线周期分析,买卖条件是:
开仓:cross(macd,0);(日线)
平仓:收益达到4%且日线MACD绿柱变短或60分钟DIF小于等于前一周期,平仓时全平。
止损:亏7%。
开仓数量:20000元(股价有高有低,如何转换成数量)

测试成功后购买专业版。我的电话13913992413


--  作者:jinzhe
--  发布时间:2016/9/8 17:12:38
--  

macd:=stkindi(\'\',\'macd.macd1\',0,6);
diff:=stkindi(\'\',\'macd.diff\',0,5);
diff1:=stkindi(\'\',\'macd.diff\',0,5,-1);
if cross(macd,0) then tbuy(tbuyholding(1)=0,20000/close,mkt);
if c>tenterprice*1.04 and tbuyholding(0)>0 and ((macd<0 and abs(macd)<ref(abs(macd),1)) or (diff<=diff1)) then tsell(1,0,mkt);
if c<tenterprice*0.93 and tbuyholding(0)>0 then tsell(1,0,mkt);

 


--  作者:zwdqx
--  发布时间:2016/9/9 8:24:19
--  

老师果真厉害,我一个星期没搞出来,你5分钟就搞定。

请老师帮我按下列要求再完善一下,谢谢!

 

10点钟之前满足cross(macd,0),量比达到6, 主力资金净流入,外盘大于内盘,立即开仓;

10点钟之后满足cross(macd,0),量比达到3, 主力资金净流入,外盘大于内盘,立即开仓;

只满足cross(macd,0),14:55开仓执行;

止盈14:55执行,收益达到4%且日线MACD绿柱变短或60分钟DIF小于等于前一周期,平仓时全平。

止损按触发价立即执行,不必等到14:55;

有仓位的不买,持股超过20交易日强行平仓;

止损:亏7%;
开仓数量:20000元;
分析标的:所有股票。
用Tbuy这种后台交易语言编写!

--  作者:zwdqx
--  发布时间:2016/9/9 8:28:03
--  

老师请再增加一个监控未成交单,如有追单。


--  作者:jinzhe
--  发布时间:2016/9/9 9:04:32
--  
macd:=stkindi(\'\',\'macd.macd1\',0,6);
diff:=stkindi(\'\',\'macd.diff\',0,5);
diff1:=stkindi(\'\',\'macd.diff\',0,5,-1);
if time<100000 and cross(macd,0)and  DYNAINFO( 17)>=6 and buyvol>sellvol then tbuy(tbuyholding(1)=0,20000/close,mkt);
if time>=100000 and cross(macd,0)and  DYNAINFO( 17)>=3 and buyvol<sellvol then tbuy(tbuyholding(1)=0,20000/close,mkt);
if cross(macd,0) and time>=145500 then tbuy(tbuyholding(1)=0,20000/close,mkt);
if time>=145500 and c>tenterprice*1.04 and tbuyholding(0)>0 and ((macd<0 and abs(macd)<ref(abs(macd),1)) or (diff<=diff1)) then tsell(1,0,mkt);
if c<tenterprice*0.93 and tbuyholding(0)>0 then tsell(1,0,mkt);
if tenterbars>=20 then tsell(1,0,mkt);
[此贴子已经被作者于2016-9-9 9:09:20编辑过]

--  作者:zwdqx
--  发布时间:2016/9/9 10:01:43
--  

老师,辛苦了。

 

主力资金净流入是不是无法编写,能不能加一个未成交追单的语句,谢谢主!


--  作者:jinzhe
--  发布时间:2016/9/9 10:03:39
--  

1.不行,没有这类数据

2.用软件自带的撤单追单功能

 


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

--  作者:zwdqx
--  发布时间:2016/9/9 10:15:05
--  

老师,这个程序需不需要设定逐K线或者固定间隔模式?