ডাইরেকশনাল মুভমেন্ট ইন্ডেক্স (ডিএমআই) ট্রেডিং কৌশল

লেখক:চাওঝাং, তারিখ: ২০২৩-০৯-১৮ ১৪ঃ১১ঃ২১
ট্যাগঃ

সারসংক্ষেপ

এই কৌশলটি দিকনির্দেশক আন্দোলন সূচক (ডিএমআই) এর উপর ভিত্তি করে প্রবণতা ট্রেডিং বাস্তবায়ন করে। ডিএমআইতে তিনটি লাইন রয়েছেঃ এডিএক্স, + ডিআই এবং - ডিআই। এডিএক্স প্রবণতা শক্তি দেখায়, একটি প্রান্তিকের উপরে মানগুলি একটি প্রবণতা নির্দেশ করে; + ডিআই এবং - ডিআই উপরের এবং নীচের প্রবণতা শক্তি দেখায়। + ডিআই - ডিআই এর উপরে অতিক্রম করলে লং যান এবং - ডিআই + ডিআই এর উপরে অতিক্রম করলে সংক্ষিপ্ত যান।

কৌশলগত যুক্তি

ADX, +DI এবং -DI রেখা গণনা করুন। একটি প্রবণতা উপস্থিত কিনা তা নির্ধারণের জন্য ADX এর জন্য একটি যুক্তিসঙ্গত থ্রেশহোল্ড সেট করুন, যেমন 25. যখন ADX এই স্তরের উপরে থাকে, যদি +DI -DI এর চেয়ে বড় হয়, একটি আপ ট্রেন্ড সনাক্ত করা হয়, দীর্ঘ যান। যদি -DI +DI এর চেয়ে বড় হয়, একটি ডাউন ট্রেন্ড সনাক্ত করা হয়, শর্ট যান। বিপরীত সংকেত উপস্থিত না হওয়া পর্যন্ত অবস্থানটি ধরে রাখুন।

সুবিধা বিশ্লেষণ

  • ডিএমআই সঠিকভাবে কম সংকেত দিয়ে প্রবণতা দিক চিহ্নিত করে
  • অর্থহীন লেনদেন এড়াতে এডিএক্স অপ্রয়োজনীয় ব্রেকআউট ফিল্টার করে
  • ট্রেডিং ট্রেন্ডের দিক থেকে হুইপসা এড়ায়
  • বড় প্যারামিটার টিউনিং স্পেস - ADX থ্রেশহোল্ড, DI সময়কাল ইত্যাদি

ঝুঁকি বিশ্লেষণ

  • প্রবণতা বিপরীতমুখী হলে ক্ষতি হতে পারে
  • এডিএক্স প্রবণতা শক্তি নির্ধারণে বিলম্ব করেছে
  • দীর্ঘ সময় ধরে ধরে রাখার সময়সূচী ব্যবহারের ঝুঁকি বাড়ায়

ট্রেন্ড রিভার্স নির্ধারণের জন্য হোল্ডিং পিরিয়ড কমিয়ে বা অন্যান্য সূচক যোগ করে হ্রাস করুন।

অপ্টিমাইজেশান নির্দেশাবলী

  • প্রতিক্রিয়াশীলতা এবং গোলমাল ফিল্টারিংয়ের ভারসাম্য বজায় রাখার জন্য ADX পরামিতিগুলি অপ্টিমাইজ করুন
  • পরীক্ষার সময়কালের বিভিন্ন সেটিংসের পরীক্ষার প্রভাব
  • প্রবণতা বিপরীত চিহ্নিত করতে চলমান গড় ইত্যাদি যোগ করার কথা বিবেচনা করুন
  • বিভিন্ন পণ্যের উপর নির্ভরশীলতা পরীক্ষা করুন

সিদ্ধান্ত

ডিএমআই কৌশল সঠিকভাবে নিয়ন্ত্রিত ড্রডাউন সঙ্গে প্রবণতা দিক নির্ধারণ করে। পরামিতি অপ্টিমাইজেশান মাধ্যমে আরও উন্নতি সম্ভব। একটি সহজ এবং ব্যবহারিক প্রবণতা অনুসরণ কৌশল।


