
रणनीति एक प्रवृत्ति ट्रैकिंग ट्रेडिंग प्रणाली है जो कई तकनीकी संकेतकों को जोड़ती है। यह मुख्य रूप से बाजार की प्रवृत्ति और प्रवेश के समय को निर्धारित करने के लिए पारलौकिक रूपरेखा (SAR), चलती औसत (SMA) और दिशात्मक गतिशीलता (DMI) का उपयोग करता है, और प्रतिशत स्टॉप और MACD पीछे हटने के माध्यम से बाहर निकलने का अनुकूलन करता है। रणनीति के डिजाइन का मुख्य विचार एक मजबूत प्रवृत्ति के बाद प्रवेश की पुष्टि करना है, और पूर्वनिर्धारित लाभ लक्ष्य को पूरा करने या प्रवृत्ति में बदलाव के संकेतों के लिए समय पर बाहर निकलना है।
ट्रेडिंग सिग्नल की पुष्टि करने के लिए रणनीति में कई स्तरों के फ़िल्टरिंग तंत्र का उपयोग किया जाता हैः
इस रणनीति का निर्माण एक अपेक्षाकृत पूर्ण प्रवृत्ति ट्रैकिंग ट्रेडिंग प्रणाली है, जो कई तकनीकी संकेतकों के साथ काम करती है। इसका लाभ संकेतों की पुष्टि की विश्वसनीयता और जोखिम नियंत्रण की लचीलापन में है। हालांकि कुछ पिछड़े जोखिम हैं, लेकिन पैरामीटर अनुकूलन और गतिशील प्रबंधन तंत्र में शामिल होने के माध्यम से रणनीति का समग्र प्रदर्शन अभी भी बेहतर है। निरंतर अनुकूलन और सुधार के माध्यम से, यह रणनीति एक मजबूत व्यापारिक उपकरण बन सकती है।
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-09 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Swing Trading Strategy with DMI", overlay=true)
// Define parameters
sarStart = input.float(0.02, title="SAR Start")
sarIncrement = input.float(0.02, title="SAR Increment")
sarMax = input.float(0.2, title="SAR Max")
atrLength = input.int(10, title="ATR Length")
macdShort = input.int(12, title="MACD Short Length")
macdLong = input.int(26, title="MACD Long Length")
macdSignal = input.int(9, title="MACD Signal Length")
smaLength = input.int(50, title="SMA Length")
dmiLength = input.int(14, title="DMI Length")
adxSmoothing = input.int(14, title="ADX Smoothing") // Smoothing period for ADX
targetProfitPercentage = input.float(3.0, title="Target Profit Percentage")
// Calculate SAR
sar = ta.sar(sarStart, sarIncrement, sarMax)
// Calculate ATR
atr = ta.atr(atrLength)
// Calculate MACD
[macdLine, macdSignalLine, _] = ta.macd(close, macdShort, macdLong, macdSignal)
// Calculate SMA
sma = ta.sma(close, smaLength)
bullishTrend = close > sma
// Calculate DMI
[plusDI, minusDI, adx] = ta.dmi(dmiLength, adxSmoothing) // Specify ADX smoothing period
// Determine if DMI is bullish
dmiBullish = plusDI > minusDI
// Define buy signal
buySignal = ta.crossover(close, sar) and bullishTrend and dmiBullish
// Track buy price and position state
var float buyPrice = na
var bool inPosition = false
// Enter position
if (buySignal and not inPosition)
buyPrice := close
inPosition := true
strategy.entry("Buy", strategy.long)
// Define target price (3% above the buy price)
targetPrice = na(buyPrice) ? na : buyPrice * (1 + targetProfitPercentage / 100)
// Define MACD sell signal
macdSellSignal = ta.crossunder(macdLine, macdSignalLine)
// Define sell signal
sellSignal = inPosition and (close >= targetPrice or macdSellSignal)
// Exit position
if (sellSignal)
inPosition := false
strategy.exit("Sell", "Buy", limit=targetPrice)
// Plot SAR on the chart
plot(sar, color=color.red, style=plot.style_cross, linewidth=2)
// Plot SMA (optional, for visualizing the trend)
plot(sma, color=color.blue, title="SMA")
// Plot DMI +DI and -DI
plot(plusDI, color=color.green, title="+DI")
plot(minusDI, color=color.red, title="-DI")
// Plot buy signal on the chart
//plotshape(series=buySignal, location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
// Plot sell signal on the chart
//plotshape(series=sellSignal, location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
// Optional: Plot background color for buy and sell signals
bgcolor(buySignal ? color.new(color.green, 90) : na, title="Buy Signal Background")
bgcolor(sellSignal ? color.new(color.red, 90) : na, title="Sell Signal Background")