程式碼如下
// 宣告參數 input: profit_point2(2, "停利(%)");
input: FastLength(12, "DIF短期期數"), SlowLength(26, "DIF長期期數"), MACDLength(9, "MACD期數");
variable: difValue(0), macdValue(0), oscValue(0);
// 資料讀取筆數設定 SetTotalBar((maxlist(FastLength,SlowLength,6) + MACDLength) * 3 + 8);
MACD(weightedclose(), FastLength, SlowLength, MACDLength, difValue, macdValue, oscValue);
// 多方進場策略:DIF-MACD由負轉正。
if oscValue Crosses Above 0 then setposition(1);
if profit_point2 > 0 and Close >= FilledAvgPrice*(1+0.03) then SetPosition(0); // 停利 }
回測設定日頻率時間為8/21-9/2,8/24當日的OSC並未由負轉正,為何交易發生在8/24 09:01 1860這個時間點價位?
1 評論