
یہ حکمت عملی MACD اشارے کے قریب اور پھیلاؤ کی بنیاد پر ٹریڈنگ سگنل کا فیصلہ کرتی ہے۔ جب MACD لائن اور سگنل لائن کا ایک کراس ہوتا ہے اور MACD لائن کی قیمت 1.5 سے زیادہ یا 1.5 سے کم ہوتی ہے تو ، زیادہ اور کم کا اشارہ ہوتا ہے۔ اس کے ساتھ ہی ، حکمت عملی میں ایک مقررہ اسٹاپ نقصان کی پوزیشن مقرر کی گئی ہے ، اور اس میں خطرہ کی واپسی کا تناسب ((R: R) کا تصور متعارف کرایا گیا ہے۔ اس کے علاوہ ، اس حکمت عملی میں دن میں زیادہ سے زیادہ نقصان اور زیادہ سے زیادہ منافع کی حد ، اور زیادہ سخت متحرک اسٹاپ نقصانات کے اقدامات کو بھی اپنایا گیا ہے تاکہ خطرے کو بہتر طور پر کنٹرول کیا جاسکے۔
اس حکمت عملی میں ٹریڈنگ سگنل کا فیصلہ MACD اشارے کے قریب اور پھیلاؤ کے ذریعہ کیا گیا ہے ، اور خطرے کے کنٹرول کے اقدامات جیسے رسک ریٹرن تناسب ، موبائل اسٹاپ نقصان اور دن کی حد متعارف کروائی گئی ہے۔ اگرچہ حکمت عملی کسی حد تک رجحانات کو پکڑنے اور خطرے پر قابو پانے میں کامیاب رہی ہے ، لیکن اس میں کچھ اصلاحات اور بہتری کی گنجائش ہے۔ مستقبل میں سگنل کی تصدیق ، اسٹاپ نقصان ، موبائل اسٹاپ نقصان اور دن کی حد جیسے جہتوں سے اصلاح کرنے پر غور کیا جاسکتا ہے ، تاکہ زیادہ مستحکم اور قابل ذکر منافع حاصل کیا جاسکے۔
/*backtest
start: 2023-05-28 00:00:00
end: 2024-06-02 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © DD173838
//@version=5
strategy("MACD Convergence Strategy with R:R, Daily Limits, and Tighter Stop Loss", overlay=true, default_qty_type=strategy.fixed, default_qty_value=1)
// MACD settings
fastLength = input.int(12, title="Fast Length", minval=1)
slowLength = input.int(26, title="Slow Length", minval=1)
signalSmoothing = input.int(9, title="Signal Smoothing", minval=1)
source = input(close, title="Source")
// Calculate MACD
[macdLine, signalLine, _] = ta.macd(source, fastLength, slowLength, signalSmoothing)
// Plot MACD and signal line
plot(macdLine, title="MACD Line", color=color.blue)
plot(signalLine, title="Signal Line", color=color.red)
// Define convergence conditions
macdConvergenceUp = ta.crossover(macdLine, signalLine) and macdLine > 1.5
macdConvergenceDown = ta.crossunder(macdLine, signalLine) and macdLine < -1.5
// Define take profit and stop loss
takeProfit = 600
stopLoss = 100
// Plot buy and sell signals on the chart
plotshape(series=macdConvergenceDown, title="Short Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SHORT")
plotshape(series=macdConvergenceUp, title="Long Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="LONG")
// Execute short and long orders with defined take profit and stop loss
if (macdConvergenceDown)
strategy.entry("Short", strategy.short, qty=1, stop=high + (stopLoss / syminfo.mintick), limit=low - (takeProfit / syminfo.mintick))
if (macdConvergenceUp)
strategy.entry("Long", strategy.long, qty=1, stop=low - (stopLoss / syminfo.mintick), limit=high + (takeProfit / syminfo.mintick))
// Trailing stop logic
var float entryPrice = na
var float trailingStopPrice = na
if (strategy.position_size != 0)
entryPrice := strategy.opentrades.entry_price(0)
if (strategy.position_size > 0) // For long positions
if (close - entryPrice > 300)
trailingStopPrice := entryPrice + (close - entryPrice - 300)
if (strategy.position_size < 0) // For short positions
if (entryPrice - close > 300)
trailingStopPrice := entryPrice - (entryPrice - close - 300)
if (strategy.position_size > 0 and not na(trailingStopPrice) and close < trailingStopPrice)
strategy.close("Long", comment="Trailing Stop")
if (strategy.position_size < 0 and not na(trailingStopPrice) and close > trailingStopPrice)
strategy.close("Short", comment="Trailing Stop")
// Daily drawdown and profit limits
var float startOfDayEquity = na
if (na(startOfDayEquity) or ta.change(time('D')) != 0)
startOfDayEquity := strategy.equity
maxDailyLoss = 600
maxDailyProfit = 1800
currentDailyPL = strategy.equity - startOfDayEquity
if (currentDailyPL <= -maxDailyLoss)
strategy.close_all(comment="Max Daily Loss Reached")
if (currentDailyPL >= maxDailyProfit)
strategy.close_all(comment="Max Daily Profit Reached")