开仓盈利10个点后,自动设置止损在开仓价位置;图表自动交易怎么写?
以多头为例,空头可以仿照这个写下。
zy:holding>0 and (hhv(h,ENTERBARS+2)-ENTERPRICE)>10*MINDIFF and c<=ENTERPRICE;
if zy then sell(holding>0,holding,market);
zy2:holding<0 and (ENTERPRICE-llv(l,ENTERBARS+2))>10*MINDIFF and c>=ENTERPRICE;
if zy2 then sellshort(holding<0,holding,market);
zy:holding>0 and (hhv(h,ENTERBARS+2)-ENTERPRICE)>10*MINDIFF and c<=ENTERPRICE; if zy then sell(holding>0,holding,market);
zy2:holding<0 and (ENTERPRICE-llv(l,ENTERBARS+2))>10*MINDIFF and c>=ENTERPRICE; if zy2 then sellshort(holding<0,holding,market); |
|
老师:在上面语句中加入,开仓盈利50个点后止损移动到开仓价+5个点,多仓,空仓头都写一下,谢谢
修改下数值就可以了。
zy3:holding>0 and (hhv(h,ENTERBARS+2)-ENTERPRICE)>50*MINDIFF and c<=ENTERPRICE+5*MINDIFF;
if zy3 then sell(holding>0,holding,market);
zy4:holding<0 and (ENTERPRICE-llv(l,ENTERBARS+2))>50*MINDIFF and c>=ENTERPRICE-5*MINDIFF;
if zy4 then sellshort(holding<0,holding,market);