
इस रणनीति में कई चलती औसत ((MA) को मुख्य ट्रेडिंग सिग्नल के रूप में और औसत दिशा सूचकांक ((ADX) को फ़िल्टर के रूप में उपयोग किया जाता है। रणनीति का मुख्य विचार यह है कि तेजी से एमए, धीमी एमए और औसत एमए के बीच संबंधों की तुलना करके संभावित बहुमुखी और खाली अवसरों की पहचान की जाए। साथ ही, ट्रेडिंग सिग्नल की विश्वसनीयता को बढ़ाने के लिए पर्याप्त प्रवृत्ति के साथ बाजार की स्थिति को फ़िल्टर करने के लिए एडीएक्स संकेतक का उपयोग करें।
औसत दिशा सूचकांक फ़िल्टर के आधार पर एक समान-रेखा अस्वीकृति रणनीति, जो कई एमए और एडीएक्स संकेतकों का उपयोग करती है, संभावित व्यापारिक अवसरों की पहचान करती है और निम्न-गुणवत्ता वाले व्यापारिक संकेतों को फ़िल्टर करती है। रणनीति का तर्क स्पष्ट है, इसे समझना और लागू करना आसान है, लेकिन वास्तविक अनुप्रयोगों में बाजार के परिवेश में बदलाव पर ध्यान देने की आवश्यकता होती है, और अन्य तकनीकी संकेतकों और जोखिम प्रबंधन उपायों के साथ संयोजन में अनुकूलित किया जाता है।
/*backtest
start: 2024-04-01 00:00:00
end: 2024-04-30 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © gavinc745
//@version=5
strategy("MA Rejection Strategy with ADX Filter", overlay=true)
// Input parameters
fastMALength = input.int(10, title="Fast MA Length", minval=1)
slowMALength = input.int(50, title="Slow MA Length", minval=1)
averageMALength = input.int(20, title="Average MA Length", minval=1)
adxLength = input.int(14, title="ADX Length", minval=1)
adxThreshold = input.int(20, title="ADX Threshold", minval=1)
// Calculate moving averages
fastMA = ta.wma(close, fastMALength)
slowMA = ta.wma(close, slowMALength)
averageMA = ta.wma(close, averageMALength)
// Calculate ADX manually
dmPlus = high - high[1]
dmMinus = low[1] - low
trueRange = ta.tr
dmPlusSmoothed = ta.wma(dmPlus > 0 and dmPlus > dmMinus ? dmPlus : 0, adxLength)
dmMinusSmoothed = ta.wma(dmMinus > 0 and dmMinus > dmPlus ? dmMinus : 0, adxLength)
trSmoothed = ta.wma(trueRange, adxLength)
diPlus = dmPlusSmoothed / trSmoothed * 100
diMinus = dmMinusSmoothed / trSmoothed * 100
adx = ta.wma(math.abs(diPlus - diMinus) / (diPlus + diMinus) * 100, adxLength)
// Identify potential levels
potentialLongLevel = low < slowMA and close > slowMA
potentialShortLevel = high > slowMA and close < slowMA
// Confirm levels
confirmedLongLevel = potentialLongLevel and close > fastMA
confirmedShortLevel = potentialShortLevel and close < fastMA
// Entry signals
longEntry = confirmedLongLevel and ta.crossover(fastMA, averageMA) and adx > adxThreshold
shortEntry = confirmedShortLevel and ta.crossunder(fastMA, averageMA) and adx > adxThreshold
// Exit signals
longExit = ta.crossunder(close, slowMA)
shortExit = ta.crossover(close, slowMA)
// Plot signals
plotshape(longEntry, title="Long Entry", location=location.belowbar, style=shape.triangleup, size=size.small, color=color.green)
plotshape(shortEntry, title="Short Entry", location=location.abovebar, style=shape.triangledown, size=size.small, color=color.red)
// Plot moving averages and ADX
plot(fastMA, title="Fast MA", color=color.blue)
plot(slowMA, title="Slow MA", color=color.red)
plot(averageMA, title="Average MA", color=color.orange)
// plot(adx, title="ADX", color=color.purple)
// hline(adxThreshold, title="ADX Threshold", color=color.gray, linestyle=hline.style_dashed)
// Execute trades
if longEntry
strategy.entry("Long", strategy.long)
else if longExit
strategy.close("Long")
if shortEntry
strategy.entry("Short", strategy.short)
else if shortExit
strategy.close("Short")