-- 作者:tyq988
-- 发布时间:2012/12/20 15:14:33
-- 止损和开多在同一K线上,啥意思?
此主题相关图片如下:qq截图20121220151051.png
如上图,开多和止损在同一K线上,我是新手,新高人指点,公式代码为:
MA1:=MA(CLOSE,5); MA2:=MA(CLOSE,30); //移动止损范例 VARIABLE: aspect=0;//初始化假定做多头 VARIABLE: stopprice=0;//止损价格变量 VARIABLE: stopnum=0.002;//止损价差 RUNMODE:0;//工作于逐周期模式
IF CROSS(MA1,MA2) THEN BUY(1,5000); //平仓 SELL(CROSS(MA2,MA1),0);
if barpos = 0 then //当前K线从第一根开始的第几根K线 stopprice := l - stopnum;//止损价格为当前周期的最低价减去止损价差0.002 if aspect = 0 then //如果为多头 begin //多头处理 if l <= stopprice then //如果当前周期的最低价小于等于止损价格,这个止损价格的值是上面得来的 begin //多反空 aspect:=1;//多反空,为空头 stopprice := h+stopnum;//当前止损价格为当前周期的最高价加上止损价差 end //处理移动的底部 if l - stopnum > stopprice then //如果当前周期的最低价减去止损价差大于止损价格, stopprice := l - stopnum; //那么止损价格的值为最低价减去止损价差 end if aspect = 1 then begin //空头处理 if h >= stopprice then begin //空反多 aspect:=0; stopprice:=l-stopnum; end //处理移动的底部 if h + stopnum < stopprice then stopprice := h+stopnum; end if close <= stopprice then 止损:sell(1,0);
|