
یہ سپر ٹرینڈ اشارے، ایکسپونینشل موونگ ایوریج (EMA) اور ایوریج ٹرو رینج (ATR) پر مبنی حکمت عملی کے بعد ایک رجحان ہے۔ یہ حکمت عملی مارکیٹ کے رجحانات اور رسک کنٹرول کی متحرک ٹریکنگ حاصل کرنے کے لیے ابتدائی سٹاپ نقصان اور موونگ سٹاپ نقصان کے ساتھ مل کر متعدد تکنیکی اشارے استعمال کرتی ہے۔ حکمت عملی کا بنیادی مقصد SuperTrend اشارے کے ذریعے رجحان کی سمت میں ہونے والی تبدیلیوں کو پکڑنا ہے، رجحان کی تصدیق کے لیے EMA کا استعمال کریں، اور منافع کی حفاظت کے لیے ایک ڈبل سٹاپ-لوس میکانزم ترتیب دیں۔
حکمت عملی درج ذیل بنیادی اجزاء پر مبنی کام کرتی ہے:
جب سپر ٹرینڈ کی سمت نیچے کی طرف مڑ جاتی ہے اور اختتامی قیمت EMA سے اوپر ہوتی ہے، تو سسٹم بغیر کسی پوزیشن کے ایک لمبا سگنل جاری کرتا ہے۔ اس کے برعکس، جب سپر ٹرینڈ سمت اوپر کی طرف مڑتی ہے اور اختتامی قیمت EMA سے کم ہوتی ہے، تو سسٹم ایک مختصر سگنل بھیجتا ہے۔
یہ ایک مکمل تجارتی حکمت عملی ہے جو متعدد تکنیکی اشارے اور رسک کنٹرول میکانزم کو یکجا کرتی ہے۔ SuperTrend انڈیکیٹر کے ذریعے رجحانات کی گرفت کرنے، EMA کے ذریعے سمت کی تصدیق کرنے، اور ڈبل سٹاپ لوس میکانزم کے ساتھ ہم آہنگی کے ذریعے، ایک بہتر رسک ریٹرن تناسب حاصل کیا جاتا ہے۔ حکمت عملی کی اصلاح کی جگہ بنیادی طور پر پیرامیٹرز کی متحرک ایڈجسٹمنٹ، مارکیٹ کے ماحول کا فیصلہ اور رسک مینجمنٹ سسٹم کی بہتری میں ہے۔ اصل ایپلی کیشنز میں، یہ سفارش کی جاتی ہے کہ کافی تاریخی ڈیٹا بیک ٹیسٹنگ کی جائے اور مخصوص تجارتی مصنوعات کی خصوصیات کے مطابق پیرامیٹرز کو ایڈجسٹ کیا جائے۔
/*backtest
start: 2024-01-17 00:00:00
end: 2025-01-15 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT","balance":49999}]
*/
//@version=5
strategy(" nifty supertrend triton", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
// Input parameters
atrPeriod = input.int(16, "ATR Length", step=1)
factor = input.float(3.02, "Factor", step=0.01)
maPeriod = input.int(49, "Moving Average Period", step=1)
trailPoints = input.int(70, "Trailing Points", step=1) // Points after which trailing stop activates
initialStopLossPoints = input.int(50, "Initial Stop Loss Points", step=1) // Initial stop loss of 50 points
// Calculate Supertrend
[_, direction] = ta.supertrend(factor, atrPeriod)
// Calculate EMA
ema = ta.ema(close, maPeriod)
// Variables to track stop loss levels
var float trailStop = na
var float entryPrice = na
var float initialStopLoss = na // To track the initial stop loss
// Generate buy and sell signals
if ta.change(direction) < 0 and close > ema
if strategy.position_size == 0 // Only open a new long position if no current position
strategy.entry("Buy", strategy.long)
entryPrice := close // Record the entry price for the long position
initialStopLoss := entryPrice - initialStopLossPoints // Set initial stop loss for long position
trailStop := na // Reset trailing stop for long
if ta.change(direction) > 0 and close < ema
if strategy.position_size == 0 // Only open a new short position if no current position
strategy.entry("Sell", strategy.short)
entryPrice := close // Record the entry price for the short position
initialStopLoss := entryPrice + initialStopLossPoints // Set initial stop loss for short position
trailStop := na // Reset trailing stop for short
// Apply initial stop loss for long positions
if (strategy.position_size > 0) // Check if in a long position
if close <= initialStopLoss // If the price drops to or below the initial stop loss
strategy.close("Buy", "Initial Stop Loss Hit") // Exit the long position
// Apply trailing stop logic for long positions
if (strategy.position_size > 0) // Check if in a long position
if (close - entryPrice >= trailPoints) // If the price has moved up by the threshold
trailStop := na(trailStop) ? close - trailPoints : math.max(trailStop, close - trailPoints) // Adjust trailing stop upwards
if not na(trailStop) and close < trailStop // If the price drops below the trailing stop
strategy.close("Buy", "Trailing Stop Hit") // Exit the long position
// Apply initial stop loss for short positions
if (strategy.position_size < 0) // Check if in a short position
if close >= initialStopLoss // If the price rises to or above the initial stop loss
strategy.close("Sell", "Initial Stop Loss Hit") // Exit the short position
// Apply trailing stop logic for short positions
if (strategy.position_size < 0) // Check if in a short position
if (entryPrice - close >= trailPoints) // If the price has moved down by the threshold
trailStop := na(trailStop) ? close + trailPoints : math.min(trailStop, close + trailPoints) // Adjust trailing stop downwards
if not na(trailStop) and close > trailStop // If the price rises above the trailing stop
strategy.close("Sell", "Trailing Stop Hit") // Exit the short position