
এই কৌশলটি একটি পরিমাণগত ট্রেডিং পদ্ধতি যা প্রবণতা ট্র্যাকিং এবং মেশিন লার্নিংয়ের সমন্বয় করে যা বাজারের প্রবণতাকে ক্যাপচার করে এবং গতিশীল স্টপ লস এবং ট্রেন্ড কনফার্মিং সিগন্যালের মাধ্যমে ঝুঁকি হ্রাস করে। কৌশলটি সম্ভাব্য প্রবণতার দিকনির্দেশনা সনাক্ত করতে স্বল্প ও দীর্ঘমেয়াদী সরল চলমান গড় (এসএমএ) ব্যবহার করে এবং ট্রেডিং সিগন্যাল নিশ্চিত করার জন্য মেশিন লার্নিং অবিশ্বাসের প্রতিনিধিত্বকারী হিসাবে তুলনামূলকভাবে শক্তিশালী সূচক (আরএসআই) ব্যবহার করে।
ডায়নামিক ট্রেন্ড ট্র্যাকিং কৌশল এবং মেশিন লার্নিং এন্টিমেটেড রিস্ক ম্যানেজমেন্ট হল একটি সমন্বিত পরিমাণগত ট্রেডিং পদ্ধতি যা ট্রেডারদের জন্য একটি শক্তিশালী হাতিয়ার প্রদান করে। যদিও কৌশলগুলির কিছু সম্ভাব্য ঝুঁকি রয়েছে, ক্রমাগত অপ্টিমাইজেশন এবং উন্নতির মাধ্যমে এর পারফরম্যান্স এবং অভিযোজনযোগ্যতা আরও উন্নত করা যেতে পারে।
/*backtest
start: 2024-09-18 00:00:00
end: 2024-09-25 00:00:00
period: 15m
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Enhanced Trend Following with ML", overlay=true)
// User Inputs
shortLength = input.int(20, minval=1, title="Short Moving Average Length")
longLength = input.int(50, minval=1, title="Long Moving Average Length")
atrPeriod = input.int(14, title="ATR Period")
stopLossMultiplier = input.float(2.0, title="Stop Loss Multiplier")
mlConfidenceThreshold = input.float(0.5, title="ML Confidence Threshold")
// Calculate Moving Averages
shortMA = ta.sma(close, shortLength)
longMA = ta.sma(close, longLength)
// Plot Moving Averages
plot(shortMA, title="Short MA", color=color.red)
plot(longMA, title="Long MA", color=color.blue)
// Trend Strength Indicator (using RSI as a proxy for ML confidence)
mlSignal = math.round(ta.rsi(close, 14) / 100)
// Conditions for entering trades
longCondition = ta.crossover(shortMA, longMA) and mlSignal > mlConfidenceThreshold
shortCondition = ta.crossunder(shortMA, longMA) and mlSignal < (1 - mlConfidenceThreshold)
// ATR for dynamic stop loss
atrValue = ta.atr(atrPeriod)
stopLoss = atrValue * stopLossMultiplier
// Trade Entry
if (longCondition)
strategy.entry("Long", strategy.long)
strategy.exit("SLLong", "Long", stop=strategy.position_avg_price - stopLoss)
if (shortCondition)
strategy.entry("Short", strategy.short)
strategy.exit("SLShort", "Short", stop=strategy.position_avg_price + stopLoss)
// Trade Management
longCrossover = ta.crossover(shortMA, longMA)
shortCrossunder = ta.crossunder(shortMA, longMA)
if (strategy.position_size > 0)
if (longCrossover)
strategy.close("Long")
if (strategy.position_size < 0)
if (shortCrossunder)
strategy.close("Short")
// Trailing Stop for existing positions
var float trailStopLong = strategy.position_avg_price
var float trailStopShort = strategy.position_avg_price
if (strategy.position_size > 0)
trailStopLong := math.min(trailStopLong, close)
strategy.exit("TrailLong", "Long", stop=trailStopLong)
if (strategy.position_size < 0)
trailStopShort := math.max(trailStopShort, close)
strategy.exit("TrailShort", "Short", stop=trailStopShort)
// Additional alert for trend changes
alertcondition(longCrossover, title="Bullish Trend Change", message="Bullish trend change detected")
alertcondition(shortCrossunder, title="Bearish Trend Change", message="Bearish trend change detected")