請問
我是想要寫出 當我自己進場後腳本可以幫我自動執行移動停損的單子 日線
停損5趴
當價格漲幅超過10趴後開始執行移動停損 停損點開始跟著往上走
請問這樣可以嗎 感謝
input: stop_per(5, "停損百分比"), trailing_per(10, "移動起始點");
var: stop_point(0), moving_point(0), controller(0);
if filled > 0 and position > 0 then begin
if controller = 0 then begin
stop_point = filledAvgPrice * (1 - (0.01 * stop_per)); //計算停損點
moving_point = filledAvgPrice * (1 + (0.01 * trailing_per)); //計算起始移動點
controller = 1;
end;
if close >= moving_point and (close * (1 - (0.01 * stop_per))) > stop_point then stop_point = (close * (1 - (0.01 * stop_per)))
// 如果價格大於起始移動點且新停損點大於舊停損點的話,更新停損點數值
else if close <= stop_point then begin
// 收盤價小於停損點就出場
setposition(0, market);
controller = 0;
print("out");
end;
print(date, time, close, filledAvgPrice, stop_point, moving_point);
end;
1 評論