یہ حکمت عملی مشین لرننگ پر مبنی ایک اڈاپٹیو سپر ٹرینڈ ٹریڈنگ سسٹم ہے جو اتار چڑھاؤ کے کلسٹرنگ، اڈاپٹیو اے ٹی آر ٹرینڈ کا پتہ لگانے اور سٹرکچرڈ انٹری اور ایگزٹ میکانزم کے ذریعے روایتی سپر ٹرینڈ انڈیکیٹرز کی بھروسے کو بہتر بناتی ہے۔ حکمت عملی کا بنیادی مقصد مشین لرننگ کے طریقوں کے ذریعے مارکیٹ کے اتار چڑھاؤ کی درجہ بندی کرنا، مناسب مارکیٹ کے ماحول میں ٹرینڈ ٹریکنگ لین دین کرنا، اور خطرات کو کنٹرول کرنے کے لیے متحرک اسٹاپ لاس اور ٹیک-پرافٹ کا استعمال کرنا ہے۔
حکمت عملی تین اہم اجزاء پر مشتمل ہے: 1) رجحان کی سمت اور ٹرننگ پوائنٹس کا تعین کرنے کے لیے ATR پر مبنی اڈاپٹیو کلسٹرنگ؛ مارکیٹ کی حیثیت کو تین زمروں میں درجہ بندی کرنے کے لیے اتار چڑھاؤ کا کلسٹرنگ: اعلی، درمیانے اور کم 3) اتار چڑھاؤ کے ماحول پر مبنی تجارتی قوانین کم اتار چڑھاؤ والے ماحول میں رجحان کے مواقع تلاش کریں اور زیادہ اتار چڑھاؤ والے ماحول میں محتاط رہیں۔ یہ نظام ta.crossunder اور ta.crossover فنکشنز کے ذریعے ٹرینڈ ریورسل سگنلز حاصل کرتا ہے، اور قیمت اور SuperTrend لائن کے درمیان پوزیشنی تعلق کی بنیاد پر تجارتی سمت کا تعین کرتا ہے۔
یہ حکمت عملی مشین سیکھنے کی تکنیکوں کو روایتی تکنیکی تجزیہ کے طریقوں کے ساتھ ملا کر ایک ذہین رجحان کی پیروی کرنے والا نظام بناتی ہے۔ حکمت عملی کا بنیادی فائدہ اس کی موافقت اور رسک کنٹرول کی صلاحیتوں میں مضمر ہے، جو اتار چڑھاؤ کے جھرمٹ کے ذریعے مارکیٹ کے حالات کی ذہین شناخت کے قابل بناتا ہے۔ اگرچہ پیرامیٹر کی حساسیت جیسے خطرات ہیں، مسلسل اصلاح اور بہتری کے ذریعے، حکمت عملی سے مارکیٹ کے مختلف ماحول میں مستحکم کارکردگی کو برقرار رکھنے کی توقع ہے۔ یہ تجویز کیا جاتا ہے کہ ٹریڈرز ریئل ٹائم میں درخواست دیتے وقت پیرامیٹر کی حساسیت کو پوری طرح جانچیں، اور مارکیٹ کی مخصوص خصوصیات کی بنیاد پر ٹارگٹڈ اصلاح کریں۔
/*backtest
start: 2025-01-09 00:00:00
end: 2025-01-16 00:00:00
period: 10m
basePeriod: 10m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT","balance":49999}]
*/
//@version=5
strategy("Adaptive SuperTrend Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=200)
// Import Indicator Components
atr_len = input.int(10, "ATR Length", group="SuperTrend Settings")
fact = input.float(3, "SuperTrend Factor", group="SuperTrend Settings")
training_data_period = input.int(100, "Training Data Length", group="K-Means Settings")
// Volatility Clustering
volatility = ta.atr(atr_len)
upper = ta.highest(volatility, training_data_period)
lower = ta.lowest(volatility, training_data_period)
high_volatility = lower + (upper-lower) * 0.75
medium_volatility = lower + (upper-lower) * 0.5
low_volatility = lower + (upper-lower) * 0.25
cluster = volatility >= high_volatility ? 0 : volatility >= medium_volatility ? 1 : 2
// SuperTrend Calculation
pine_supertrend(factor, atr) =>
src = hl2
upperBand = src + factor * atr
lowerBand = src - factor * atr
prevLowerBand = nz(lowerBand[1])
prevUpperBand = nz(upperBand[1])
lowerBand := lowerBand > prevLowerBand or close[1] < prevLowerBand ? lowerBand : prevLowerBand
upperBand := upperBand < prevUpperBand or close[1] > prevUpperBand ? upperBand : prevUpperBand
int _direction = na
float superTrend = na
prevSuperTrend = superTrend[1]
if na(atr[1])
_direction := 1
else if prevSuperTrend == prevUpperBand
_direction := close > upperBand ? -1 : 1
else
_direction := close < lowerBand ? 1 : -1
superTrend := _direction == -1 ? lowerBand : upperBand
[superTrend, _direction]
[ST, dir] = pine_supertrend(fact, volatility)
// Entry Conditions
longEntry = ta.crossunder(dir, 0) and cluster > 1 and close > ST
shortEntry = ta.crossover(dir, 0) and cluster == 0 and close < ST
// Stop Loss & Take Profit
atr_mult = input.float(2, "ATR Multiplier for SL/TP", group="Risk Management")
sl = atr_mult * ta.atr(atr_len)
longStopLoss = close - sl
longTakeProfit = close + (sl * 1.5)
shortStopLoss = close + sl
shortTakeProfit = close - (sl * 1.5)
// Execute Trades
if longEntry
strategy.entry("Long", strategy.long)
strategy.exit("Take Profit", from_entry="Long", limit=longTakeProfit, stop=longStopLoss)
if shortEntry
strategy.entry("Short", strategy.short)
strategy.exit("Take Profit", from_entry="Short", limit=shortTakeProfit, stop=shortStopLoss)
// Plot SuperTrend
plot(ST, title="SuperTrend", color=dir > 0 ? color.green : color.red, linewidth=2)
// Alerts
alertcondition(longEntry, title="Long Entry Signal", message="Buy Signal - Trend Shift Up")
alertcondition(shortEntry, title="Short Entry Signal", message="Sell Signal - Trend Shift Down")