
এই কৌশলটি দুটি মুভিং এভারেজ ((MA) ব্যবহার করে ট্রেডিং সিগন্যাল তৈরি করে। যখন সংক্ষিপ্ত সময়ের MA নীচে থেকে উপরে দীর্ঘ সময়ের MA অতিক্রম করে, তখন এটি একটি কেনার সংকেত তৈরি করে; যখন সংক্ষিপ্ত সময়ের MA উপরে থেকে নীচে দীর্ঘ সময়ের MA অতিক্রম করে, তখন এটি একটি বিক্রয় সংকেত তৈরি করে। এই কৌশলটি একই সাথে ট্রেডিং সময়কাল ((8 থেকে 20 UTC) এবং স্টপ পয়েন্ট ((150 পয়েন্ট) সেট করে।
এই কৌশলটি ট্রেডিং সিগন্যাল উত্পন্ন করার জন্য দুটি ভিন্ন চক্রের চলমান গড়ের ক্রস উপর ভিত্তি করে ট্রেন্ডিং বাজারের জন্য প্রযোজ্য। ট্রেডিং সময়কাল এবং একটি নির্দিষ্ট স্টপ-আপ সেট করে কিছুটা ঝুঁকি নিয়ন্ত্রণ করা যেতে পারে। তবে এই কৌশলটি অস্থির বাজারে খারাপ পারফরম্যান্স করতে পারে এবং একটি নির্দিষ্ট স্টপ-আপ কৌশলটির লাভের স্থানকে সীমাবদ্ধ করতে পারে। ভবিষ্যতে আরও প্রযুক্তিগত সূচকগুলি প্রবর্তন করা, স্টপ-আপ সেটিংগুলিকে অনুকূলিত করা, বাজারের মাইক্রোস্ট্রাকচার সম্পর্কিত তথ্য এবং বাজারের বিভিন্ন অবস্থার জন্য বিভিন্ন প্যারামিটার সেটিংগুলি গ্রহণ করা ইত্যাদির মাধ্যমে কৌশলটি অনুকূলিত করার জন্য বিবেচনা করা যেতে পারে।
/*backtest
start: 2024-03-01 00:00:00
end: 2024-03-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy("Moving Average Crossover Strategy", overlay=true)
// User-defined moving average periods
ma1Periods = input(5, title="First Moving Average Periods")
ma2Periods = input(20, title="Second Moving Average Periods")
// Calculate moving averages
ma1 = sma(close, ma1Periods)
ma2 = sma(close, ma2Periods)
// Plot moving averages
plot(ma1, color=color.red, linewidth=2, title="First Moving Average")
plot(ma2, color=color.blue, linewidth=2, title="Second Moving Average")
// Detect crossovers and crossunders
bullishCross = crossover(ma1, ma2)
bearishCross = crossunder(ma1, ma2)
// Define trading hours (8 AM to 2 PM UTC)
startHour = 8
endHour = 20
utcHour = hour(time, "UTC")
isMarketOpen = true
// Define profit target
profitTarget = 150
// Check if the price has closed above/below the MA for the past 4 bars
aboveMa = close[4] > ma1[4] and close[3] > ma1[3] and close[2] > ma1[2] and close[1] > ma1[1]
belowMa = close[4] < ma1[4] and close[3] < ma1[3] and close[2] < ma1[2] and close[1] < ma1[1]
// Create buy and sell signals
if (bullishCross and isMarketOpen and aboveMa)
strategy.entry("Buy", strategy.long)
strategy.exit("Sell", "Buy", profit=profitTarget)
if (bearishCross and isMarketOpen and belowMa)
strategy.entry("Sell", strategy.short)
strategy.exit("Cover", "Sell", profit=profitTarget)
// Plot shapes on crossovers
plotshape(series=bullishCross and isMarketOpen and aboveMa, location=location.belowbar, color=color.green, style=shape.labelup, text="Buy")
plotshape(series=bearishCross and isMarketOpen and belowMa, location=location.abovebar, color=color.red, style=shape.labeldown, text="Sell")