inputs:
ProfitTarget(10), // 啟動移動停利%
ProfitDrawdown(25); // 損益拉回%
vars:
IntraBarPersist MaxProfit(0);
if Position <> 0 and Filled <> 0 then MaxProfit = MaxList(MaxProfit, AbsValue(High - FilledAvgPrice)) else MaxProfit = 0; // 多單
if Position <> 0 and Filled <> 0 then MaxProfit = MaxList(MaxProfit, AbsValue(Low - FilledAvgPrice)) else MaxProfit = 0; // 空單
if Position <> 0 and Filled <> 0 then begin
if MaxProfit > FilledAvgPrice * ProfitTarget * 0.01 and Close > FilledAvgPrice + (MaxProfit * (100 - ProfitDrawdown) * 0.01) then SetPosition(0); // 多單移動停利
if MaxProfit > FilledAvgPrice * ProfitTarget * 0.01 and Close > FilledAvgPrice - (MaxProfit * (100 - ProfitDrawdown) * 0.01) then SetPosition(0); // 空單移動停利
end;
假設19:20的高是14650,20:00跌到14550進場然後開啟程式自動停利,再來21:00漲到14620後開始拉回
問一下上述語法的High會是當晚最高的14650,還是開啟程式後的高點14620?
如果是前者的話,那該如果改寫成後者?
1 評論