সংশোধিত দিকনির্দেশক আন্দোলন সূচক কৌশল

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

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

এই কৌশলটি সংশোধিত দিকনির্দেশক আন্দোলন সূচক (ডিএমআই) এর উপর ভিত্তি করে ট্রেড করে। সংশোধিত ডিএমআই প্রবণতা দিক নির্ধারণের জন্য ইতিবাচক দিকনির্দেশক (+ ডিআই) এবং নেতিবাচক দিকনির্দেশক (- ডিআই) এর মধ্যে পার্থক্যের তুলনা করে।

লেনদেনের যুক্তি হচ্ছেঃ

  1. একটি সময়ের মধ্যে +DI এবং -DI গণনা করুন

  2. মানচিত্র +DI এবং -DI মান 100 থেকে -100 এর মধ্যে

  3. সংশোধিত ডিএমআই রেখা হিসাবে + ডিআই এবং - ডিআই এর মধ্যে পার্থক্য গ্রাফ করুন

  4. পরিবর্তিত ডিএমআই ০ এর উপরে গেলে লং যান

  5. সংশোধিত ডিএমআই ০ এর নিচে গেলে শর্ট করুন

  6. মিথ্যা সংকেত ফিল্টার করার জন্য ডিএমআই লাইনের ঐচ্ছিক মসৃণকরণ

কৌশলটি সরাসরি +DI এবং -DI এর আপেক্ষিক শক্তির তুলনা করে প্রবণতা নির্ধারণ করে, একক সূচকের সীমাবদ্ধতা অতিক্রম করে।

সুবিধা

  • সংশোধিত ডিএমআই স্বজ্ঞাতভাবে + ডিআই/-ডিআই তুলনা প্রতিফলিত করে

  • ডিএমআই ফিল্টারগুলিকে মসৃণ করা

  • পরিষ্কার দীর্ঘ/সংক্ষিপ্ত সংকেত পয়েন্ট

ঝুঁকি

  • ডিএমআই নিজেই বিলম্ব আছে, সময় ভুল হতে পারে

  • প্যারামিটার সময়কাল অপ্টিমাইজেশান প্রয়োজন

  • ঝামেলাপূর্ণ বাজারগুলোতে ঝাঁকুনির ঝুঁকি

সংক্ষিপ্তসার

এই কৌশলটি সংশোধিত ডিএমআই এর মাধ্যমে প্রবণতা দিকের পরিবর্তনকে বিচার করে, প্রবণতা ট্রেডিংয়ের বিকল্প দৃষ্টিভঙ্গি প্রদান করে। তবে ডিএমআই এর বিলম্বিত প্রকৃতির জন্য সতর্কতা প্রয়োজন এবং এটি অন্যান্য নিশ্চিতকারী সূচকগুলির সাথে একত্রিত হতে পারে।


