
এই কৌশলটি একটি ট্রেডিং সিস্টেম যা EMA এবং ADX সূচকগুলির সাথে ট্রেডিং ট্রেডিং সিস্টেমকে একাধিক স্তরের স্টপ এবং মুভিং স্টপ দ্বারা অর্থ পরিচালনার অপ্টিমাইজ করার জন্য ব্যবহার করে। কৌশলটি EMA সমান্তরালকে প্রবণতার দিকনির্দেশ হিসাবে ব্যবহার করে, ADX সূচকটি প্রবণতার শক্তিকে ফিল্টার করে, এবং লাভের জন্য তিনটি স্তরের স্টপ সিস্টেম ডিজাইন করে, যখন এটিআরকে ঝুঁকি নিয়ন্ত্রণের জন্য গতিশীলভাবে স্টপ পজিশনের সমন্বয় করে।
কৌশলটির মূল যুক্তিতে নিম্নলিখিত মূল অংশগুলি অন্তর্ভুক্ত রয়েছে:
এটি একটি কাঠামোগত, যুক্তিসঙ্গতভাবে সুস্পষ্ট প্রবণতা ট্র্যাকিং কৌশল যা একাধিক স্তরের স্টপস্টপ এবং গতিশীল স্টপ লস দ্বারা লাভ এবং ঝুঁকির ভারসাম্য বজায় রাখে। কৌশলটির সামগ্রিক নকশাটি কোয়ান্টাম ট্রেডিংয়ের মৌলিক নীতির সাথে সামঞ্জস্যপূর্ণ, ভাল স্কেলযোগ্যতা এবং অপ্টিমাইজেশনের জন্য জায়গা রয়েছে। যুক্তিসঙ্গত প্যারামিটার সমন্বয় এবং অপ্টিমাইজেশনের মাধ্যমে, কৌশলটি বিভিন্ন বাজারের পরিবেশে স্থিতিশীল কর্মক্ষমতা বজায় রাখার প্রত্যাশিত।
/*backtest
start: 2024-03-06 18:40:00
end: 2025-02-17 00:00:00
period: 4h
basePeriod: 4h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=6
strategy("BTC Optimized Strategy v6", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=250)
// === 參數設定 ===
lengthEMA = input(50, title="EMA 週期")
adxLength = input(14, title="ADX 週期")
atrLength = input(14, title="ATR 週期")
riskReward = input(2.0, title="風險報酬比")
tp1_ratio = input(1.0, title="TP1 (ATR 倍數)")
tp2_ratio = input(2.0, title="TP2 (ATR 倍數)")
trailATR = input(3.0, title="移動止盈 ATR 倍數")
// === 計算技術指標 ===
ema = ta.ema(close, lengthEMA)
atr = ta.atr(atrLength)
// === 計算 ADX ===
upMove = math.max(high - nz(high[1], high), 0)
downMove = math.max(nz(low[1], low) - low, 0)
tr = math.max(math.max(high - low, math.abs(high - nz(close[1], close))), math.abs(low - nz(close[1], close)))
plusDM = upMove > downMove and upMove > 0 ? upMove : 0
minusDM = downMove > upMove and downMove > 0 ? downMove : 0
plusDI = 100 * ta.rma(plusDM, adxLength) / ta.rma(tr, adxLength)
minusDI = 100 * ta.rma(minusDM, adxLength) / ta.rma(tr, adxLength)
dx = 100 * math.abs(plusDI - minusDI) / (plusDI + minusDI)
adx = ta.rma(dx, adxLength)
// === 趨勢過濾條件 ===
isTrending = adx > 20
// === 進場條件 ===
longCondition = ta.crossover(close, ema) and isTrending
shortCondition = ta.crossunder(close, ema) and isTrending
// === 計算止損、止盈價格 ===
longStopLoss = low - atr
shortStopLoss = high + atr
longTP1 = close + tp1_ratio * atr
longTP2 = close + tp2_ratio * atr
shortTP1 = close - tp1_ratio * atr
shortTP2 = close - tp2_ratio * atr
// === 設定進場和出場 ===
if longCondition
strategy.entry("Long", strategy.long)
strategy.exit("Long_Exit1", from_entry="Long", qty_percent=30, limit=longTP1, stop=longStopLoss)
strategy.exit("Long_Exit2", from_entry="Long", qty_percent=50, limit=longTP2, stop=longStopLoss)
strategy.exit("Long_Trail", from_entry="Long", qty_percent=20,
trail_points=atr * trailATR,
trail_offset=atr * trailATR)
if shortCondition
strategy.entry("Short", strategy.short)
strategy.exit("Short_Exit1", from_entry="Short", qty_percent=30, limit=shortTP1, stop=shortStopLoss)
strategy.exit("Short_Exit2", from_entry="Short", qty_percent=50, limit=shortTP2, stop=shortStopLoss)
strategy.exit("Short_Trail", from_entry="Short", qty_percent=20,
trail_points=atr * trailATR,
trail_offset=atr * trailATR)
// === 當價格超過 TP2 後,自動平倉 ===
if close >= longTP2
strategy.close("Long")
if close <= shortTP2
strategy.close("Short")
// === 畫圖標示 ===
plotshape(series=longCondition, location=location.belowbar, color=color.blue, style=shape.labelup, title="買入")
plotshape(series=shortCondition, location=location.abovebar, color=color.red, style=shape.labeldown, title="賣出")
plot(ema, color=color.orange, title="EMA")