
この戦略は,双均線交差に基づく取引システムで,9周期と21周期インデックス移動平均 ((EMA)) の交差を監視して取引を行う.戦略は,10分間の時間枠で動作し,ポジションを保持する際にポジションを繰り返し開設しない単一取引モードを採用する.システムは,初期資金10万を使用し,取引ごとに口座利権の10%を使用する.
戦略の核心原則は,長期EMAよりも市場価格の変化に対する短期のEMAの感受性が高いという特性を利用することである.短期のEMA ((9期) が長期のEMA ((21期) を横断すると,短期的な上位動力が強化され,システムが複数の信号を発信する.短期のEMAが短期のEMAを横断すると,短期的な下位動力が強化され,システムが平仓信号を発信する.戦略は,position_sizeパラメータを使用して,同時に1つの取引しか持たないことを保証し,リスクを効果的に制御する.
これは,合理的で論理的に明確な均線交差戦略である. EMA交差は,市場動向を捉え,単一取引モデルとパーセンテージポジション管理を組み合わせて,リスクと利益のバランスを達成している. いくつかの固有の限界があるにもかかわらず,推奨された方向の最適化によって,戦略の安定性と適応性がさらに向上することができます. 実用的には,特定の市場特性と個人のリスク好みに応じてトレーダーに相応した調整を行うことが推奨されています.
/*backtest
start: 2024-02-25 00:00:00
end: 2025-02-22 08:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Binance","currency":"SOL_USDT"}]
*/
//@version=6
strategy("EMA Crossover Labels (One Trade at a Time)", overlay=true, initial_capital=100000, default_qty_type=strategy.percent_of_equity, default_qty_value=10)
// ==== User Inputs ====
// Set the testing timeframe (ensure the chart is on a 10-min timeframe)
testTimeFrame = input.timeframe("10", "Strategy Timeframe")
// EMA period inputs
emaPeriod9 = input.int(9, "EMA 9 Period", minval=1)
emaPeriod21 = input.int(21, "EMA 2q Period", minval=1)
// ==== Retrieve Price Data ====
// For simplicity, we use the chart's timeframe (should be 10-min)
price = close
// ==== Calculate EMAs ====
ema9 = ta.ema(price, emaPeriod9)
ema21 = ta.ema(price, emaPeriod21)
// ==== Define Crossover Conditions ====
// Buy signal: when EMA9 crosses above EMA21 AND no current position is open
buySignal = ta.crossover(ema9, ema21) and strategy.position_size == 0
// Sell signal: when EMA9 crosses below EMA21 AND a long position is active
sellSignal = ta.crossunder(ema9, ema21) and strategy.position_size > 0
// ==== Strategy Orders ====
// Enter a long position when a valid buy signal occurs
if buySignal
strategy.entry("Long", strategy.long)
alert("Long Signal: " + syminfo.tickerid + " - EMA9 crossed above EMA21", alert.freq_once_per_bar_close)
// Exit the long position when a valid sell signal occurs
if sellSignal
strategy.close("Long")
alert("Sell Long Signal: " + syminfo.tickerid + " - EMA9 crossed below EMA21", alert.freq_once_per_bar_close)
// ==== Plot Buy/Sell Labels ====
// Only plot a "Buy" label if there's no open position
plotshape(buySignal, title="Buy Label", location=location.belowbar, color=color.green, style=shape.labelup, text="Buy", textcolor=color.white)
// Only plot a "Sell" label if a position is active
plotshape(sellSignal, title="Sell Label", location=location.abovebar, color=color.red, style=shape.labeldown, text="Sell", textcolor=color.white)
// ==== Plot EMAs for Visualization ====
plot(ema9, color=color.blue, title="EMA 21")
plot(ema21, color=color.orange, title="EMA 21")