小幫手請教
在回測時候,腳本觸發了停利訊號,而由於是12:45-13:45的收盤觸發,所以我設立了下午盤開盤停利,如下腳本粗體部份。
但圖片中的print數值,紀錄前K收價17085沒有問題,停利點=17185,卻不會在15:00出場,不知道是我邏輯哪邊不完善呢?在煩請指教,感謝。
//==============================================================
//檢查出場條件:停利
//==============================================================
//多停利
if position>0 and filled>0 and C>filledAvgPrice then
begin
if maxList(C-stop_point,simpleLowest(L,stop_length)) > bout then bout = maxList(C-stop_point,simpleLowest(L,stop_length));
if time = 150000 and C[1] < bout[1] then setposition(0,market,label:="做多停利");
if C < bout then setposition(0,market,label:="做多停利");
_stop_profit = bout - filledAvgPrice;
print(file("f:\Users\USER\Desktop\平台型態\台期程式交易\"),text("日期",dateToString(date), "時間",timeToString(time),
"。前根收價:",NumToStr(C[1],0),"。停利出場點:",NumToStr(bout,0),"。停利總點數:",NumToStr(_stop_profit,0)));
end;
//空停利
if position<0 and filled<0 and C<filledAvgPrice then
begin
if minList(C+stop_point,simplehighest(H,stop_length)) < sout then sout = minList(C+stop_point,simplehighest(H,stop_length));
if time = 150000 and C[1] > sout[1] then setposition(0,market,label:="做空停利");
if C > sout then setposition(0,market,label:="做空停利");
_stop_profit = sout - filledAvgPrice;
print(file("f:\Users\USER\Desktop\平台型態\台期程式交易\"),text("日期",dateToString(date), "時間",timeToString(time),
"。前根收價:",NumToStr(C[1],0),"。停利出場點:",NumToStr(sout,0),"。停利總點數:",NumToStr(_stop_profit,0)));
end;
7 評論