/*backtest
start: 2022-09-07 00:00:00
end: 2023-09-13 00:00:00
period: 3d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
strategy(shorttitle="DMI Modified Strategy", title="DMI Modified Strategy", overlay=true,default_qty_type=strategy.cash, default_qty_value=10000, initial_capital=10000)
// This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License https://creativecommons.org/licenses/by-sa/4.0/
// © dman103
// As promised a strategy of my DMI Modified indicator! (See link below for indicator).
// === How does it work? ===
// Instead of plotting the positive direction of +DI and negative direction for -DI, we subtract the +DI with the -DI on scales of 100 to -100.
// The result is plotted with a oscillator to identify the current trend.
// DMI Modified supports multiple moving averages (default is EMA with length of 9). You can disable moving averages smoothing in settings.

//== About the Strategy ==
// Buys when the line crosses over the Zero line.
// Sells when the line crosses under the Zero line.
// The DMI modified  strategy is pretty much clean, without any filtering besides the DMI Modified and a moving average to smooth it.
// Works best to catch a trend and more suitable for 1 hour and above time frame. Stay tuned for updates.

// == Oscillator Colors ==
// GREEN : Strong Up Trend as DMI Modified is above zero line and DMI modified is ascending.
// LIGHT GREEN: Still up trend but weakening as DMI modified is above zero but descending. 
// RED: Strong Downtrend as DMI Modified is below zero line and DMI modified is descending.
// LIGHT RED: Still down trending but weakening as DMI modified is below zero but ascending.

// == Notes ==
// Short is enabled by default.
// Can also be used to find divergences.
// Bar coloring is disabled by default

// == Links ==
// DMI modified indicator: https://www.tradingview.com/script/CbDXEyDN-DMI-Modified/
// Like if you like and Enjoy! Follow for more upcoming indicators/strategies: https://www.tradingview.com/u/dman103/#published-scripts

length = input(9, title="Length", minval=0)
smoothing_length=input(9, title="Smoothing length")
ma_select = input(title="Moving Average Type", defval="EMA", options=["NONE","SMA","SMMA" ,"EMA", "WMA", "HMA", "JMA"])
allow_short = input(true,title="Allow Short")
MA_selector(src, length) =>
    ma = 0.0
    if ma_select == "NONE"
        ma:=src
        ma
    if ma_select == "SMA"
        ma := sma(src, length)
        ma
    if ma_select == "SMMA"
        smma = float (0.0)
        smaval=sma(src, length)
        smma := na(smma[1]) ? smaval : (smma[1] * (length - 1) + src) / length
        ma := smma
    if ma_select == "EMA"
        ma := ema(src, length)
        ma

    if ma_select == "WMA"
        ma := wma(src, length)
        ma
    if ma_select == "HMA"
        ma := hma(src,length)
        ma
    if ma_select == "JMA"
        beta = 0.45*(length-1)/(0.45*(length-1)+2)
        alpha = beta
        tmp0 = 0.0, tmp1 = 0.0, tmp2 = 0.0, tmp3 = 0.0, tmp4 = 0.0
        tmp0 := (1-alpha)*src + alpha*nz(tmp0[1])
        tmp1 := (src - tmp0[0])*(1-beta) + beta*nz(tmp1[1])
        tmp2 := tmp0[0] + tmp1[0]
        tmp3 := (tmp2[0] - nz(tmp4[1]))*((1-alpha)*(1-alpha)) + (alpha*alpha)*nz(tmp3[1])
        tmp4 := nz(tmp4[1]) + tmp3[0]
        ma := tmp4
        ma
    
    ma
color_bars=input(false,title="Color bars")
//  Colors
col_grow_above = #26A69A
col_grow_below = #FFCDD2
col_fall_above = #AAFFDB
col_fall_below = #EF5350

dirmov(len,up_band,low_band) =>
	up = change(highest(up_band,len)) 
	down = -change(lowest(low_band,len))
	truerange = rma(tr, len)
	plus = fixnan(100 * rma(up > down and up > 0 ? up : 0, len) / truerange)
	minus = fixnan(100 * rma(down > up and down > 0 ? down : 0, len) / truerange)
	[plus, minus]

[plus, minus]= dirmov(length,high,low)
result= plus-minus
result:=MA_selector(result,smoothing_length)
closeStatus =  strategy.openprofit > 0 ? "win" : "lose"
colors= result > 0 and result>result[1] ? col_grow_above : result > 0 and result<result[1] ? col_fall_above : result<0 and result>result[1] ? col_grow_below : result<0 and result<result[1] ? col_fall_below : color.white
dmi=plot(result, style=plot.style_line, color=colors, linewidth=2, title="DI+-")
barcolor(color_bars ? colors : na)
zero_line=plot(0, color=color.white, title="0-Line",transp=60)
fill (dmi,zero_line,color=colors)
long =  result > 0 and result>result[1]
short = result< 0 and result<result[1]
// strategy.entry("B", true,when=long)
// strategy.entry("S",false,when=short)


//, comment=strategy.position_size<0 ? closeStatus : na)
strategy.close("short",when=long,comment=closeStatus)
strategy.close("long",when=short,comment=closeStatus)
strategy.entry("long", true, when = long)
if (allow_short)
    strategy.entry("short",false, when = short)

plotshape(crossover(result,0) ? result : na, style=shape.circle, color=color.lime,location=location.absolute,size=size.tiny,transp=65)
plotshape(crossunder(result,0) ? result : na, style=shape.circle, color=color.red,location=location.absolute,size=size.tiny,transp=65)

আরো