程式碼如下,想法為
開盤大於昨天收盤價 ,新一筆交易大於前筆交易時,買進一張
開盤小於昨天收盤價 ,新一筆交易小於前筆交易時,賣出一張
為何回測時無交易紀錄?
if position=0 and filled=0
then begin
if openD(0) > closeD(1) and close > close[1] then setposition(1,market,label:="買1");
if openD(0) < closeD(1) and close < close[1] then setposition(-1,market,label:="賣1");
end;
input: X1(6,">買進有漲%停利"),X2(15,"<買進有跌%停損"),X3(6,"<賣出有跌%停利"),X4(15,">賣出有漲%停損");
value95=100 * (Close - FilledAvgPrice) / FilledAvgPrice; //停利停損%
if position<>0 and filled<>0 then begin
if filled=1 and close >=X1 then setposition(0,close);
if filled=1 and value95 <=-x2 then setposition(0,close);
if filled=-1 and close <=X3 then setposition(0,close);
if filled=-1 and value95 >=x4 then setposition(0,close);
end;
6 評論