想請教寫了以下交易腳本請問為何大小台測試出來的數據不一樣呢?
if barfreq <> "min" or barInterval<>30 then raiseruntimeerror ("本腳本只適用於30分K");
var: stop_point(0), controller(0);
value1 = highest(C[1],20);
value2 = lowest(C[1],20);
input: profit_point(100, "停利(點)");
input: profit_drawback_point(50, "停利回跌(點)");
input: loss_point(100, "停損(點)");
condition1 = c>value1;
condition2 = c<value2;
if profit_point = 0 then raiseruntimeerror("請設定停利(點)");
if profit_drawback_point = 0 then raiseruntimeerror("請設定停利回跌(點)");
if profit_drawback_point > profit_point then raiseruntimeerror("停利(點)需大於停利回跌(點)");
if position = 0 and filled = 0 and condition1 then setposition(1, market);
if position = 0 and filled = 0 and condition2 then setposition(-1, market);
if Position = -1 and Filled = -1 then begin
var: intrabarpersist max_profit_point(0);{ 啟動停利後最大獲利點 }
if loss_point > 0 and Close >= FilledAvgPrice + loss_point then begin{ 停損 }
SetPosition(0);
max_profit_point = 0;
end else begin{ 判斷是否要啟動停利 }
if max_profit_point = 0 and Close <= FilledAvgPrice - profit_point then begin
max_profit_point = Close;
end;
if max_profit_point <> 0 then begin
if Close >= max_profit_point + profit_drawback_point then begin{ 停利 }
SetPosition(0);
max_profit_point = 0;
end else if Close < max_profit_point then begin{ 移動最大獲利點 }
max_profit_point = Close;
end;
end;
end;
end;
if Position = 1 and Filled = 1 then begin
if loss_point > 0 and Close <= FilledAvgPrice - loss_point then begin{ 停損 }
SetPosition(0);
max_profit_point = 0;
end else begin{ 判斷是否要啟動停利 }
if max_profit_point = 0 and Close >= FilledAvgPrice + profit_point then begin
max_profit_point = Close;
end;
if max_profit_point <> 0 then begin
if Close <= max_profit_point - profit_drawback_point then begin{ 停利 }
SetPosition(0);
max_profit_point = 0;
end else if Close > max_profit_point then begin{ 移動最大獲利點 }
max_profit_point = Close;
end;
end;
end;
end;


1 評論