下面程式碼用60秒K回測, 用到 intrabarpersist 作訊號進出場,但是卻只能用重播方式 ,才會訊號進出
所以程式要怎麼改才能
1.細部回測
2.跑最佳化
inputs:vl(20); vars:intrabarpersist TUVol(0),intrabarpersist TDVol(0),intrabarpersist TUpTicks(0), intrabarpersist TDownticks(0), intrabarpersist TPreTime_s(0),intrabarpersist TTime_s(0), TColor(0); if LastBarOnChart_s then begin TPreTime_s=TTime_s; TTime_s=barnumber; if TPreTime_s<>TTime_s then begin TUVol=0; TDVol=0; end; if UpTicks-TUpTicks>=VL then TUVol=TUVol+UpTicks-TUpTicks; if DownTicks-TDownticks>=VL then TDVol=TDVol+DownTicks-TDownticks; if TUVol>TDVol then TColor=red else TColor=green; TUpTicks=UpTicks; TDownticks=Downticks; end;
寫成訊號就有你要的功能,指標沒有
HI:
我在訊號中用print的方式,data2都是0
inputs:vl(20); vars:intrabarpersist TUVol(0),intrabarpersist TDVol(0),intrabarpersist TUpTicks(0), intrabarpersist TDownticks(0), intrabarpersist TPreTime_s(0),intrabarpersist TTime_s(0), TColor(0); if LastBarOnChart_s then begin TPreTime_s=TTime_s; TTime_s=barnumber; if D<>D[1] then begin TUVol=0; TDVol=0; end; if UpTicks-TUpTicks<=vl then TUVol=TUVol+UpTicks-TUpTicks; if DownTicks-TDownticks<=vl then TDVol=TDVol+DownTicks-TDownticks; if TUVol>TDVol then TColor=red else TColor=green; TUpTicks=UpTicks; TDownticks=Downticks; end; print(date,time,TUpTicks-TDownticks);
這樣就可以了,謝謝
inputs:vl(20); vars:TUVol(0),TDVol(0),TUpTicks(0),TDownticks(0), TPreTime_s(0),TTime_s(0), TColor(0); TPreTime_s=TTime_s; TTime_s=barnumber; if D<>D[1] then begin TUVol=0; TDVol=0; end; if UpTicks-TUpTicks<=20 then TUVol=TUVol+UpTicks-TUpTicks; if DownTicks-TDownticks<=20 then TDVol=TDVol+DownTicks-TDownticks; if TUVol>TDVol then TColor=red else TColor=green; TUpTicks=UpTicks; TDownticks=Downticks; print(date,time,TUVol-TDVol);