
यह रणनीति कई चक्रों पर आधारित डोंगचीआन चैनल संकेतकों पर आधारित है। यह एक ट्रेंड ट्रैकिंग सिस्टम का निर्माण करती है। विभिन्न समय अवधि में डोंगचीआन चैनल के ब्रेकडाउन का विश्लेषण करके, मुख्य प्रवृत्ति और स्थानीय प्रवृत्ति के सहसंबंध को मिलाकर, एक दृश्य रूप से सहज प्रवृत्ति बैंड आरेख का निर्माण करती है। रणनीति प्रवृत्ति की ताकत और कमजोरी को दिखाने के लिए रंगों में गहरा परिवर्तन का उपयोग करती है, हरा क्षेत्र ऊपर की ओर प्रवृत्ति का प्रतिनिधित्व करता है, लाल क्षेत्र नीचे की ओर प्रवृत्ति का प्रतिनिधित्व करता है, रंग जितना गहरा होता है, प्रवृत्ति उतनी स्पष्ट होती है।
रणनीति का केंद्र डोंचियन चैनल के आधार पर प्रवृत्ति का आकलन करना है। डोंचियन चैनल में उच्चतम मूल्य चैनल और निम्नतम मूल्य चैनल होते हैं, जो वर्तमान मूल्य और चैनल के स्थान संबंध की तुलना करके प्रवृत्ति का आकलन करते हैं। इसमें मुख्य रूप से निम्नलिखित कुछ महत्वपूर्ण घटक शामिल हैंः
इस रणनीति का मुख्य लाभ यह है कि यह जटिल प्रवृत्ति विश्लेषण प्रक्रिया को दृश्यमान बनाता है, जिससे व्यापारियों को बाजार की गति को समझने में मदद मिलती है। उचित पैरामीटर अनुकूलन और जोखिम नियंत्रण उपायों के साथ, इस रणनीति का वास्तविक उपयोग करने के लिए अच्छा मूल्य है। व्यापारियों को सलाह दी जाती है कि वे वास्तविक समय में बाजार की स्थिति के विकल्पों पर ध्यान दें और अपनी जोखिम सहनशीलता के साथ स्थिति प्रबंधन करें।
/*backtest
start: 2024-06-12 00:00:00
end: 2025-02-19 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"ETH_USDT"}]
*/
//@version=6
strategy("Donchian Trend Ribbon Strategy", shorttitle="DonchianTrendRibbonStrat", overlay=true, precision=0)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Parameters
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dlen = input.int(defval=20, title="Donchian Channel Period", minval=10)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Helper function to determine color
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
f_color(mainTrend, localTrend) =>
// mainTrend = 1 => uptrend, -1 => downtrend
// localTrend = 1 => local uptrend, -1 => local downtrend
// Return color based on whether local trend aligns with the main trend
color c = na
if mainTrend == 1
c := localTrend == 1 ? color.new(color.lime, 0) : color.new(color.lime, 60)
else if mainTrend == -1
c := localTrend == -1 ? color.new(color.red, 0) : color.new(color.red, 60)
else
c := na
c
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Function dchannel - determines main trend (1 or -1)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dchannel(len) =>
float hh = ta.highest(len)
float ll = ta.lowest(len)
var int tr = 0
tr := close > hh[1] ? 1 : close < ll[1] ? -1 : nz(tr[1])
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Function dchannelalt - determines local trend and returns color
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dchannelalt(len, maintrend) =>
float hh = ta.highest(len)
float ll = ta.lowest(len)
var int tr = 0
tr := close > hh[1] ? 1 : close < ll[1] ? -1 : nz(tr[1])
f_color(maintrend, tr)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Calculate main trend
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
maintrend = dchannel(dlen)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Plotting the Donchian Trend Ribbon
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
plot( 5, color=dchannelalt(dlen - 0, maintrend), style=plot.style_columns, histbase= 0)
plot(10, color=dchannelalt(dlen - 1, maintrend), style=plot.style_columns, histbase= 5)
plot(15, color=dchannelalt(dlen - 2, maintrend), style=plot.style_columns, histbase=10)
plot(20, color=dchannelalt(dlen - 3, maintrend), style=plot.style_columns, histbase=15)
plot(25, color=dchannelalt(dlen - 4, maintrend), style=plot.style_columns, histbase=20)
plot(30, color=dchannelalt(dlen - 5, maintrend), style=plot.style_columns, histbase=25)
plot(35, color=dchannelalt(dlen - 6, maintrend), style=plot.style_columns, histbase=30)
plot(40, color=dchannelalt(dlen - 7, maintrend), style=plot.style_columns, histbase=35)
plot(45, color=dchannelalt(dlen - 8, maintrend), style=plot.style_columns, histbase=40)
plot(50, color=dchannelalt(dlen - 9, maintrend), style=plot.style_columns, histbase=45)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Trading Logic (STRATEGY)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bool goLong = (maintrend == 1)
bool goShort = (maintrend == -1)
// Entry signals
if goLong
strategy.entry("Long", strategy.long)
if goShort
strategy.entry("Short", strategy.short)
// Close positions when trend changes
if strategy.position_size > 0 and goShort
strategy.close("Long")
if strategy.position_size < 0 and goLong
strategy.close("Short")