[求助]以当前K线最低或者最高值与均线距离作为进场条件或离场条件,该怎么写
比如在20均线上方 最低价大于均线,距离均线10个点,开仓做多,最低价跌破均线止损
在20均线下方 最高价小于均线,距离均线10个点,开仓做空,最高价上破均线止损
对代码不熟悉,最好能详细些
ma20:ma(c,20);
duo:l>ma20 and l-ma20>=10*mindiff;
kong:h<ma20 and ma20-h>=10*mindiff;
if duo then buy(holding=0,1,market);
if kong then buyshort(holding=0,1,market);
if cross(ma20,l) and holding>0 then sell(1,0,market);
if cross(h,ma20) and holding<0 then sellshort(1,0,market);