Input: filterLength(2), LEN(22), maLength(8);
Var: atrValue(0), highPoint(0), lowPoint(0), maValue(0);
// 設定需要計算資料的歷史K棒數量
SetTotalBar(LEN + maLength + 20);
// 計算技術指標
atrValue = ATR(10);
highPoint = Highest(High, LEN);
lowPoint = Lowest(Low, LEN);
maValue = Average(Close, maLength);
// 僅在有進出場意義時才處理:ATR大於filterLength
If atrValue > filterLength Then Begin
// 先處理出場條件(因為出場條件優先度較高)
// 空單出場條件:Position < 0 且 close > maValue
// 多單出場條件:Position > 0 且 close < maValue
If Position < 0 And Close > maValue Then Begin
// 平空單
SetPosition(0);
End Else If Position > 0 And Close < maValue Then Begin
// 平多單
SetPosition(0);
End Else If Position = 0 Then Begin
// 若目前空手,檢查進場
// 進場條件:
// 若 close < highPoint => 買進,以highPoint為委託價格
If Close < highPoint Then Begin
SetPosition(1, highPoint);
End Else If Close > lowPoint Then Begin
// 若 close > lowPoint => 做空,以lowPoint為委託價格
SetPosition(-1, lowPoint);
End;
End;
End; // end of atrValue > filterLength
請問我把這個丟到自動交易腳本去回測時
為什麼都變成每一分鐘進出一次呢?
我是要用日K的技術指標去判斷進出
都已經勾選日頻率了
怎麼還是用一分K去判斷呢?
1 評論