
এই কৌশলটি একটি জটিল মাল্টি-ইনডিকেটর ট্রেডিং সিস্টেম যা RSI, MACD, মুভিং এভারেজ (SMA) এবং আরও অনেক প্রযুক্তিগত সূচককে একত্রিত করে। এই কৌশলটি দীর্ঘমেয়াদী প্রবণতা নির্ধারণের জন্য 200-দিনের গড় লাইন ব্যবহার করে, মধ্যমেয়াদী প্রবণতা হিসাবে 50-দিনের গড় লাইন ব্যবহার করে এবং ট্রেডিংয়ের সময় নির্ধারণের জন্য র্যান্ডম RSI এবং MACD এর ক্রস সিগন্যাল ব্যবহার করে।
কৌশলটির মূল যুক্তি তিনটি প্রধান স্তম্ভের উপর নির্মিত:
ক্রয় শর্ত একই সময়ে পূরণ করা আবশ্যক:
বিক্রির শর্তাবলীঃ
সূচক প্যারামিটার অপ্টিমাইজেশনঃ
সিগন্যাল ফিল্টারঃ
ঝুঁকি ব্যবস্থাপনার উন্নতিঃ
বাজার অভিযোজনযোগ্যতা:
এটি একটি পদ্ধতিগত প্রবণতা ট্র্যাকিং কৌশল যা একাধিক প্রযুক্তিগত সূচকগুলির সমন্বিত ব্যবহারের মাধ্যমে লেনদেনের নির্ভরযোগ্যতা নিশ্চিত করার পাশাপাশি একটি স্পষ্ট ঝুঁকি নিয়ন্ত্রণ ব্যবস্থাও সরবরাহ করে। কৌশলটির প্রধান সুবিধা হ’ল এর বহু স্তরের যাচাইকরণ ব্যবস্থা, তবে একই সাথে একাধিক সূচক দ্বারা উত্থাপিত হতে পারে এমন পশ্চাদপদ ঝুঁকি নিয়ন্ত্রণের বিষয়েও সতর্কতা প্রয়োজন। ক্রমাগত অপ্টিমাইজেশন এবং উন্নতির মাধ্যমে, কৌশলটি বিভিন্ন বাজারের পরিবেশে স্থিতিশীল পারফরম্যান্স বজায় রাখার প্রত্যাশা করে।
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-10 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("RSI and MACD by Karthik", overlay=true)
// Define periods for SMAs
sma50Period = 50
sma200Period = 200
// Calculate SMAs
sma50 = ta.sma(close, sma50Period)
sma200 = ta.sma(close, sma200Period)
// Plot SMAs on the main chart
plot(sma50, color=color.blue, title="50 Period SMA", linewidth=2)
plot(sma200, color=color.red, title="200 Period SMA", linewidth=2)
// Define and calculate parameters for Stochastic RSI
stochRSIPeriod = 14
rsi = ta.rsi(close, stochRSIPeriod)
stochRSIK = ta.stoch(rsi, rsi, stochRSIPeriod, 3)
stochRSID = ta.sma(stochRSIK, 3)
// Define and calculate parameters for MACD
macdShort = 12
macdLong = 26
macdSignal = 9
[macdLine, signalLine, macdHist] = ta.macd(close, macdShort, macdLong, macdSignal)
// Plot Stochastic RSI in a separate pane
hline(80, "Overbought", color=color.red, linewidth=1)
hline(20, "Oversold", color=color.green, linewidth=1)
plot(stochRSIK, color=color.blue, title="Stochastic RSI %K")
plot(stochRSID, color=color.red, title="Stochastic RSI %D")
// Plot MACD in a separate pane
hline(0, "Zero Line", color=color.gray, linewidth=1)
plot(macdHist, color=color.blue, title="MACD Histogram", style=plot.style_histogram)
plot(macdLine, color=color.red, title="MACD Line")
plot(signalLine, color=color.green, title="Signal Line")
// Conditions for buy and sell signals
isAbove200SMA = close > sma200
isStochRSIKAbove = stochRSIK > stochRSID
macdLineAbove = macdLine > signalLine
buySignal = isAbove200SMA and isStochRSIKAbove and macdLineAbove
isBelow200SMA = close < sma200
isStochRSIKBelow = stochRSIK < stochRSID
macdLineBelow = macdLine < signalLine
sellSignal = isBelow200SMA and isStochRSIKBelow and macdLineBelow
// Track the last signal with explicit type declaration
var string lastSignal = na
// Create series for plotting conditions
var bool plotBuySignal = na
var bool plotSellSignal = na
var bool plotExitBuySignal = na
var bool plotExitSellSignal = na
// Update plotting conditions based on signal and last signal
if buySignal and (lastSignal != "buy")
plotBuySignal := true
lastSignal := "buy"
else
plotBuySignal := na
if sellSignal and (lastSignal != "sell")
plotSellSignal := true
lastSignal := "sell"
else
plotSellSignal := na
// Update exit conditions based on SMA50
if lastSignal == "buy" and close < sma50
plotExitBuySignal := true
lastSignal := na // Clear lastSignal after exit
else
plotExitBuySignal := na
if lastSignal == "sell" and close > sma50
plotExitSellSignal := true
lastSignal := na // Clear lastSignal after exit
else
plotExitSellSignal := na
// Plot buy and sell signals on the main chart
plotshape(series=plotBuySignal, location=location.belowbar, color=color.green, style=shape.circle, size=size.small, title="Buy Signal")
plotshape(series=plotSellSignal, location=location.abovebar, color=color.red, style=shape.circle, size=size.small, title="Sell Signal")
// Plot exit signals for buy and sell
plotshape(series=plotExitBuySignal, location=location.belowbar, color=color.yellow, style=shape.xcross, size=size.small, title="Exit Buy Signal")
plotshape(series=plotExitSellSignal, location=location.abovebar, color=color.yellow, style=shape.xcross, size=size.small, title="Exit Sell Signal")
// Strategy to Backtest
long = buySignal
short = sellSignal
// Exit Conditions
exitBuy = close < sma50
exitSell = close > sma50
if (buySignal)
strategy.entry("Long", strategy.long, 1.0)
if (sellSignal)
strategy.entry("Short", strategy.short, 1.0)
strategy.close("Long", when=exitBuy)
strategy.close("Short", when=exitSell)