开仓用MA5大于收盘价 作为条件?还是其他自定义的指标线吗?说清楚点。
就一条MA5线,线上收盘开多,线下收盘开空,加上上面的止损止盈,麻烦了谢谢老师
Q:C;//也可以自定义其他指标线
ma5:ma(c,5);
if q>ma5 then //开多前必须平空,反之亦然。
begin
sellshort(holding<0,holding,market);
buy(holding=0,1,market);
end
if holding>0 and c<ref(l,ENTERBARS) then sell(holding>0,holding,market); //止损1
if q<ma5 then
begin
sell(holding>0,holding,market);
buyshort(holding=0,1,market);
end
if holding>0 and c>ref(h,ENTERBARS) then sellshort(holding<0,holding,market);//止损
maxProfitA:hhv(h,ENTERBARS)-ENTERPRICE;//获取开多仓以来最大盈利
maxProfitB:ENTERPRICE-llv(l,ENTERBARS);//获取开空仓以来最大盈利
cproA:c-ENTERPRICE<maxProfitA-5;
cproB:ENTERPRICE-c<maxProfitB-5;
if (maxProfitA>10*mindiff or maxProfitB>10*mindiff) and holding<>0 and (cproA or cproB) then
begin
sellshort(holding<0,holding,market);
sell(holding>0,holding,market);
end
cd:holding;
大致的一个范例,可以根据你自己需求的细节继续修改即可。
老师,麻烦帮我再修改一下,不要定义Q,就单独MA5一条均线
就MA5线上多线下反手开,止损止盈同上
谢谢
K线收盘价在MA5
均线上面下一根K线就开多单,止损点是开仓价K线前一根K线最低点,保本止盈点是盈利10个点后激活保本止盈条件功能,如果回撤至5个点保本止盈平仓K线收盘价在MA5均线下面就平仓多单反手开空单,止损点是开仓价K线前一根K线最高点,保本止盈点是盈利10个点后激活保本止盈条件功能,如果回撤至5个点保本止盈平仓