//@version=5 indicator("Stochastic with Buy/Sell Signals", overlay=true) // パラメータ設定 kLength = input.int(14, title="K期間") dLength = input.int(3, title="D期間") smoothK = input.int(3, title="スムージング期間") // 計算 k = ta.sma(ta.stoch(close, high, low, kLength), smoothK) d = ta.sma(k, dLength) // オシレーター表示 plot(k, title="%K", color=color.blue) plot(d, title="%D", color=color.orange) hline(80, "Overbought", color=color.red) hline(20, "Oversold", color=color.green) // シグナル条件 buySignal = ta.crossover(k, d) and k < 20 sellSignal = ta.crossunder(k, d) and k > 80 // チャートにシグナル表示 plotshape(buySignal, title="Buy Signal", style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small, text="BUY") plotshape(sellSignal, title="Sell Signal", style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small, text="SELL")