1.收盘价同时在5日线以及10日线之上时开仓,这时怎样记录开仓位置K线的最高点。
2. 以股指为例,开仓同上,盈利20点以后开始保本止盈,也就是回撤到开仓价+1点时平仓出局。
请问以上语句怎样写啊?多谢。
1.收盘价同时在5日线以及10日线之上时开仓,这时怎样记录开仓位置K线的最高点。
2. 以股指为例,开仓同上,盈利20点以后开始保本止盈,也就是回撤到开仓价+1点时平仓出局。
请问以上语句怎样写啊?多谢。
第一个问题:以hh来表示开仓位置K线最高点
第一种方法:
buycond:=c>ma(c,5) and c>ma(c,10);
selcond:=c<ma(c,5) and c<ma(c,10);
if holding>0 and selcond then sell(1,1,limitr,c);
if holding<0 and buycond then sellshort(1,1,limitr,c);
if holding=0 and buycond then buy(1,1,limitr,c);
if holding=0 and selcond then buyshort(1,1,limitr,c);
hh:=ref(h,enterbars);
第二种方法:
buycond:=c>ma(c,5) and c>ma(c,10);
selcond:=c<ma(c,5) and c<ma(c,10);
if holding>0 and selcond then sell(1,1,limitr,c);
if holding<0 and buycond then sellshort(1,1,limitr,c);
if holding=0 and buycond then begin
buy(1,1,limitr,c);
hh:=h;
end
if holding=0 and selcond then buyshort(1,1,limitr,c);
第二个问题:
见【阿火秘笈】之二
http://www.weistock.com/bbs/dispbbs.asp?boardid=10&Id=9439
很详细。多谢啦。
1. variable:hh=0;
if c>ma5 and c>ma10 then
begin
buy(1,1,market);
hh:=h;
end