
یہ حکمت عملی ایک جامع تجارتی نظام ہے جو رجحان سے باخبر رہنے اور بینڈ ٹریڈنگ کے طریقوں کو جوڑتا ہے ، تاکہ ای ایم اے اور ایس ایم اے کی مساوی کراسنگ ، بینڈ ہائی لوڈس کی شناخت ، ٹرانزیکشن فلٹرنگ اور فیصد اسٹاپ اور ٹریکنگ اسٹاپ نقصان کے طریقہ کار کے ذریعہ ایک مکمل تجارتی نظام تشکیل دیا جاسکے۔ حکمت عملی کا ڈیزائن کثیر جہتی سگنل کی تصدیق پر توجہ دیتا ہے ، جس میں تکنیکی اشارے کے ہم آہنگی کے ذریعے تجارت کی درستگی اور وشوسنییتا میں اضافہ ہوتا ہے۔
حکمت عملی میں ایک کثیر سطحی سگنل فلٹرنگ میکانزم استعمال کیا جاتا ہے ، پہلے EMA ((10) اور SMA ((21)) کے کراس فارمیشن بیس ٹرینڈ کا تعین کیا جاتا ہے ، پھر چھ K لائنوں کے بائیں اور دائیں اونچائی کے نچلے حصے کو توڑ کر داخلے کا وقت طے کیا جاتا ہے ، جبکہ 200 سیکنڈ کی اوسط سے زیادہ تجارت کی ضرورت ہوتی ہے ، تاکہ کافی لیکویڈیٹی کے ماحول میں تجارت کو یقینی بنایا جاسکے۔ نظام میں 2٪ فیصد اسٹاپ اور 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 combining EMA/SMA Crossover, Swing High/Low, Volume Filtering, and Percentage TP & Trailing Stop
strategy("Swing High/Low Strategy with Volume, EMA/SMA Crossovers, Percentage TP and Trailing Stop", overlay=true)
// --- Inputs ---
source = close
TITLE = input(false, title='Enable Alerts & Background Color for EMA/SMA Crossovers')
turnonAlerts = input(true, title='Turn on Alerts?')
colorbars = input(true, title="Color Bars?")
turnonEMASMA = input(true, title='Turn on EMA1 & SMA2?')
backgroundcolor = input(false, title='Enable Background Color?')
// EMA/SMA Lengths
emaLength = input.int(10, minval=1, title='EMA Length')
smaLength = input.int(21, minval=1, title='SMA Length')
ema1 = ta.ema(source, emaLength)
sma2 = ta.sma(source, smaLength)
// Swing High/Low Lengths
leftBars = input.int(6, title="Left Bars for Swing High/Low", minval=1)
rightBars = input.int(6, title="Right Bars for Swing High/Low", minval=1)
// Volume MA Length
volMaLength = input.int(200, title="Volume Moving Average Length")
// Percentage Take Profit with hundredth place adjustment
takeProfitPercent = input.float(2.00, title="Take Profit Percentage (%)", minval=0.01, step=0.01) / 100
// Trailing Stop Loss Option
useTrailingStop = input.bool(true, title="Enable Trailing Stop Loss?")
trailingStopPercent = input.float(1.00, title="Trailing Stop Loss Percentage (%)", minval=0.01, step=0.01) / 100
// --- Swing High/Low Logic ---
pivotHigh(_leftBars, _rightBars) =>
ta.pivothigh(_leftBars, _rightBars)
pivotLow(_leftBars, _rightBars) =>
ta.pivotlow(_leftBars, _rightBars)
ph = fixnan(pivotHigh(leftBars, rightBars))
pl = fixnan(pivotLow(leftBars, rightBars))
// --- Volume Condition ---
volMa = ta.sma(volume, volMaLength)
// Declare exit conditions as 'var' so they are initialized
var bool longExitCondition = na
var bool shortExitCondition = na
// --- Long Entry Condition: Close above Swing High & Volume >= 200 MA ---
longCondition = (close > ph and volume >= volMa)
if (longCondition)
strategy.entry("Long", strategy.long)
// --- Short Entry Condition: Close below Swing Low & Volume >= 200 MA ---
shortCondition = (close < pl and volume >= volMa)
if (shortCondition)
strategy.entry("Short", strategy.short)
// --- Take Profit and Trailing Stop Logic ---
// For long position: Set take profit at the entry price + takeProfitPercent
longTakeProfitLevel = strategy.position_avg_price * (1 + takeProfitPercent)
shortTakeProfitLevel = strategy.position_avg_price * (1 - takeProfitPercent)
// --- Long Exit Logic ---
if (useTrailingStop)
// Trailing Stop for Long
strategy.exit("Long Exit", "Long", stop=na, trail_offset=strategy.position_avg_price * trailingStopPercent, limit=longTakeProfitLevel)
else
// Exit Long on Take Profit only
strategy.exit("Long Exit", "Long", limit=longTakeProfitLevel)
// --- Short Exit Logic ---
if (useTrailingStop)
// Trailing Stop for Short
strategy.exit("Short Exit", "Short", stop=na, trail_offset=strategy.position_avg_price * trailingStopPercent, limit=shortTakeProfitLevel)
else
// Exit Short on Take Profit only
strategy.exit("Short Exit", "Short", limit=shortTakeProfitLevel)
// --- Plot Swing High/Low ---
plot(ph, style=plot.style_circles, linewidth=1, color=color.blue, offset=-rightBars, title="Swing High")
plot(ph, style=plot.style_line, linewidth=1, color=color.blue, offset=0, title="Swing High")
plot(pl, style=plot.style_circles, linewidth=1, color=color.red, offset=-rightBars, title="Swing High")
plot(pl, style=plot.style_line, linewidth=1, color=color.red, offset=0, title="Swing High")
// --- Plot EMA/SMA ---
plot(turnonEMASMA ? ema1 : na, color=color.green, title="EMA")
plot(turnonEMASMA ? sma2 : na, color=color.orange, title="SMA")
// --- Alerts ---
alertcondition(longCondition, title="Long Entry", message="Price closed above Swing High with Volume >= 200 MA")
alertcondition(shortCondition, title="Short Entry", message="Price closed below Swing Low with Volume >= 200 MA")
// --- Bar Colors for Visualization ---
barcolor(longCondition ? color.green : na, title="Long Entry Color")
barcolor(shortCondition ? color.red : na, title="Short Entry Color")
bgcolor(backgroundcolor ? (ema1 > sma2 ? color.new(color.green, 50) : color.new(color.red, 50)) : na)