Rss & SiteMap

金字塔客服中心 - 专业程序化交易软件提供商 http://www.weistock.com/bbs/

专业程序化软件提供商
共10 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:[求助]自动交易测试代码,求教老师

1楼
lenghang 发表于:2012/11/29 15:14:41

当满足A A1 A2 时多头信号出现

当满足B B1 B2时空头信号出现;

要编写一个,当出现A信号时开多10%仓位,后面出现同方向满足A信号时不管他,出现A1 多头信号时加仓10%,出现A2多头时再加仓10%

当出现空头信号时(无论B B1 B2) 平多开空,加仓操作同上。

 

请教老师这个代码要怎么写

谢谢指点!

2楼
jinzhe 发表于:2012/11/29 15:27:55

variable:n=0,m=0;

 

if a and n=0 then begin

buy(holding=0 ,10%,market);

n:=1;

end

 

if a1 and n=1 then begin

buy(1,10%,market);

n:=2;

end

 

if a2 and n=2 then begin

buy(1,10%,market);

n:=3;

end

 

if b or b1 or b2 then begin

sell(1,0,market);

buyshort(holding=0,1,10%);

n:=0;

end

 

if b and m=0 then begin

buyshort(holding=0 ,10%,market);

m:=1;

end

 

if b1 and m=1 then begin

buyshort(1,10%,market);

m:=2;

end

 

if b2 and m=2 then begin

buyshort(1,10%,market);

m:=3;

end

3楼
lenghang 发表于:2012/11/29 15:54:25
先谢谢,我试试看
4楼
lenghang 发表于:2012/11/29 16:12:36
REF 函数在逐K线模式下不能直接在IF控制语句之内引用。请参阅帮助公式部分的解决方案。 这是为什么,求教老师
5楼
jinzhe 发表于:2012/11/29 16:23:36

把带ref的条件写在if外面

6楼
lenghang 发表于:2012/11/29 17:08:17
但是我的A B 等条件里是有REF函数的啊,出信号的条件里包含了REF函数
7楼
jinzhe 发表于:2012/11/29 17:26:32

你把ref写进了if后面的then里面了,比如 if    then   b:=ref(a,1);

这个要写在外面 aa:=ref(a,1)  if   then b:=aa;

类似这样改

8楼
lenghang 发表于:2012/11/29 17:41:42
好的,谢谢
9楼
lenghang 发表于:2012/12/1 9:45:48
我测试起来怎么钱变没了,这怎么可能?
10楼
jinzhe 发表于:2012/12/3 9:18:12

http://www.weistock.com/bbs/dispbbs.asp?boardid=4&Id=332

参考问题21

共10 条记录, 每页显示 10 条, 页签: [1]


Powered By Dvbbs Version 8.3.0
Processed in 0.03418 s, 3 queries.