1 想在买入后做一个加仓追入。是否可以这样写
如果买了一手
if holding=1 then begin
if jiacang1 then begin
buy()
end
end
如果买了两手
if holding=2 then begin
if jiacang1 then begin
buy()
end
end
还是只能用Holding>0写加仓
2 如果想获得第一次买入时候的价格。应如下方法
jiage1:=enterprice;
那么第二次追入的价格,是否还是如此定义,是否会与第一次买入价格冲突?
jiage2:=enterprice;
谢谢
不行,enterprice 是记录上传开仓价格,如果开2次仓,它取的是最后一次开仓价,
你要用全局变量记录每次开仓价,例如
VARIABLE:a1=0;
if date=1141225 and time=100000 then begin
buy(1,1,market);
a1:=enterprice;
end
if date=1141226 and time=100000 then begin
buy(1,1,market);
a2:=enterprice;
end
a1是第一次开仓价,a2是第二次开仓价。
[此贴子已经被作者于2014/12/29 9:37:19编辑过]
可以用typebar
比如你要求之前2次的开多价格就是
ref(enterprice,typebar(2,1))
我采用 了 jiage:=ref(enterprice,typebar(2,1)),
第一次买入
lz1:=cross(ma1,ma2);
lz1:=close;
第二次买入
lz2:=cross(ma1,ma3);
lz2:=close;
第三次买入
lz2:=cross(ma1,ma4);
lz2:=close;
是否对应价格如下
jiage1:=ref(enterprice,typebar(3,1)); 第一次买入
jiage2:=ref(enterprice,typebar(2,1)); 第二次买入
jiage3:=ref(enterprice,typebar(1,1)); 第三次买入
我尝试了一下,似乎都是上次买的价格。
jiage2:=ref(enterprice,typebar(3,1)) 应放在end里面还是外面?
if long1 and dc<ci then begin
多1:buy(1,lots,limitr,close);
dc:=dc+1;
end
谢谢
那么在代码里面多写几次开仓,就一个开仓信号不会出现好几个开仓价格
[此贴子已经被作者于2014/12/29 14:17:29编辑过]