
یہ حکمت عملی ایک مقداری تجارتی نظام ہے جس میں ایک متحرک اوسط کراس اور نسبتا strong مضبوط اشارے ((RSI) کا امتزاج کیا گیا ہے ، اور اس میں ٹریکنگ اسٹاپ کی خصوصیات کو مربوط کیا گیا ہے۔ اس حکمت عملی میں 9 اور 21 دوروں کی دو متحرک اوسط کو اہم رجحانات کے فیصلے کے اشارے کے طور پر استعمال کیا گیا ہے ، جس میں آر ایس آئی اشارے کے ساتھ تجارتی سگنل کی تصدیق کی گئی ہے ، اور منافع کو بچانے اور خطرات کو کنٹرول کرنے کے لئے متحرک طور پر ٹریکنگ اسٹاپ کا استعمال کیا گیا ہے۔ اس حکمت عملی کے ڈیزائن میں مارکیٹ کے رجحانات ، حرکیات اور خطرے کے انتظام کی تین جہتوں کو مکمل طور پر مدنظر رکھا گیا ہے ، تاکہ ایک مکمل تجارتی نظام تشکیل دیا جاسکے۔
حکمت عملی کی بنیادی منطق درج ذیل کلیدی عناصر پر مبنی ہے:
اس حکمت عملی نے تکنیکی تجزیہ میں کلاسیکی اشارے کو ملا کر ایک تجارتی نظام تشکیل دیا ہے جس میں رجحانات کی پیروی اور متحرک خصوصیات ہیں۔ اس کی بنیادی خوبی ایک کثیر جہتی سگنل کی تصدیق کا طریقہ کار اور ایک مکمل رسک مینجمنٹ سسٹم ہے۔ مسلسل اصلاح اور بہتری کے ذریعہ ، اس حکمت عملی کو مختلف مارکیٹ کے ماحول میں مستحکم کارکردگی برقرار رکھنے کی امید ہے۔ اس سے پہلے کہ اس کا استعمال عملی طور پر کیا جائے ، تاجروں کو مشورہ دیا جاتا ہے کہ وہ کافی جانچ پڑتال کریں اور پیرامیٹرز کی ترتیبات کو مخصوص تجارتی اقسام کی خصوصیات کے مطابق ایڈجسٹ کریں۔
/*backtest
start: 2019-12-23 08:00:00
end: 2024-11-27 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("ojha's Intraday MA Crossover + RSI Strategy with Trailing Stop", overlay=true)
// Define Moving Averages
fastLength = 9
slowLength = 21
fastMA = ta.sma(close, fastLength)
slowMA = ta.sma(close, slowLength)
// Define RSI
rsiPeriod = 14
rsiValue = ta.rsi(close, rsiPeriod)
// Define Conditions for Long and Short
longCondition = ta.crossover(fastMA, slowMA) and rsiValue > 55
shortCondition = ta.crossunder(fastMA, slowMA) and rsiValue < 45
// Define the trailing stop distance (e.g., 1% trailing stop)
trailingStopPercent = 1.0
// Variables to store the entry candle high and low
var float longEntryLow = na
var float shortEntryHigh = na
// Variables for trailing stop levels
var float longTrailingStop = na
var float shortTrailingStop = na
// Exit conditions
exitLongCondition = rsiValue > 80
exitShortCondition = rsiValue < 22
// Stop-loss conditions (price drops below long entry candle low * 1% or exceeds short entry candle high * 1%)
longStopLoss = longEntryLow > 0 and close < longEntryLow * 0.99
shortStopLoss = shortEntryHigh > 0 and close > shortEntryHigh * 1.01
// Execute Buy Order and store the entry candle low for long stop-loss
if (longCondition)
strategy.entry("Long", strategy.long)
longEntryLow := low // Store the low of the candle where long entry happened
longTrailingStop := close * (1 - trailingStopPercent / 100) // Initialize trailing stop at entry
// Execute Sell Order and store the entry candle high for short stop-loss
if (shortCondition)
strategy.entry("Short", strategy.short)
shortEntryHigh := high // Store the high of the candle where short entry happened
shortTrailingStop := close * (1 + trailingStopPercent / 100) // Initialize trailing stop at entry
// Update trailing stop for long position
if (strategy.opentrades > 0 and strategy.position_size > 0)
longTrailingStop := math.max(longTrailingStop, close * (1 - trailingStopPercent / 100)) // Update trailing stop as price moves up
// Update trailing stop for short position
if (strategy.opentrades > 0 and strategy.position_size < 0)
shortTrailingStop := math.min(shortTrailingStop, close * (1 + trailingStopPercent / 100)) // Update trailing stop as price moves down
// Exit Buy Position when RSI is above 80, Stop-Loss triggers, or trailing stop is hit
if (exitLongCondition or longStopLoss or close < longTrailingStop)
strategy.close("Long")
longEntryLow := na // Reset the entry low after the long position is closed
longTrailingStop := na // Reset the trailing stop
// Exit Sell Position when RSI is below 22, Stop-Loss triggers, or trailing stop is hit
if (exitShortCondition or shortStopLoss or close > shortTrailingStop)
strategy.close("Short")
shortEntryHigh := na // Reset the entry high after the short position is closed
shortTrailingStop := na // Reset the trailing stop
// Plot Moving Averages on the Chart
plot(fastMA, color=color.green, title="9-period MA")
plot(slowMA, color=color.red, title="21-period MA")
// Plot RSI on a separate panel
rsiPlot = plot(rsiValue, color=color.blue, title="RSI")
hline(50, "RSI 50", color=color.gray)
hline(80, "RSI 80", color=color.red)
hline(22, "RSI 22", color=color.green)
// Plot Trailing Stop for Visualization
plot(longTrailingStop, title="Long Trailing Stop", color=color.red, linewidth=1, style=plot.style_line)
plot(shortTrailingStop, title="Short Trailing Stop", color=color.green, linewidth=1, style=plot.style_line)