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

3 評論