
یہ حکمت عملی ایک ٹریڈنگ سسٹم ہے جس میں قیمتوں کے توڑ اور متحرک ٹریکنگ اسٹاپ نقصانات پر مبنی ہے۔ یہ پچھلے N سائیکلوں کی اعلی ترین اور کم ترین قیمتوں کی نگرانی کرکے تجارت کرتا ہے ، جب قیمتیں ان اہم سطحوں کو توڑ دیتی ہیں۔ حکمت عملی میں ایک ذہین اسٹاپ نقصان کا طریقہ کار استعمال کیا گیا ہے ، جس میں ٹریکنگ اسٹاپ نقصانات کو صرف 1 فیصد منافع کے بعد ہی چالو کیا جاتا ہے ، جس سے منافع کو مکمل طور پر ترقی دی جاسکتی ہے۔
حکمت عملی کی بنیادی منطق میں درج ذیل اہم حصے شامل ہیں:
یہ ایک مناسب ڈیزائن کردہ رجحان سے باخبر رہنے کی حکمت عملی ہے ، جس میں قیمتوں میں اضافے اور متحرک رکاوٹوں کا امتزاج کیا گیا ہے ، جو بڑے رجحانات کو پکڑنے کے ساتھ ساتھ خطرے کو مؤثر طریقے سے کنٹرول کرنے کے قابل ہے۔ حکمت عملی کی تخصیص پذیری مضبوط ہے ، اور پیرامیٹرز کی اصلاح کے ذریعہ مختلف مارکیٹ کے حالات کے مطابق ڈھال سکتی ہے۔ یہ مشورہ دیا جاتا ہے کہ حکمت عملی کو مختلف مارکیٹ کے حالات میں کارکردگی کی توثیق کرنے کے لئے عملی طور پر چھوٹے عہدوں سے شروع کریں۔
/*backtest
start: 2024-02-21 00:00:00
end: 2025-02-18 08:00:00
period: 2d
basePeriod: 2d
exchanges: [{"eid":"Binance","currency":"TRB_USDT"}]
*/
//@version=5
//TSLA has the buest results on the 5 min or 1 hour chart
//NQ 15 minute
strategy("!! 🔥 Breakout Strategy with Trailing Stop", overlay=true,
default_qty_type=strategy.percent_of_equity, default_qty_value=100,
pyramiding=100)
// User inputs
var int lookbackBars = input.int(10, title="Lookback Bars", minval=1)
var float breakoutThresholdPct = input.float(0.05, title="Breakout Threshold Percentage", minval=0.0001, maxval=5, step=0.01)
var float stopLossPct = input.float(0.2, title="Stop Loss Percentage", minval=0.1) / 100
// Adjusted: No longer directly using takeProfitPct for a fixed take profit level
var float trailStartPct = input.float(0.5, title="Trail Start at Profit Percentage", minval=0.001) / 100
// Tracking the last entry time
var float lastEntryTime = na
// Calculate the highest high and lowest low over the last N bars excluding the current bar
float previousHigh = ta.highest(high[1], lookbackBars)
float previousLow = ta.lowest(low[1], lookbackBars)
// Entry condition adjusted to compare current price against the previous period's high/low
bool breakoutHigh = close > previousHigh * (1 + breakoutThresholdPct / 100) and (na(lastEntryTime) or (time - lastEntryTime) > 3600000 )
bool breakoutLow = close < previousLow * (1 - breakoutThresholdPct / 100) and (na(lastEntryTime) or (time - lastEntryTime) > 3600000 )
// Execute strategy based on the breakout condition
if (breakoutHigh)
strategy.entry("Breakout Buy", strategy.long)
lastEntryTime := time
else if (breakoutLow)
strategy.entry("Breakout Sell", strategy.short)
lastEntryTime := time
// Exiting the strategy with a trailing stop that starts after reaching 1% profit
// Adjusted: Implementing a dynamic trailing stop that activates after a 1% profit
if strategy.position_size > 0
strategy.exit("Trailing Stop Exit", "Breakout Buy", trail_points = close * trailStartPct, trail_offset = close * stopLossPct)
if strategy.position_size < 0
strategy.exit("Trailing Stop Exit", "Breakout Sell", trail_points = close * trailStartPct, trail_offset = close * stopLossPct)
// Visualization for debugging and analysis
plot(previousHigh, color=color.green, linewidth=2, title="Previous High")
plot(previousLow, color=color.red, linewidth=2, title="Previous Low")
// plotshape(series=breakoutHigh, location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
// plotshape(series=breakoutLow, location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")