input:profit_point(50,"停利%");
input:profit_drawback_point(3,"停利回跌%");
input:loss_point(3,"停損%");
if position>0 and filled>0 then begin
//移動停利條件
if profit_point = 0 then raiseruntimeerror("請設定停利%");
if profit_drawback_point = 0 then raiseruntimeerror("請設定停利回跌%");
if profit_drawback_point > profit_point then raiseruntimeerror("停利需大於停利回跌");
var: intrabarpersist max_profit_point(0); { 啟動停利後最大獲利點 }
{ 停損 }
if loss_point > 0 and Close<FilledAvgPrice*(1-(0.01*loss_point)) then begin
SetPosition(0,market);
max_profit_point = 0;
end;
{ 判斷是否要啟動停利 }
if max_profit_point = 0 and close>=FilledAvgPrice then begin
max_profit_point = close;
end;
{ 停利 }
if max_profit_point <> 0 then begin
if Close <= max_profit_point*(1-(0.01*profit_drawback_point)) then begin
SetPosition(0,market);
max_profit_point = 0;
end;
{ 移動最大獲利點 }
if Close>max_profit_point then begin
max_profit_point = Close;
end;
end;
end;
以上是我參考內建的移動停利腳本修改成%數腳本
我的進場跟出場分成兩個腳本,使用模擬帳號測試出場腳本時似乎沒有觸發出場;使用交易回測是有歷史進出場
想請問小幫手幾個問題
1.每天開盤前啟動策略是否會有影響
2.內建腳本有用到 if...then begin....end else begin...end,我是將每一段敘述分開寫是否也是同樣的效果?
3.日頻率跟分鐘頻率在價格判斷上有執行上的差異嗎?
 
            
        
        
        
            
1 評論