
この戦略は,双指数移動平均 ((EMA)) に基づくトレンド追跡取引システムである.この戦略は,44周期と200周期の2つのEMAラインを使用して,価格突破シグナルと組み合わせて取引方向を決定する.同時に,ダイナミックポジション計算と移動ストップを含むリスク管理機構を統合している.
戦略の核心論理は,価格と二重EMA線の相互作用に基づいている.44周期EMAは,最高価格と最低価格の形成上下チャネルにそれぞれ適用され,200周期EMAは,長期トレンドフィルターとして使用されている.閉盘価格が上線EMAを突破し,200EMAフィルター条件を満たしたときに,システムは複数の信号を生成し,閉盘価格が上線EMAを突破し,200EMAフィルター条件を満たしたときに,システムは空白信号を生成する.戦略は,口座権益に基づくダイナミックなポジション管理を採用し,各取引のリスクパーセントに基づいて,自動的にポジション開設数を計算する.
これは,構造が整った,論理が明確なトレンド追跡戦略である.双EMAチャネルと長期トレンドフィルターによって取引信号を提供し,完善したリスク管理機構と連携し,優れた実用性がある.戦略の最適化スペースは,主に信号確認,動的パラメータ調整,リスク管理機構の完善にある.実用的なアプリケーションでは,パラメータの感受性を十分にテストし,特定の取引品種の特性に合わせてターゲットに最適化することを推奨する.
/*backtest
start: 2024-02-25 00:00:00
end: 2024-03-17 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"SOL_USDT"}]
*/
//@version=5
strategy("RENTABLE Dual EMA Breakout TSLA ", overlay=true)
// Inputs for EMA lengths and risk per trade
length = input(44, title="EMA Length")
longTermLength = input(200, title="Long-Term EMA Length")
riskPerTrade = input.float(1.0, title="Risk per Trade (%)", minval=0.1, maxval=10.0)
// Additional inputs for strategy customization
useFilter = input.bool(true, title="Use 200 EMA Filter")
tradeDirection = input.string("Both", title="Trade Direction", options=["Long", "Short", "Both"])
// EMAs based on the high and low prices and long-term EMA
emaHigh = ta.ema(high, length)
emaLow = ta.ema(low, length)
ema200 = ta.ema(close, longTermLength)
// Plotting EMAs on the chart
plot(emaHigh, color=color.green, title="High EMA")
plot(emaLow, color=color.red, title="Low EMA")
plot(ema200, color=color.blue, title="200 EMA")
// Entry conditions with optional EMA filter
longCondition = close > emaHigh and (useFilter ? close > ema200 : true)
shortCondition = close < emaLow and (useFilter ? close < ema200 : true)
// Calculating stop-loss and position size
longStop = emaLow
shortStop = emaHigh
riskPerShareLong = close - longStop
riskPerShareShort = shortStop - close
equity = strategy.equity
// Ensure risk per share is positive for calculations
riskPerShareLong := riskPerShareLong > 0 ? riskPerShareLong : 0.01
riskPerShareShort := riskPerShareShort > 0 ? riskPerShareShort : 0.01
positionSizeLong = (equity * riskPerTrade / 100) / riskPerShareLong
positionSizeShort = (equity * riskPerTrade / 100) / riskPerShareShort
// Ensure position sizes are positive before entering trades
if (longCondition and (tradeDirection == "Long" or tradeDirection == "Both") and positionSizeLong > 0)
strategy.entry("Long", strategy.long, qty= positionSizeLong)
if (shortCondition and (tradeDirection == "Short" or tradeDirection == "Both") and positionSizeShort > 0)
strategy.entry("Short", strategy.short, qty=positionSizeShort)
// Applying the stop-loss to strategy
strategy.exit("Exit Long", "Long", stop=longStop)
strategy.exit("Exit Short", "Short", stop=shortStop)
////Usar en 1,2 3 4 HRS TSLA