
یہ ایک متحرک ٹرینڈ لائن اور ٹرانزیکشن حجم کی تصدیق پر مبنی ایک کثیر جہتی بریک ٹریڈنگ حکمت عملی ہے۔ حکمت عملی قیمت کی نقل و حرکت کو حقیقی وقت میں ٹریک کرکے اہم اتار چڑھاؤ کی اونچائی کی نشاندہی کرتی ہے ، اور ان پوائنٹس کو متحرک طور پر ٹرینڈ لائن بنانے کے لئے استعمال کرتی ہے۔ حکمت عملی ایک کثیر جہتی پوزیشن میں داخل ہوتی ہے جب قیمت نمایاں طور پر اوپر کی طرف بڑھتی ہوئی ٹرینڈ لائن کو توڑ دیتی ہے ، جبکہ فیصد اسٹاپ نقصان اور ٹریکنگ اسٹاپ نقصان کا استعمال کرتے ہوئے خطرے کا انتظام کرتی ہے۔
حکمت عملی کا بنیادی منطق تین اہم ستونوں پر مبنی ہے: متحرک رجحان لائن کی تعمیر ، حجم کی تصدیق اور رسک مینجمنٹ سسٹم۔ پہلے ، حکمت عملی قیمتوں میں اتار چڑھاؤ کی اعلی سطح کی شناخت کے لئے ta.pivothigh فنکشن کا استعمال کرتی ہے اور اوپر کی رجحان لائن کی تعمیر کے لئے حالیہ دو اتار چڑھاؤ کی اونچائی کی بنیاد پر اسکیلپنگ اور کراسنگ کا حساب لگاتی ہے۔ دوسرا ، حکمت عملی کا تقاضا ہے کہ داخلہ سگنل کے ساتھ ہونا ضروری ہے 20 ادوار کی اوسط سے 1.5 گنا زیادہ حجم ، اس بات کا یقین کرنے کے لئے کہ توڑنے کی تاثیر ہو۔ آخر میں ، حکمت عملی میں فکسڈ فیصد اسٹاپ نقصان (((2٪) اور اسٹاپ نقصان (((1٪) کا استعمال کیا گیا ہے ، اور منافع کو مقفل کرنے کے لئے 1٪ ٹریکنگ نقصانات متعارف کروائے گئے ہیں۔
یہ ایک مناسب ڈیزائن ، منطقی اور سخت رجحان کی پیروی کرنے والی حکمت عملی ہے۔ متحرک رجحان لائنوں اور ٹرانزیکشن حجم کی تصدیق کے ساتھ مل کر ، اور ایک بہتر رسک مینجمنٹ سسٹم کے ساتھ ، حکمت عملی میں بہتر موافقت اور وشوسنییتا ہے۔ اگرچہ مارکیٹ پر کچھ انحصار موجود ہے ، لیکن تجویز کردہ اصلاحی سمت کے ذریعہ ، حکمت عملی میں بہتری کی گنجائش ہے۔ یہ تجویز ہے کہ تاجر اس کے استعمال سے پہلے پیرامیٹرز کی کافی اصلاح اور جانچ پڑتال کریں۔
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-09 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Long Only Strategy with Dynamic Trend Lines, Fixed TP/SL, and Trailing SL+", overlay=true,
default_qty_type=strategy.percent_of_equity, default_qty_value=10,
pyramiding=0, // Prevent multiple entries
calc_on_order_fills=true,
calc_on_every_tick=true)
// === Parameters ===
swingThreshold = input.int(5, title="Swing Detection Threshold")
tpPercent = input.float(2.0, title="Take Profit (%)")
slPercent = input.float(1.0, title="Stop Loss (%)")
trailPercent = input.float(1.0, title="Trailing Stop (%)")
volumeThresholdMultiplier = input.float(1.5, title="Volume Spike Threshold (x MA)")
// === Volume Indicator ===
avgVolume = ta.sma(volume, 20)
volumeSpike = volume > (avgVolume * volumeThresholdMultiplier)
// === Detect Swing High ===
isSwingHigh = ta.pivothigh(high, swingThreshold, swingThreshold)
// Variables to store swing highs
var float swingHigh1 = na
var float swingHigh2 = na
var int swingHighBar1 = na
var int swingHighBar2 = na
// Update swing highs
if (isSwingHigh)
swingHigh2 := swingHigh1
swingHighBar2 := swingHighBar1
swingHigh1 := high[swingThreshold]
swingHighBar1 := bar_index - swingThreshold
// === Calculate Upper Trend Line ===
var float upperSlope = na
var float upperIntercept = na
// Calculate slope and intercept for upper trend line if there are two swing highs
if (not na(swingHigh1) and not na(swingHigh2))
deltaX = swingHighBar1 - swingHighBar2
if (deltaX != 0)
upperSlope := (swingHigh1 - swingHigh2) / deltaX
upperIntercept := swingHigh1 - (upperSlope * swingHighBar1)
else
upperSlope := 0
upperIntercept := swingHigh1
// Calculate trend line price for the current bar
var float upperTrendPrice = na
if (not na(upperSlope) and not na(upperIntercept))
upperTrendPrice := upperSlope * bar_index + upperIntercept
// Calculate trend line price for the previous bar
var float upperTrendPrice_prev = na
if (not na(upperSlope) and not na(upperIntercept))
upperTrendPrice_prev := upperSlope * (bar_index - 1) + upperIntercept
// === Buy Condition Based on Trend Line Breakout ===
// Buy Signal: Price breaks above Upper Trend Line with volume spike
breakoutBuyCondition = (not na(upperTrendPrice)) and
(close > upperTrendPrice) and
(not na(upperTrendPrice_prev)) and
(close[1] <= upperTrendPrice_prev) and
volumeSpike
// === Manage Single Position ===
// Calculate Take Profit and Stop Loss levels based on percentage
longTakeProfit = close * (1 + tpPercent / 100)
longStopLoss = close * (1 - slPercent / 100)
// Calculate Trailing Stop as trail_offset (in price)
trail_offset = close * (trailPercent / 100)
// Execute Trade with Single Position Management
if (breakoutBuyCondition)
// Close existing short position if any
if (strategy.position_size < 0)
strategy.close("Sell")
// Open long position
strategy.entry("Buy", strategy.long)
// Set Take Profit, Stop Loss, and Trailing Stop Loss for long position
strategy.exit("Take Profit Buy", from_entry="Buy", limit=longTakeProfit, stop=longStopLoss, trail_offset=trail_offset)
// Plot Buy Signal
plotshape(breakoutBuyCondition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")