请教均线金叉后进场的问题 [MC]
-
MC用户求助:
input: fastlength(20), slowlength(60);
var: fast_ma(0), slow_ma(0), long_flag(-1), short_flag(-1), long_tf(false);
fast_ma=averagefc(close,fastlength); //快线值
slow_ma=averagefc(close,slowlength); //慢线值
if fast_ma cross over slow_ma then begin
long_tf=true;
long_flag=-1;
end
else if fast_ma cross under slow_ma then begin
long_tf=false;
short_flag=-1;
end;
if long_tf then
long_flag=long_flag+1 //当金叉时开始累加long_flag,也就是累加bar的数量
else short_flag=short_flag+1; //当死叉时开始累加short_flag,也就是累加bar的数量
if long_tf and long_flag<=8 and absvalue(close-fast_ma)<=minmove*10 point and marketposition<>1 then
buy next bar at market
else if long_tf and long_flag>8 and absvalue(close-slow_ma)<=minmove*10 point and marketposition<>1 then
buy next bar at market;
if long_tf=false and short_flag<=8 and absvalue(close-fast_ma)<=minmove*10 point and marketposition<>-1 then
sellshort next bar at market
else if long_tf=false and short_flag>8 and absvalue(close-slow_ma)<=minmove*10 point and marketposition<>-1 then
sellshort next bar at market;
特别说明:
将您的多头进场的对应的空头进场也一起编写了,多头策略与空头策略是对称的;并且策略没有考虑到加仓的情况
-
MC回复讨论一:
input: fastlength(20), slowlength(60);
var: fast_ma(0), slow_ma(0), long_flag(-1), short_flag(-1), long_tf(false);
fast_ma=averagefc(close,fastlength); //快线值
slow_ma=averagefc(close,slowlength); //慢线值
if fast_ma cross over slow_ma then begin
long_tf=true;
long_flag=-1;
end
else if fast_ma cross under slow_ma then begin
long_tf=false;
short_flag=-1;
end;
if long_tf then
long_flag=long_flag+1 //当金叉时开始累加long_flag,也就是累加bar的数量
else short_flag=short_flag+1; //当死叉时开始累加short_flag,也就是累加bar的数量
if long_tf and long_flag<=8 and absvalue(close-fast_ma)<=minmove*10 point and marketposition<>1 then
buy next bar at market
else if long_tf and long_flag>8 and absvalue(close-slow_ma)<=minmove*10 point and marketposition<>1 then
buy next bar at market;
if long_tf=false and short_flag<=8 and absvalue(close-fast_ma)<=minmove*10 point and marketposition<>-1 then
sellshort next bar at market
else if long_tf=false and short_flag>8 and absvalue(close-slow_ma)<=minmove*10 point and marketposition<>-1 then
sellshort next bar at market;
特别说明:
将您的多头进场的对应的空头进场也一起编写了,多头策略与空头策略是对称的;并且策略没有考虑到加仓的情况
有思路,想编写各种指标公式,程序化交易模型,选股公式,预警公式的朋友
可联系技术人员 QQ: 511411198 进行 有偿 编写!(不贵!点击查看价格!)
相关文章
-
没有相关内容