以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (http://weistock.com/bbs/index.asp) -- 公式模型编写问题提交 (http://weistock.com/bbs/list.asp?boardid=4) ---- 怎么控制加仓次数 (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=25323) |
-- 作者:ericsun1981 -- 发布时间:2012/9/9 9:53:03 -- 怎么控制加仓次数 if long and cc<=3 then
begin
buy(holding>= 0 , 45%,thisclose);
cc:=cc+1;
end if LONGSELL then
begin
sell(holding > 0, 0,thisclose);
cc:=0;
end 用CC变量控制加仓次数,好像不能控制,想知道怎么控制加仓次数
|
-- 作者:admin -- 发布时间:2012/9/9 19:12:44 -- 将代码发全,我们帮你看看 |
-- 作者:董小球 -- 发布时间:2012/9/10 9:18:57 -- 用这种普通的变量作为计数是不行的,你要用全局变量才可以,看看下面网址: |
-- 作者:ericsun1981 -- 发布时间:2012/9/10 11:24:22 -- //画出多头的止损线 partline(holding>0,LL,colorred); LONGSELL:=C<LL; if LONGSELL then
begin
sell(holding > 0, 0,thisclose);
cc:=0;
end DRAWnumber(c>0,c*1.001,cc,0); //建立多头的进场条件 long :=c>upperband and time>N and time<143000 ; if long and cc<=3 then
begin
buy(holding>= 0 , 45%,thisclose);
cc:=cc+1;
end //画出空头的止损线 partline(holding<0, HH, colorgreen); SHORTSELL:=C>HH; if SHORTSELL then
begin
sellSHORT(holding < 0, 0,thisclose);
dd:=0;
end
DRAWnumber(c>0,c*1.002,dd,0); //开空条件 short :=c<lowerband and time > N and time <143000; if short and dd<=3 then
begin
buyshort(holding <= 0 , 45%, thisclose);
dd:=dd+1;
end 好了,开空和开多分别用CC和DD控制就可以了,如果开空和开多都用CC控制,就会出现问题。
|
-- 作者:ericsun1981 -- 发布时间:2012/9/10 11:36:30 -- 都用CC控制的时候,把HOLDING条件提上来也没有问题的。 是我模型中开多的时候,平空条件满足了,把CC赋值0的缘故。 |