-- 作者:淡定688
-- 发布时间:2011/9/8 23:04:04
-- [求助]二个模块的结合
请求开仓模块与止损模块的结合! 开仓模块 //////波动突破策略////// input:volatility(14,1,60,1); jysj:=time >=090000 and time <=145500; dist:=barslast(date <> ref(date,1)); oo:=ref(open,dist); highest:=oo + volatility * mindiff; lowest:=oo - volatility * mindiff; buycond:=jysj and HIGH >=highest; buyprice:=max(open,highest); buyshortcond:=jysj and LOW <=lowest; buyshortprice:=min(open,lowest); if holding=0 and buycond then begin buy(1,1,limitr,buyprice); //开多 , end if holding = 0 and buyshortcond then begin buyshort(1,1,limitr,buyshortprice); end //收盘前5分钟平仓 if time > 145500 then begin sell(holding > 0, 0, thisclose); sellshort(holding < 0, 0, thisclose); end 止损模块 {ATR Stop} INPUT:N(20,1,100,1),M(30,1,100,5),P(0,0,100,1); RUNMODE:0; //使用逐周期运行模式 variable:sarx=0; variable:value=0; variable:Trend=0; //ATR:=STD(C,N); ATR:=ma(tr,N); S0:=C-ATR*M*0.1; S1:=C+ATR*M*0.1; if barpos <= N then exit;//不到CYC的统计周期,直接退出等待下个周期再做判断
if barpos = N+1 then begin if (high[barpos]-high[barpos-1])+(low[barpos]-low[barpos-1]) > 0 then begin //看跌 Trend:= -1; sarx:=S1; value:=S1; end else begin //看涨 Trend:= 1; sarx:=S0; value:=S0; end GOTO ENDANDSHOW;//跳转到末尾直接显示 End if Trend > 0 then begin if C >= value then begin sarx:=max(value+0.01*ATR*P,S0); value:=sarx; end else begin sarx:=S1; value:=sarx; Trend:=-1; end GOTO ENDANDSHOW; end if Trend < 0 then begin if C <= value then begin sarx:=min(value-0.01*ATR*P,S1); value:=sarx; end else begin sarx:=S0; value:=sarx; Trend:=1; end GOTO ENDANDSHOW; end //显示变量 ENDANDSHOW@; //此为语句标号,GOGO语句可以用这个标号直接跳转到这里 IF Trend=1 then sarx,CIRCLEDOT,colorred; else sarx,CIRCLEDOT,colorgreen;
|