
یہ حکمت عملی اے ٹی آر (اوسط حقیقی طول موج) پر مبنی ایک رجحان ٹریکنگ سسٹم ہے جس میں متحرک طور پر نقصانات کا سراغ لگانا ہوتا ہے۔ یہ ای ایم اے کی اوسط لائن کو رجحان فلٹر کے طور پر جوڑتا ہے اور سگنل کی پیداوار کو حساسیت کے پیرامیٹرز اور اے ٹی آر کی مدت کو ایڈجسٹ کرکے کنٹرول کرتا ہے۔ یہ نظام نہ صرف زیادہ تجارت کی حمایت کرتا ہے ، بلکہ اس سے بھی زیادہ تجارت کی حمایت کرتا ہے ، اور اس میں منافع کے انتظام کا ایک مکمل طریقہ کار ہے۔
یہ ایک منظم ، منطقی طور پر واضح رجحانات کا سراغ لگانے والا نظام ہے۔ اے ٹی آر متحرک ٹریکنگ اور ای ایم اے ٹرینڈ فلٹرنگ کے امتزاج کے ذریعہ ، رجحانات کو پکڑنے کے ساتھ ساتھ خطرے کو بہتر طور پر کنٹرول کیا جاتا ہے۔ وقفے وقفے سے منافع بخش میکانزم کا ڈیزائن بھی سمجھدار تجارتی سوچ کو ظاہر کرتا ہے۔ حکمت عملی میں مضبوط عملی اور توسیع پذیری ہے ، جس میں مسلسل اصلاح اور بہتری کے ذریعہ بہتر تجارتی نتائج حاصل کرنے کی امید ہے۔
/*backtest
start: 2024-10-15 00:00:00
end: 2025-02-18 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Enhanced UT Bot with Long & Short Trades", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
// Input Parameters
keyvalue = input.float(1.1, title="Key Value (Sensitivity)", step=0.1)
atrperiod = input.int(200, title="ATR Period")
emaPeriod = input.int(50, title="EMA Period")
roi_close = input.float(100, title="Close Trade at ROI (%)", step=1)
// ATR Calculation
src = close
xATR = ta.atr(atrperiod)
nLoss = keyvalue * xATR
// EMA for Trend Filtering
ema = ta.ema(src, emaPeriod)
// Trailing Stop Logic
var float xATRTrailingStop = na
if na(xATRTrailingStop)
xATRTrailingStop := src - nLoss
if src > nz(xATRTrailingStop[1]) and src[1] > nz(xATRTrailingStop[1])
xATRTrailingStop := math.max(nz(xATRTrailingStop[1]), src - nLoss)
else if src < nz(xATRTrailingStop[1]) and src[1] < nz(xATRTrailingStop[1])
xATRTrailingStop := math.min(nz(xATRTrailingStop[1]), src + nLoss)
else
xATRTrailingStop := src > nz(xATRTrailingStop[1]) ? src - nLoss : src + nLoss
// Buy/Sell Signal with Trend Filter
buySignal = ta.crossover(src, xATRTrailingStop) and src > ema
sellSignal = ta.crossunder(src, xATRTrailingStop) and src < ema
// Strategy Logic: Long Trades
if buySignal and strategy.position_size <= 0
strategy.entry("Buy", strategy.long)
if sellSignal and strategy.position_size > 0
strategy.close("Buy")
// Strategy Logic: Short Trades
if sellSignal and strategy.position_size >= 0
strategy.entry("Sell", strategy.short)
if buySignal and strategy.position_size < 0
strategy.close("Sell")
// ROI Calculation for Both Long and Short Trades
var float entryPrice = na
var bool isLong = na
if strategy.position_size > 0
entryPrice := strategy.opentrades.entry_price(0)
isLong := true
if strategy.position_size < 0
entryPrice := strategy.opentrades.entry_price(0)
isLong := false
// Calculate current profit
currentProfit = isLong ? (close - entryPrice) / entryPrice * 100 : (entryPrice - close) / entryPrice * 100
// Enhanced ROI Management
if strategy.position_size > 0 // Long Position
if currentProfit >= 20 and currentProfit < 50
stopLevel = entryPrice // Breakeven
strategy.exit("TSL Breakeven", from_entry="Buy", stop=stopLevel)
if currentProfit >= 50 and currentProfit < 80
stopLevel = entryPrice * 1.30 // 30% ROI
strategy.exit("TSL 30%", from_entry="Buy", stop=stopLevel)
strategy.close("Partial Profit", qty_percent=50) // Take 50% profit
if currentProfit >= 80 and currentProfit < roi_close
stopLevel = entryPrice * 1.60 // 60% ROI
strategy.exit("TSL 60%", from_entry="Buy", stop=stopLevel)
if currentProfit >= roi_close
strategy.close("Full Exit at 100% ROI")
if strategy.position_size < 0 // Short Position
if currentProfit >= 20 and currentProfit < 50
stopLevel = entryPrice // Breakeven
strategy.exit("TSL Breakeven", from_entry="Sell", stop=stopLevel)
if currentProfit >= 50 and currentProfit < 80
stopLevel = entryPrice * 0.70 // 30% ROI (Short stop)
strategy.exit("TSL 30%", from_entry="Sell", stop=stopLevel)
strategy.close("Partial Profit", qty_percent=50) // Take 50% profit
if currentProfit >= 80 and currentProfit < roi_close
stopLevel = entryPrice * 0.40 // 60% ROI (Short stop)
strategy.exit("TSL 60%", from_entry="Sell", stop=stopLevel)
if currentProfit >= roi_close
strategy.close("Full Exit at 100% ROI")
// Plotting
plot(xATRTrailingStop, color=buySignal ? color.green : sellSignal ? color.red : color.gray, title="Trailing Stop")
plot(ema, color=color.blue, title="EMA Trend Filter")
plotshape(buySignal, title="Buy Signal", style=shape.labelup, location=location.belowbar, color=color.green, text="Buy")
plotshape(sellSignal, title="Sell Signal", style=shape.labeldown, location=location.abovebar, color=color.red, text="Sell")