この戦略は20日指数移動平均 ((EMA) をベースにチャネルを構築し,価格がチャネルを突破する上沿いに多行し,価格がチャネルを突破する下沿いに空行し,トレンド追跡戦略に属します.
リスク対策:
この戦略は,全体的にシンプルで実用的で,EMAチャネルをベースに構築され,典型的なトレンド追跡戦略の1つである.突破信号の特徴があるが,ある程度の誤報のリスクもある.パラメータを最適化したり,フィルターを追加したりなどして戦略の効果を向上させることができる.さらなるテストと最適化の価値がある.
/*backtest
start: 2023-12-01 00:00:00
end: 2023-12-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy("EMA Channel Strategy with Alerts", shorttitle="EMA Channel", overlay=true)
// Define EMA length
emaLength = 20
// Calculate EMA values
emaHigh = ema(high, emaLength)
emaLow = ema(low, emaLength)
// Define the condition for a buy signal
buyCondition = crossover(close, emaHigh)
// Define the condition for a sell signal
sellCondition = crossunder(close, emaLow)
// Plot the EMA lines
plot(emaHigh, color=color.green, title="EMA High")
plot(emaLow, color=color.red, title="EMA Low")
// Plot buy and sell signals
plotshape(buyCondition, style=shape.triangleup, location=location.belowbar, color=color.green, title="Buy Signal")
plotshape(sellCondition, style=shape.triangledown, location=location.abovebar, color=color.red, title="Sell Signal")
// Strategy
strategy.entry("Buy", strategy.long, when=buyCondition)
strategy.close("Buy", when=sellCondition)
// Define and trigger alerts
alertcondition(buyCondition, title="Buy Alert", message="Buy signal - Price crossed above EMA High")
alertcondition(sellCondition, title="Sell Alert", message="Sell signal - Price crossed below EMA Low")