K线上穿均线后,收盘价在均线以上 //K线上穿均线,K线的最高价上穿38日均线吗(可以换算成:上根K线收盘价〈38日均线,本根最高价〉38日均线)?
在下一个均线开始时,价格也在均线以上//是指的下一个K线的开盘价大于38日均线吗?
//此策略仅为一个雏形,后续工作人员会持续跟踪调试,请勿直接用于实盘。
input:n(38,5,60,1);
variable:maxprofit=0; //最大获利
win:=0; //盈利
win2:=0; //回调
ma1:ma(c,n);
cond:o>ma1 and cross(ref(h,1),ref(ma1,1)); //开多条件
conk:o<=ma1 and cross(ref(ma1,1),ref(h,1)); //开空条件
if cond then
begin
sellshort(holding<0,holding,MARKET);
buy(holding=0,1,MARKET);
maxprofit:=0;
end
if conk then
begin
sell(holding>0,holding,MARKET);
buyshort(holding=0,1,MARKET);
maxprofit:=0;
end
sells1:l-enterprice>30 and holding>0;
sells2:h-enterprice>30 and holding<0;
if sells1 or sells2 then
begin
zs1:sell(holding>0,holding,MARKET);
zs2:sellshort(holding<0,holding,MARKET);
maxprofit:=0;
end
if holding>0 and enterbars>0 then //计算持多单盈利及回调
begin
win:=(high-enterprice);
if win>maxprofit then maxprofit:=win;
win2:=maxprofit-win;
end
if holding<0 and enterbars>0 then //计算持空单盈利及回调
begin
win:=(low-enterprice);
if win>maxprofit then maxprofit:=win;
win2:=maxprofit-win;
end
selly1:=win>=130 and win<=180 and win2<=105;
selly2:=win>180 and win<=280 and win2<=145;
selly3:=win>280 and win2<=278;
if selly1 or selly2 or selly3 THEN
begin
zy1:sell(holding>0,holding,MARKET);
zy2:sellshort(holding<0,holding,MARKET);
end
cond:o>ma1 and cross(ref(h,1),ref(ma1,1)); //开多条件
以上为本策略中的开多条件,本周期的开盘价在均线之上,且上一周期的最高价上穿均线才开多。一直在均线以上不会触发开多信号。