// 宣告參數
input: Length(9, "計算期數"), RSVt(3, "RSVt權數"), Kt(3, "Kt權數"), LowBound(40, "低檔區"),
profit_percent(10, "停利(%)"), loss_percent(7, "停損(%)");
variable: _rsv(0), _k(0), _d(0);
// 資料讀取筆數設定
SetTotalBar(maxlist(Length,6) * 3 + 8);
Stochastic(Length, RSVt, Kt, _rsv, _k, _d);
// 多方進場策略:K在低檔區由下往上突破D值。
if _k < LowBound and _k crosses over _d
and filled = 0 and position = 0 then setposition(1, market);
{多單停損停利(%)}
if filled = 1 and position = 1 and (high >= (filledAvgPrice * (1+(profit_percent / 100))){停利}
or low <= (filledAvgPrice * (1-(loss_percent/100))){停損})
then setposition(0, market);
1 評論