
यह एक ट्रेंड ट्रैकिंग रणनीति है जो बहु-चक्र विश्लेषण और अस्थिरता प्रबंधन को जोड़ती है। रणनीति के केंद्र में द्वि-समान-रेखा क्रॉसिंग ट्रेंड की दिशा का आकलन करना है, आरएसआई संकेतक के माध्यम से ओवरबॉय ओवरसोड फ़िल्टर करना है, उच्च समय अवधि ईएमए को समग्र प्रवृत्ति की पुष्टि करने के लिए पेश करना है, और एटीआर संकेतक का उपयोग करके रोक और लाभ के लक्ष्यों को गतिशील रूप से प्रबंधित करना है। यह रणनीति कई तकनीकी संकेतकों के संयोजन के माध्यम से व्यापार संकेतों की विश्वसनीयता की गारंटी देती है और जोखिम पर प्रभावी नियंत्रण प्राप्त करती है।
इस रणनीति का मुख्य लेनदेन तर्क निम्नलिखित प्रमुख भागों में विभाजित हैः
यह एक अच्छी तरह से डिज़ाइन की गई प्रवृत्ति का पालन करने की रणनीति है, जो बहु-चक्र विश्लेषण और अस्थिरता प्रबंधन के माध्यम से बेहतर जोखिम-लाभ सुविधाओं को प्राप्त करती है। रणनीति का मुख्य लाभ कई तकनीकी संकेतकों के जैविक संयोजन में है, जो व्यापार की विश्वसनीयता की गारंटी देता है और जोखिम पर प्रभावी नियंत्रण करता है। हालांकि कुछ संभावित जोखिम हैं, लेकिन निरंतर अनुकूलन और सुधार के माध्यम से रणनीति के समग्र प्रदर्शन में सुधार की गुंजाइश है।
/*backtest
start: 2019-12-23 08:00:00
end: 2024-11-26 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Trend Following with ATR and MTF Confirmation", overlay=true)
// Parameters
emaShortPeriod = input.int(9, title="Short EMA Period", minval=1)
emaLongPeriod = input.int(21, title="Long EMA Period", minval=1)
rsiPeriod = input.int(14, title="RSI Period", minval=1)
rsiOverbought = input.int(70, title="RSI Overbought", minval=50)
rsiOversold = input.int(30, title="RSI Oversold", minval=1)
atrPeriod = input.int(14, title="ATR Period", minval=1)
atrMultiplier = input.float(1.5, title="ATR Multiplier", minval=0.1)
takeProfitATRMultiplier = input.float(2.0, title="Take Profit ATR Multiplier", minval=0.1)
// Multi-timeframe settings
htfEMAEnabled = input.bool(true, title="Use Higher Timeframe EMA Confirmation?", inline="htf")
htfEMATimeframe = input.timeframe("D", title="Higher Timeframe", inline="htf")
// Select trade direction
tradeDirection = input.string("Both", title="Trade Direction", options=["Both", "Long", "Short"])
// Calculating indicators
emaShort = ta.ema(close, emaShortPeriod)
emaLong = ta.ema(close, emaLongPeriod)
rsiValue = ta.rsi(close, rsiPeriod)
atrValue = ta.atr(atrPeriod)
// Higher timeframe EMA confirmation
htfEMALong = request.security(syminfo.tickerid, htfEMATimeframe, ta.ema(close, emaLongPeriod))
// Trading conditions
longCondition = ta.crossover(emaShort, emaLong) and rsiValue < rsiOverbought and (not htfEMAEnabled or close > htfEMALong)
shortCondition = ta.crossunder(emaShort, emaLong) and rsiValue > rsiOversold and (not htfEMAEnabled or close < htfEMALong)
// Plotting EMAs
plot(emaShort, title="EMA Short", color=color.green)
plot(emaLong, title="EMA Long", color=color.red)
// Trailing Stop-Loss and Take-Profit levels
var float trailStopLoss = na
var float trailTakeProfit = na
// Exit conditions
var bool exitLongCondition = na
var bool exitShortCondition = na
if (strategy.position_size != 0)
if (strategy.position_size > 0) // Long Position
trailStopLoss := na(trailStopLoss) ? close - atrValue * atrMultiplier : math.max(trailStopLoss, close - atrValue * atrMultiplier)
trailTakeProfit := close + atrValue * takeProfitATRMultiplier
exitLongCondition := close <= trailStopLoss or close >= trailTakeProfit
strategy.exit("Exit Long", "Long", stop=trailStopLoss, limit=trailTakeProfit, when=exitLongCondition)
else // Short Position
trailStopLoss := na(trailStopLoss) ? close + atrValue * atrMultiplier : math.min(trailStopLoss, close + atrValue * atrMultiplier)
trailTakeProfit := close - atrValue * takeProfitATRMultiplier
exitShortCondition := close >= trailStopLoss or close <= trailTakeProfit
strategy.exit("Exit Short", "Short", stop=trailStopLoss, limit=trailTakeProfit, when=exitShortCondition)
// Strategy Entry
if (longCondition and (tradeDirection == "Both" or tradeDirection == "Long"))
strategy.entry("Long", strategy.long)
if (shortCondition and (tradeDirection == "Both" or tradeDirection == "Short"))
strategy.entry("Short", strategy.short)
// Plotting Buy/Sell signals
plotshape(series=longCondition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(series=shortCondition, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
// Plotting Trailing Stop-Loss and Take-Profit levels
plot(strategy.position_size > 0 ? trailStopLoss : na, title="Long Trailing Stop Loss", color=color.red, linewidth=2, style=plot.style_line)
plot(strategy.position_size < 0 ? trailStopLoss : na, title="Short Trailing Stop Loss", color=color.green, linewidth=2, style=plot.style_line)
plot(strategy.position_size > 0 ? trailTakeProfit : na, title="Long Take Profit", color=color.blue, linewidth=2, style=plot.style_line)
plot(strategy.position_size < 0 ? trailTakeProfit : na, title="Short Take Profit", color=color.orange, linewidth=2, style=plot.style_line)
// Alerts
alertcondition(longCondition, title="Buy Alert", message="Buy Signal Triggered")
alertcondition(shortCondition, title="Sell Alert", message="Sell Signal Triggered")
alertcondition(exitLongCondition, title="Long Exit Alert", message="Long Position Closed")
alertcondition(exitShortCondition, title="Short Exit Alert", message="Short Position Closed")