
یہ حکمت عملی ڈونچین چینل پر مبنی ٹرینڈ ٹریکنگ ٹریڈنگ سسٹم ہے جس میں سپر ٹرینڈ اشارے اور ٹرانزیکشن فلٹرز شامل ہیں جو تجارتی سگنل کی وشوسنییتا کو بڑھا دیتے ہیں۔ یہ حکمت عملی بنیادی طور پر قیمتوں کی تاریخی اونچائیوں کو توڑنے کے ذریعہ ممکنہ کثیر جہتی تجارتی مواقع کی نشاندہی کرتی ہے ، جبکہ ٹرانزیکشن کی تصدیق اور ٹرینڈ ٹریکنگ اشارے کا استعمال جعلی ٹرانزیکشن سگنل کو فلٹر کرنے کے لئے کیا جاتا ہے۔ حکمت عملی کا ڈیزائن لچکدار ہے ، جس کو مختلف مارکیٹ کے حالات اور تجارتی اقسام کے مطابق پیرامیٹرز کے مطابق بہتر بنایا جاسکتا ہے۔
حکمت عملی کی بنیادی منطق درج ذیل کلیدی اجزاء پر مبنی ہے:
اس حکمت عملی نے متعدد تکنیکی اشارے کے مربوط استعمال کے ذریعے ، ایک نسبتا complete مکمل رجحان ٹریکنگ ٹریڈنگ سسٹم تشکیل دیا ہے۔ اس حکمت عملی کے فوائد سگنل کی اعلی وشوسنییتا ، خطرے کے انتظام میں لچکدار ہیں ، لیکن پھر بھی تاجروں کو مخصوص مارکیٹ کی خصوصیات کے مطابق پیرامیٹرز کو بہتر بنانے کی ضرورت ہے۔ مسلسل بہتری اور اصلاح کے ذریعہ ، اس حکمت عملی کو رجحان مارکیٹ میں مستحکم تجارتی اثر حاصل کرنے کی امید ہے۔
/*backtest
start: 2024-10-01 00:00:00
end: 2025-02-19 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"ETH_USDT"}]
*/
// Breakout trading system based on Donchain channel strategy that works best on a weekly chart and daily charts. Weekly is preferred.
//@version=5
strategy('Donchian BO with Volume Filter and Supertrend', shorttitle='DBO+Vol+ST', default_qty_type=strategy.percent_of_equity, default_qty_value=2, overlay=true)
// Input options to configure backtest date range
startDate = input.int(title='Start Date', defval=1, minval=1, maxval=31)
startMonth = input.int(title='Start Month', defval=1, minval=1, maxval=12)
startYear = input.int(title='Start Year', defval=2016, minval=1800, maxval=2100)
avgVol = input.int(title="Avg Volume length", defval=20)
srcInput = input.source(close, "Source")
// Volume filter toggle
useVolumeFilter = input.bool(true, title='Enable Volume Filter')
endDate = input.int(title='End Date', defval=1, minval=1, maxval=31)
endMonth = input.int(title='End Month', defval=7, minval=1, maxval=12)
endYear = input.int(title='End Year', defval=2030, minval=1800, maxval=2100)
multiplier = input.int(title='SuperTrend Mult', defval=2, minval=1, maxval=12)
stlen = input.int(title='SuperTrend Length', defval=10, minval=1, maxval=12)
length = input.int(21, minval=1)
exit = input.int(3, minval=1, maxval=4, title='Exit Option') // Use Option 1 to exit using lower band; Use Option 2 to exit using basis line
lower = ta.lowest(length)
upper = ta.highest(length)
basis = math.avg(upper, lower)
// Plotting the Donchian channel
l = plot(lower, color=color.new(color.blue, 0))
u = plot(upper, color=color.new(color.blue, 0))
plot(basis, color=color.new(color.orange, 0))
fill(u, l, color=color.new(color.blue, 90))
// Check if the current bar is in the date range
inDateRange = time >= timestamp(syminfo.timezone, startYear, startMonth, startDate, 0, 0) and time < timestamp(syminfo.timezone, endYear, endMonth, endDate, 0, 0)
// Long trailing stop-loss percentage
longTrailPerc = input.float(title='Trail Long Loss (%)', minval=0.0, step=0.1, defval=3) * 0.01
longStopPrice = 0.0
longStopPrice := if strategy.position_size > 0
stopValue = close * (1 - longTrailPerc)
math.max(stopValue, longStopPrice[1])
else
0
// Volume filter: 20-period moving average
volumeMA = ta.sma(volume, avgVol)
// Long entry condition: Donchian breakout + volume filter
longCondition = ta.crossover(srcInput, upper[1]) and (not useVolumeFilter or volume > volumeMA)
longsma = ta.sma(close, 200)
if inDateRange and longCondition
strategy.entry('Long', strategy.long)
// Exit conditions
if inDateRange and exit == 1
if ta.crossunder(close, lower[1])
strategy.close('Long')
if inDateRange and exit == 2
if ta.crossunder(close, basis[1])
strategy.close('Long')
[superTrend, dir] = ta.supertrend(multiplier, stlen)
if inDateRange and exit == 3
if ta.crossunder(close, superTrend)
strategy.close('Long')
if inDateRange and exit == 4
if strategy.position_size > 0
strategy.exit(id='XL TRL STP', stop=longStopPrice)
// Short conditions (commented out for now)
shortCondition = ta.crossunder(close, lower[1])
// Exit all positions when date range ends
if not inDateRange
strategy.close_all()
// --- Add Supertrend Indicator ---
stColor = dir == 1 ? color.red : color.green
plot(superTrend, color=stColor, title="SuperTrend", linewidth=2)