
この戦略は,四重指数移動平均 ((EMA) に基づくトレンド追跡システムで,9・21・50・200周期EMAの交差と並列によって市場トレンドを識別し,パーセントストップと組み合わせてリスクコントロールを行う.戦略は,四条均等線の並列順序を判断して市場トレンドの方向を決定し,短期均等線が長期均等線の上にあるときに多入し,逆空し,同時に固定パーセントストップを設定してリスクを制御する.
戦略は,4つの異なる周期の指数移動平均 ((9,21,50,200) を用いて,これらの均線間の関係を観察して市場のトレンドを判断する. 9日のEMAが21日のEMA,21日のEMAが50日のEMA,50日のEMAが200日のEMAの上にあったとき,システムは市場が強い上昇傾向にあると判断し,多額のシグナルを発行する. 反対の信号,均線が逆の並びを見せたとき,システムは市場が低下傾向にあると判断し,空の信号を発行する. 同時に,戦略は,最大損失を制御するために2%のストップ・損失設定を導入する.
これは,構造が整ったトレンド追跡取引システムで,複数の平均線の配合使用により,より信頼性の高いトレンド識別機構を提供し,同時に固定パーセントのストップロスを採用してリスクを制御する.システムのある程度の遅滞があるにもかかわらず,合理的なパラメータの最適化と追加の指標の補充によって,戦略の安定性と収益性をさらに向上させることができる.この戦略は,波動性の高い市場,および中長期のトレンド追跡取引に特に適しています.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-11-23 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("4 EMA Strategy with Stop Loss", overlay=true)
// Define the EMA lengths
ema1_length = input(9, title="EMA 1 Length")
ema2_length = input(21, title="EMA 2 Length")
ema3_length = input(50, title="EMA 3 Length")
ema4_length = input(200, title="EMA 4 Length")
// Calculate the EMAs
ema1 = ta.ema(close, ema1_length)
ema2 = ta.ema(close, ema2_length)
ema3 = ta.ema(close, ema3_length)
ema4 = ta.ema(close, ema4_length)
// Plot EMAs on the chart
plot(ema1, color=color.blue, title="EMA 9")
plot(ema2, color=color.orange, title="EMA 21")
plot(ema3, color=color.green, title="EMA 50")
plot(ema4, color=color.red, title="EMA 200")
// Define conditions for Buy and Sell signals
buy_condition = (ema1 > ema2 and ema2 > ema3 and ema3 > ema4)
sell_condition = (ema1 < ema2 and ema2 < ema3 and ema3 < ema4)
// Input stop loss percentage
stop_loss_perc = input(2.0, title="Stop Loss %")
// Execute buy signal
if (buy_condition)
strategy.entry("Buy", strategy.long)
// Set stop loss at a percentage below the entry price
strategy.exit("Sell", "Buy", stop=strategy.position_avg_price * (1 - stop_loss_perc / 100))
// Execute sell signal
if (sell_condition)
strategy.entry("Sell", strategy.short)
// Set stop loss at a percentage above the entry price
strategy.exit("Cover", "Sell", stop=strategy.position_avg_price * (1 + stop_loss_perc / 100))