开仓条件:如果15天的移动平均线大于30天均线,并且30天均线大于45天平均线,即开仓
平仓条件:
1、如果价格上涨,涨幅达到开仓价格的7%时,平仓一半(在K线上标注“减仓”)
2、当涨幅达到10%时平仓另一半(在K线上标注“平仓”)
3、如果价格下跌,当价格跌到开仓价的7%时平仓
ma15:ma(c,15);
ma30:ma(c,30);
ma45:ma(c,45);
input:n(2,1,100,1);
if ma15>ma30 and ma30>ma45 then buy(holding=0,n,market);
if (h-enterprice)/enterprice>=0.07 and (h-enterprice)/enterprice<0.10 then 减仓:sell(1,holding/2,market);
if (h-enterprice)/enterprice>=0.10 then 平仓:sell(1,holding/2,market);
if (enterprice-l)/enterprice<0.07 then sell(1,0,market);