/*backtest
start: 2023-09-10 00:00:00
end: 2023-09-17 00:00:00
period: 30m
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// ©wojak_bogdanoff
// @version=5
// Directional Movement Index (DMI)

strategy(title="Directional Movement Index", shorttitle="DMI︎", overlay=true, pyramiding=1, calc_on_every_tick=false, calc_on_order_fills=false, initial_capital=100.0, default_qty_type=strategy.percent_of_equity, default_qty_value=100.0, commission_type=strategy.commission.percent, commission_value=0.1, slippage=1)

trade_type = 'Long' // input.string(defval = "Long", title="Position Type", options=["Both", "Long", "Short"], group='Trading Settings')
strategy_type = 'DMI' // input.string(defval="ECS︎", title="Strategy Type", options='[ECS︎'], group='Trading Settings')

start_date  = input(title='Testing Start Date', defval=timestamp("2017-01-01T00:00:00"), group='Trading Settings')
finish_date = input(title='Testing End Date', defval=timestamp("2025-01-01T00:00:00"), group='Trading Settings')

_testperiod = true
_check = _testperiod

// --- (Start) Directional Movement Index (DMI) ----------------------------- //

dmi_adxSmoothing = input.int(14, title="ADX Smoothing", minval=1, maxval=50)
dmi_len = input.int(7, minval=1, title="DI Length")
dmi_up = ta.change(high)
dmi_down = -ta.change(low)
dmi_plusDM = na(dmi_up) ? na : (dmi_up > dmi_down and dmi_up > 0 ? dmi_up : 0)
dmi_minusDM = na(dmi_down) ? na : (dmi_down > dmi_up and dmi_down > 0 ? dmi_down : 0)
dmi_rma = ta.rma(ta.tr, dmi_len)
dmi_plus = fixnan(100 * ta.rma(dmi_plusDM, dmi_len) / dmi_rma)
dmi_minus = fixnan(100 * ta.rma(dmi_minusDM, dmi_len) / dmi_rma)
dmi_sum = dmi_plus + dmi_minus
dmi_adx = 100 * ta.rma(math.abs(dmi_plus - dmi_minus) / (dmi_sum == 0 ? 1 : dmi_sum), dmi_adxSmoothing)

plot(dmi_adx, color=#F50057, title="ADX")
plot(dmi_plus, color=#2962FF, title="+DI")
plot(dmi_minus, color=#FF6D00, title="-DI")

dmi_consld_limit=input.int(defval=25, title='Consolidation ADX')
dmi_consld=dmi_adx<=dmi_consld_limit
dmi_strong_up=dmi_adx>dmi_consld_limit and dmi_plus>dmi_minus
dmi_strong_down=dmi_adx>dmi_consld_limit and dmi_plus<dmi_minus

barcolor(dmi_consld ? color.new(color.black,0) : na, title='Consolidation region', display=display.none)
barcolor(dmi_strong_up ? color.new(color.green,0) : na, title='Uptrend Region')
barcolor(dmi_strong_down ? color.new(color.red,0) : na, title='Downtrend Region')

dmi_long_e = (not dmi_strong_up[1]) and dmi_strong_up[0]
dmi_long_x = dmi_strong_up[1] and (not dmi_strong_up[0])

dmi_short_e = dmi_strong_up[1] and (not dmi_strong_up[0])
dmi_short_x = (not dmi_strong_up[1]) and dmi_strong_up[0]

// --- (End) Directional Movement Index (DMI) ------------------------------- //

// --- Trade Conditions ----------------------------------------------------- //

var is_long_open=false, var is_short_open=false

long_e = strategy_type == "DMI" ? dmi_long_e : na
long_x = strategy_type == "DMI" ? dmi_long_x : na

short_e = strategy_type == "DMI" ? dmi_short_e : na
short_x = strategy_type == "DMI" ? dmi_short_x : na

long_e_color = input.color(defval=color.new(color.teal,0), title='Long Entry', group='Signals Style - Setting')
long_x_color = input.color(defval=color.new(color.purple,0), title='Long Exit', group='Signals Style - Setting')

is_trade_bar = (long_e and not is_long_open) or (long_x and is_long_open)

barcolor(color=is_trade_bar ? na : (close>open ? color.new(color.green,90) : color.new(color.red,90)), title='Trade Bars')

barcolor(color=(trade_type == 'Long' or trade_type == 'Both') ? long_e and not is_long_open ? long_e_color : na : na, title="Long - Entry Bar", editable=false)
barcolor(color=(trade_type == 'Long' or trade_type == 'Both') ? long_x and is_long_open ? long_x_color : na : na, title="Long - Exit Bar", editable=false)

plotshape((trade_type == 'Long' or trade_type == 'Both') ? long_e and not is_long_open : na, text="B", textcolor=color.white, style=shape.labelup, color=long_e_color, size=size.tiny, location=location.belowbar, title="Long - Entry Labels")
plotshape((trade_type == 'Long' or trade_type == 'Both') ? long_x and is_long_open : na, text="S", textcolor=color.white, style=shape.labeldown, color=long_x_color, size=size.tiny, location=location.abovebar, title="Long - Exit Labels")

plotshape((trade_type == 'Short' or trade_type == 'Both') ? short_e and not is_short_open : na, text="E", textcolor=color.black, style=shape.labeldown, color=color.new(color.yellow,30), size=size.tiny, location=location.abovebar, title="Short - Entry Labels", editable=false)
plotshape((trade_type == 'Short' or trade_type == 'Both') ? short_x and is_short_open : na, text="X", textcolor=color.black, style=shape.labeldown, color=color.new(color.orange,30), size=size.tiny, location=location.abovebar, title="Short - Exit Labels", editable=false)

if long_e and not is_long_open
    is_long_open:=true
if long_x and is_long_open
    is_long_open:=false

if short_e and not is_short_open
    is_short_open:=true
if short_x and is_short_open
    is_short_open:=false

// --- Trade Executions ----------------------------------------------------- //

if trade_type == "Both" and _check
    strategy.entry("Long", strategy.long, comment="Long", when=long_e and _testperiod)
    strategy.close("Long", comment="Exit Long", when=long_x and _testperiod)
    strategy.entry("Short", strategy.short, comment="Short", when=short_e and _testperiod)
    strategy.close("Short", comment="Exit Short", when=short_x and _testperiod)

if trade_type == "Long" and _check
    strategy.entry("Long", strategy.long, comment=" ", when=long_e and _testperiod)
    strategy.close("Long", comment=" ", when=long_x and _testperiod)

if trade_type == "Short" and _check
    strategy.entry("Short", strategy.short, comment="Short", when=short_e and _testperiod)
    strategy.close("Short", comment="Exit Short", when=short_x and _testperiod)
    

আরো