
この戦略は,ケルトナーチャネル指標に基づい,指数移動平均 ((EMA) と平均実際の波動幅 ((ATR) を使って上下チャネルを構築し,価格が下軌道に突破する時に多額のポジションを開き,価格が上軌道に突破する時に平仓を打つ.この戦略は,価格の波動区間を捕捉しようとし,価格が上方チャネルに突破する時に利益を得て終了した.
この戦略は,Keltnerチャネル指標に基づいて,価格の突破上下軌道の論理を利用して取引を行う.その優点は,論理がシンプルで明確で,適応性が強いことであり,欠点は,ストップと信号品質の欠乏である.将来,ストップを導入し,信号を最適化し,パラメータを最適化し,フィルタリング条件を増やすなど,戦略を完善することができる.
/*backtest
start: 2024-05-01 00:00:00
end: 2024-05-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © satrusskumar
//@version=5
// Input parameters
length = input.int(21, title="EMA Length")
mult = input.float(2, title="ATR Multiplier")
atrLength = input.int(13, title="ATR Length")
// Calculate Keltner Channels
ema = ta.ema(close, length)
atr = ta.atr(atrLength)
upper_band = ema + mult * atr
lower_band = ema - mult * atr
// Plot Keltner Channels
plot(upper_band, color=color.red, title="Keltner Upper Band")
plot(ema, color=color.blue, title="Keltner EMA")
plot(lower_band, color=color.green, title="Keltner Lower Band")
// Strategy logic
var float entry_price = na
var bool in_trade = false
if (not in_trade and close < lower_band)
strategy.entry("Long", strategy.long)
entry_price := close
in_trade := true
if (in_trade and open > upper_band)
strategy.close("Long")
in_trade := false
// Strategy settings
strategy("Keltner Channel Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)