
この戦略は,ダイナミックなポジション管理とリスク制御の仕組みを組み合わせた,中長期指数移動平均 ((EMA) 交差に基づく取引システムである.戦略は,21サイクルと55サイクルのEMA交差によって市場のトレンドを認識し,同時に,ユーザーにカスタマイズされたリスク収益比率とリスクパーセントに基づいて,取引ポジションのサイズを動的に調整し,リスクを精密に制御する.
戦略の核心論理は,2つの時間周期のEMAの交差信号に基づいています. 21周期EMAが55周期EMAを上向きに通過すると,システムは上昇傾向として認識し,多信号を触発します. 21周期EMAが55周期EMAを下向きに通過すると,システムは下向き傾向として認識し,空白信号を触発します. ストップ・ロスの設定は,過去2つのK線の最低点 ((多) または最高点 ((空白) を採用し,ストップ・ロスは,設定されたユーザのリスクと利益の比率が動的に計算されます.
この戦略はEMAのトレンドシグナルとダイナミックなリスク管理を組み合わせて,完全な取引システムを構築している.戦略の核心的な優位性は,科学的ポジション管理とリスク制御機構にあるが,市場環境と個人のリスク好みに応じて適切なパラメータの最適化が必要である.推奨された最適化方向によって,戦略の安定性と収益性がさらに向上する見込みがある.
/*backtest
start: 2024-02-21 00:00:00
end: 2024-07-11 00:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Binance","currency":"ETH_USDT"}]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Carlos Humberto Rodríguez Arias
//@version=5
strategy("EMA Crossover Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)
// EMA periods
MT_EMA = input.int(21, title="Medium Term EMA")
LT_EMA = input.int(55, title="Long Term EMA")
RR = input.float(2.0, title="Risk-Reward Ratio") // User-defined RR
RiskPercent = input.float(1.0, title="Risk Percentage") // User-defined risk percentage
// Calculate EMAs
Signal_MT_EMA = ta.ema(close, MT_EMA)
Signal_LT_EMA = ta.ema(close, LT_EMA)
// Plot EMAs
plot(Signal_MT_EMA, title="Medium Term EMA", color=color.orange, linewidth=2)
plot(Signal_LT_EMA, title="Long Term EMA", color=color.blue, linewidth=2)
// Determine trend conditions
uptrend = ta.crossover(Signal_MT_EMA, Signal_LT_EMA)
downtrend = ta.crossunder(Signal_MT_EMA, Signal_LT_EMA)
// Stop-Loss Calculations
longStopLoss = ta.lowest(low, 2) // SL for buy = lowest low of last 2 candles
shortStopLoss = ta.highest(high, 2) // SL for sell = highest high of last 2 candles
// Take-Profit Calculations
longTakeProfit = close + (close - longStopLoss) * RR
shortTakeProfit = close - (shortStopLoss - close) * RR
// Calculate Position Size based on Risk Percentage
capital = strategy.equity * (RiskPercent / 100)
longPositionSize = capital / (close - longStopLoss)
shortPositionSize = capital / (shortStopLoss - close)
// Execute Buy Order
if uptrend
strategy.entry("Long", strategy.long, qty=longPositionSize)
strategy.exit("Long Exit", from_entry="Long", stop=longStopLoss, limit=longTakeProfit)
// Execute Sell Order
if downtrend
strategy.entry("Short", strategy.short, qty=shortPositionSize)
strategy.exit("Short Exit", from_entry="Short", stop=shortStopLoss, limit=shortTakeProfit)