嘗試用網路上找的移動停利寫法,看了print數據後發現是移動停利的語法問題,開始移動停利後按理來說停損點就會取最高的那個數字,但現在收盤價一更新 停損點也跟著變了
按理說移動停利的停損點只會變高不會變低
不知移動停利區的語法可以加上甚麼條件,讓停損點只會往上更新呢?
input: satisfy_percent(8, "滿足啟動(%)");
input: loss_percent(6, "初始防守(%)");
var:BOut(0);
//====================進場區=================================
if Position = 0 and getField("最高價","W")>=getField("開盤價","W")*1.02 then
SetPosition(1,market); { 買進1張 }
BOut=filledavgPrice*(1-loss_percent*0.01);
//=====================移動停利區=============================
if getField("close","D")[1]*(1-(satisfy_percent+loss_percent)*0.01) > BOut then
BOut = getField("close","D")[1]*(1-loss_percent*0.01);
//=========================出場區============================
if position = 1 and getField("close","D") < BOut then { 啟動停利後最大獲利點 }
SetPosition(0,market);
print("Date=",date,"部位",position,"收盤價",getField("close","D")[1],"現價",getField("close","D"),"進場點",filledavgPrice,"停損點",BOut);


11 評論