
یہ حکمت عملی ایک رجحان ٹریکنگ سسٹم ہے جو بورن بینڈ اور ای ایم اے اشارے کے ساتھ مل کر ٹریڈنگ کی کارکردگی کو بہتر بنانے کے لئے ایک کثیر جہتی رسک کنٹرول میکانزم کا استعمال کرتا ہے۔ حکمت عملی کا بنیادی مقصد مارکیٹ کے رجحانات کو پکڑنے کے لئے بورن کے نیچے کی طرف سے ٹوٹنے والی واپسی کی شکل کا استعمال کرنا ہے ، جبکہ ای ایم اے ٹرینڈ فلٹرز کے ساتھ مل کر تجارت کی درستگی کو بہتر بنانا ہے۔ اس نظام میں ایک مکمل رسک مینجمنٹ سسٹم بھی شامل ہے ، جس میں ٹریکنگ اسٹاپ نقصان ، فکسڈ اسٹاپ نقصان ، منافع کے اہداف اور وقت پر مبنی صفائی کا طریقہ کار شامل ہے۔
اس حکمت عملی کی ٹریڈنگ کی منطق مندرجہ ذیل بنیادی عناصر پر مبنی ہے:
یہ ایک اچھی طرح سے ڈیزائن کیا گیا ٹرینڈ ٹریکنگ سسٹم ہے جو برن بینڈ اور ای ایم اے کے امتزاج کے ذریعہ قابل اعتماد ٹریڈنگ سگنل فراہم کرتا ہے اور متعدد سطحوں پر رسک کنٹرول کے ذریعہ تجارت کی حفاظت کو یقینی بناتا ہے۔ حکمت عملی کی مضبوط تشکیل ، مختلف تجارتی طرزوں اور مارکیٹ کے ماحول کے مطابق ڈھالنے کے قابل ہے۔ اگرچہ کچھ موروثی خطرات موجود ہیں ، لیکن تجویز کردہ اصلاح کی سمت سے حکمت عملی کی استحکام اور منافع کو مزید فروغ دیا جاسکتا ہے۔
/*backtest
start: 2025-01-10 00:00:00
end: 2025-02-08 08:00:00
period: 2h
basePeriod: 2h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("AI Bollinger Bands Strategy with SL, TP, and Bars Till Close", overlay=true)
// Input parameters
bb_length = input.int(14, title="Bollinger Bands Length", minval=1)
bb_stddev = input.float(1.5, title="Bollinger Bands Standard Deviation", minval=0.1)
use_ema = input.bool(true, title="Use EMA Filter")
ema_length = input.int(80, title="EMA Length", minval=1)
use_trailing_stop = input.bool(true, title="Use Trailing Stop")
use_sl = input.bool(true, title="Use Stop Loss")
use_tp = input.bool(false, title="Use Take Profit")
sl_dollars = input.float(300.0, title="Stop Loss (\$)", minval=0.0)
tp_dollars = input.float(1000.0, title="Take Profit (\$)", minval=0.0)
use_bars_till_close = input.bool(true, title="Use Bars Till Close")
bars_till_close = input.int(10, title="Bars Till Close", minval=1)
// New input to toggle indicator plotting
plot_indicators = input.bool(true, title="Plot Bollinger Bands and EMA on Chart")
// Calculate Bollinger Bands and EMA
basis = ta.sma(close, bb_length)
upper_band = basis + bb_stddev * ta.stdev(close, bb_length)
lower_band = basis - bb_stddev * ta.stdev(close, bb_length)
ema = ta.ema(close, ema_length)
// Plot Bollinger Bands and EMA conditionally
plot(plot_indicators ? basis : na, color=color.blue, linewidth=2, title="Basis (SMA)")
plot(plot_indicators ? upper_band : na, color=color.red, linewidth=2, title="Upper Band")
plot(plot_indicators ? lower_band : na, color=color.green, linewidth=2, title="Lower Band")
plot(plot_indicators ? ema : na, color=color.orange, linewidth=2, title="EMA")
// EMA conditions
ema_long_condition = ema > ema[1]
ema_short_condition = ema < ema[1]
// Entry conditions
sell_condition = close[1] > upper_band[1] and close[1] > open[1] and close < open
if sell_condition and (not use_ema or ema_short_condition)
strategy.entry("Sell", strategy.short)
buy_condition = close[1] < lower_band[1] and close > open
if buy_condition and (not use_ema or ema_long_condition)
strategy.entry("Buy", strategy.long)
// Trailing stop logic
if use_trailing_stop
if strategy.position_size > 0 and close >= basis
strategy.exit("Trailing Stop Long", from_entry="Buy", stop=low)
if strategy.position_size < 0 and close <= basis
strategy.exit("Trailing Stop Short", from_entry="Sell", stop=high)
// Stop Loss and Take Profit logic
if use_sl or use_tp
if strategy.position_size > 0
long_entry = strategy.position_avg_price
long_sl = long_entry - sl_dollars
long_tp = long_entry + tp_dollars
if use_sl and close <= long_sl
strategy.close("Buy", comment="Long SL Hit")
if use_tp and close >= long_tp
strategy.close("Buy", comment="Long TP Hit")
if strategy.position_size < 0
short_entry = strategy.position_avg_price
short_sl = short_entry + sl_dollars
short_tp = short_entry - tp_dollars
if use_sl and close >= short_sl
strategy.close("Sell", comment="Short SL Hit")
if use_tp and close <= short_tp
strategy.close("Sell", comment="Short TP Hit")
// Bars Till Close logic
var int bars_since_entry = na
if strategy.position_size != 0
bars_since_entry := na(bars_since_entry) ? 0 : bars_since_entry + 1
else
bars_since_entry := na
if use_bars_till_close and not na(bars_since_entry) and bars_since_entry >= bars_till_close
strategy.close("Buy", comment="Bars Till Close Hit")
strategy.close("Sell", comment="Bars Till Close Hit")
// Plot buy/sell signals
plotshape(sell_condition and (not use_ema or ema_short_condition), title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="Sell")
plotshape(buy_condition and (not use_ema or ema_long_condition), title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="Buy")