
یہ حکمت عملی 20 دن اور 200 دن کے انڈیکس کے متحرک اوسط ((EMA) کے کراس سگنل پر مبنی ہے اور خرید و فروخت کے اشارے پیدا کرنے کے لئے نسبتا weak مضبوط اشارے ((RSI) اور متحرک اوسط اختتام پھیلنے والے اشارے ((MACD) کے ساتھ مل کر تصدیق کی جاتی ہے۔ اس کے ساتھ ہی ، حکمت عملی تجارتی خطرات کو منظم کرنے اور منافع کو مقفل کرنے کے لئے متحرک اسٹاپ نقصان اور فکسڈ ٹارگٹ منافع کے طریقہ کار کو اپناتی ہے۔
ای ایم اے کراس سگنل کے ساتھ مل کر آر ایس آئی اور ایم اے سی ڈی کی تصدیق ، اور متحرک اسٹاپ نقصان اور فکسڈ ٹارگٹ ریٹرن کے ساتھ اس حکمت عملی کے خطرے کے انتظام کے طریقہ کار کے ذریعہ ، رجحان ساز مارکیٹوں میں مستحکم منافع حاصل کرنے کا امکان ہے۔ تاہم ، اتار چڑھاؤ والی مارکیٹوں میں ، اس حکمت عملی کو بار بار تجارت اور مسلسل نقصانات کا خطرہ لاحق ہوسکتا ہے۔ لہذا ، حکمت عملی کی موافقت اور استحکام کو بڑھانے کے لئے مزید اصلاحات اور بہتری کی ضرورت ہے۔
/*backtest
start: 2023-06-11 00:00:00
end: 2024-06-16 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("EMA Crossover Strategy with RSI and MACD Confirmation and Dynamic Trailing Stop Loss", overlay=true)
// Calculate EMAs
ema20 = ta.ema(close, 20)
ema200 = ta.ema(close, 200)
// Calculate RSI
rsi = ta.rsi(close, 14)
// Calculate MACD
[macdLine, signalLine, _] = ta.macd(close, 12, 26, 9)
// Plot EMAs, RSI, and MACD on the chart
plot(ema20, color=color.blue, title="EMA 20")
plot(ema200, color=color.red, title="EMA 200")
hline(70, "Overbought", color=color.red)
hline(30, "Oversold", color=color.green)
plot(rsi, title="RSI", color=color.orange)
hline(0, "Zero Line", color=color.gray)
plot(macdLine, title="MACD Line", color=color.aqua)
plot(signalLine, title="Signal Line", color=color.fuchsia)
// Strategy parameters
targetProfitPercent = 20
trailingStopIncrement = 10
// Strategy variables
var float initialStopLevel = na
var float trailingStopLevel = na
// Strategy rules with RSI and MACD confirmation
longCondition = ta.crossover(ema20, ema200) and rsi > 50 and macdLine > signalLine
shortCondition = ta.crossunder(ema20, ema200) and rsi < 50 and macdLine < signalLine
// Execute trades
if (longCondition)
strategy.entry("Buy Call", strategy.long)
initialStopLevel := strategy.position_avg_price * (1 - 0.10) // Initial stop-loss at 10% below entry price
if (shortCondition)
strategy.entry("Buy Put", strategy.short)
// Calculate profit and loss targets
takeProfit = strategy.position_avg_price * (1 + targetProfitPercent / 100) // 20% profit target
// Update trailing stop loss
if (strategy.opentrades > 0)
if (strategy.position_size > 0) // Long position
if (strategy.netprofit >= takeProfit)
// Update stop-loss based on profit increments
if (trailingStopLevel == na)
trailingStopLevel := strategy.position_avg_price * (1 - 0.10) // Initial trailing stop at 10% below entry price
else
if (strategy.position_avg_price * (1 - 0.10) > trailingStopLevel)
trailingStopLevel := strategy.position_avg_price * (1 - 0.10) // Increase stop-loss to 10% below current price
// Apply trailing stop loss
strategy.exit("Take Profit", "Buy Call", stop=trailingStopLevel)
// Plot buy and sell signals on the chart
plotshape(series=longCondition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(series=shortCondition, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")