各位老师请教了:文华刚转到金字塔玩不转啊,(头寸函数和全局变量)
目的:当日亏损达到某数目(1000)停止交易。想通过下面小程序学习TACCOUNT函数和全局变量的使用:variable:t=0;
tt:=taccount(4)+taccount(30)<=-1000;
a:=ma(c,3);
sj:=time>009000 and time <145500;
if c>=a and t=1 and sj then
begin
buy(holding=0,1,market);
end
if c<a then
begin
sell(1,0,market);
end
if tt then
begin
sell(holding>0,0,market);
t:=1;
end
if time=closetime(0) then
begin
sell(holding>0,0,market);
t:=0;
end
当全局变量为1时,照样开仓,当亏损达到一定数时,只出现平仓信号,但是不发指令。
应当是
if c>=a and t=0 and sj 在开仓,上面写成了t=1了。更正
日内累计亏损,上次董小球老师让我用TACCOUNT(4)http://www.weistock.com/bbs/dispbbs.asp?boardid=4&Id=5861,这次fly老师建议我图表交易不用,我初学搞不明白,金字塔有没有各个函数文字说明我们初学者好学习呀
你的目的无须用到taccount函数
用全局变量即可
variable:kuisun=0;//该变量记录亏损
entertime:=time<closetime(0);
buycond:=ref(c>o,1) and c>o;
sellcond:=reef(c<o,1) and c<o;
if holding>0 and sellcond then begin
kuisun:=kuisun+min(0,c-enterprice);//平仓之后,把盈亏点数累加到变量kuisun上
sell(1,1,limitr,c);
end
if holding<0 and buycond then begin
kuisun:=kuisun+min(o,enterprice-c););//平仓之后,把盈亏点数累加到变量kuisun上
sellshort(1,1,limitr,c);
end
if holding=0 and entertime and kuisun<100 and buycond then buy(1,1,limitr,c);
if holding=0 and entertime and kuisun<100 and sellcond then buyshort(1,1,limitr,c);
//收盘平仓
if time=closetime(0) then begin
sell(holding>0,1,limitr,o);
sellshort(holding<0,1,limitr,o);
kuisun:=0; //收盘时,要亏损这个变量重新 归零
end