
ডায়নামিক ব্রেকিং কৌশল বাজার গতিশীলতা ট্র্যাক করার একটি প্রবণতা কৌশল। এটি বিভিন্ন সূচকগুলির সাথে একত্রিত করে বাজারটি বর্তমানে উত্থান বা পতনের প্রবণতায় রয়েছে কিনা তা নির্ধারণ করে এবং যখন এটি গুরুত্বপূর্ণ প্রতিরোধের পয়েন্টগুলি ভেঙে যায় তখন এটি বেশি পজিশন করে এবং যখন এটি গুরুত্বপূর্ণ সমর্থন পয়েন্টগুলি ভেঙে যায় তখন এটি খালি করে।
এই কৌশলটি মূলত বিভিন্ন দীর্ঘমেয়াদী ডোনচিয়ান চ্যানেলের হিসাব করে বাজার প্রবণতা এবং মূল মূল্যের স্তরগুলি নির্ধারণ করে। বিশেষত, এটি দামের দীর্ঘমেয়াদী ডোনচিয়ান চ্যানেলের মতো দীর্ঘমেয়াদী চক্রটি অতিক্রম করার সময় একটি উচ্চতর প্রবণতা হিসাবে বিচার করা হয় এবং এর ভিত্তিতে বছরের নতুন উচ্চতা, চলমান গড়ের দিকনির্দেশক সারি ইত্যাদি ফিল্টার শর্তগুলির সাথে মিলিত হয়ে একাধিক সংকেত প্রেরণ করা হয়। এবং যখন দাম দীর্ঘমেয়াদী ডোনচিয়ান ট্রেলের নীচে পড়ে যায়, তখন নিম্নমুখী প্রবণতা নির্ধারণের জন্য, বছরের নতুন নিম্নের মতো ফিল্টার শর্তগুলির সাথে মিলিত হয়ে একটি খালি সংকেত প্রেরণ করা হয়।
পজিশন থেকে বেরিয়ে আসার ক্ষেত্রে, এই কৌশলটি দুটি বিকল্প সরবরাহ করেঃ একটি স্থির বাতিল লাইন এবং একটি ট্র্যাকিং স্টপ। একটি স্থির বাতিল লাইন হ’ল 20 দিনের ডোনচিয়ান চ্যানেলের মতো স্বল্প সময়ের উপর ভিত্তি করে একটি স্টপ-অফ সেট করা; একটি ফ্লোটিং স্টপ যা প্রতিদিন এটিআর মানের উপর ভিত্তি করে ট্র্যাকিং স্টপ গণনা করা হয়। উভয় ধরণের স্টপ ভালভাবে ঝুঁকি নিয়ন্ত্রণ করে।
এই কৌশলটি প্রবণতা বিচার এবং বিরতি অপারেশন একত্রিত করে, যা কার্যকরভাবে বাজারে সংক্ষিপ্ত লাইনের দিকনির্দেশমূলক সুযোগগুলি ক্যাপচার করতে পারে। একক সূচকের তুলনায়, এটি একাধিক ফিল্টারিং শর্তের সমন্বিত প্রয়োগ করে, যা কিছু ভুয়া বিরতিগুলি ফিল্টার করতে পারে যা প্রবেশের সংকেতের গুণমানকে উন্নত করে। এছাড়াও, স্টপ লস কৌশলটির প্রয়োগটি এটিকে আরও সহনশীল করে তোলে, এমনকি যদি পরিস্থিতি স্বল্প সময়ের জন্য ফিরে আসে তবে ক্ষতি কার্যকরভাবে নিয়ন্ত্রণ করতে পারে।
এই কৌশলটির প্রধান ঝুঁকি হ’ল বাজারের তীব্র ওঠানামা হতে পারে, যার ফলে স্টপ লসটি পজিশন থেকে বেরিয়ে যাওয়ার জন্য ট্রিগার করা হয়। এই সময়ে যদি বাজারটি দ্রুত বিপরীত হয় তবে সুযোগটি মিস করা যেতে পারে। এছাড়াও, একাধিক ফিল্টারিং শর্তের প্রয়োগও কিছু সুযোগকে ফিল্টার করে এবং কৌশলটির পজিশন ধারণার ঘনত্বকে হ্রাস করে।
ঝুঁকি কমানোর জন্য, এটিআর মান যথাযথভাবে সামঞ্জস্য করা যেতে পারে বা ডনচিয়ান ট্র্যাকের দূরত্ব প্রসারিত করা যেতে পারে, যা স্টপ ড্যাম্পের সম্ভাব্যতা হ্রাস করতে পারে। এছাড়াও, প্রবেশের ফ্রিকোয়েন্সি বাড়ানোর জন্য ফিল্টারিংয়ের শর্তগুলি হ্রাস বা বাতিল করা যেতে পারে, তবে ঝুঁকিও বাড়বে।
এই কৌশলটি নিম্নলিখিত দিকগুলি থেকে উন্নত করা যেতে পারেঃ
বিভিন্ন প্যারামিটার পরীক্ষা করে, আপনি ঝুঁকি এবং উপকারের মধ্যে একটি ভারসাম্য খুঁজে পেতে সর্বোত্তম প্যারামিটার সমন্বয় খুঁজে পেতে পারেন।
এই কৌশলটি প্রবণতার দিকনির্দেশের জন্য একাধিক সূচক ব্যবহার করে, যখন মূল পয়েন্টের ব্রেকডাউন হয় তখন ট্রেডিং সিগন্যাল দেয়। এর স্টপ লস মেকানিজমও কৌশলটিকে শক্তিশালী ঝুঁকি নিয়ন্ত্রণের ক্ষমতা দেয়। প্যারামিটার সেটিং অপ্টিমাইজ করার মাধ্যমে কৌশলটি স্থিতিশীল অতিরিক্ত আয় অর্জন করতে পারে। এটি এমন বিনিয়োগকারীদের জন্য উপযুক্ত যারা বাজারের বিষয়ে পরিষ্কার বিচার না করে তবে প্রবণতা অনুসরণ করতে চায়।
/*backtest
start: 2024-01-23 00:00:00
end: 2024-02-22 00:00:00
period: 1h
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/
// © HeWhoMustNotBeNamed
//@version=4
strategy("BuyHigh-SellLow Strategy", overlay=true, initial_capital = 10000, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, commission_type = strategy.commission.percent, pyramiding = 1, commission_value = 0.01, calc_on_order_fills = true)
donchianEntryLength = input(40, step=10)
donchianExitLength = input(20, step=10)
considerNewLongTermHighLows = input(true)
shortHighLowPeriod = input(120, step=10)
longHighLowPeriod = input(180, step=10)
considerMAAlignment = input(true)
MAType = input(title="Moving Average Type", defval="ema", options=["ema", "sma", "hma", "rma", "vwma", "wma"])
LookbackPeriod = input(40, minval=10,step=10)
atrLength = input(22)
atrMult = input(4)
exitStrategy = input(title="Exit Strategy", defval="tsl", options=["dc", "tsl"])
considerYearlyHighLow = input(true)
backtestYears = input(10, minval=1, step=1)
f_getMovingAverage(source, MAType, length)=>
ma = sma(source, length)
if(MAType == "ema")
ma := ema(source,length)
if(MAType == "hma")
ma := hma(source,length)
if(MAType == "rma")
ma := rma(source,length)
if(MAType == "vwma")
ma := vwma(source,length)
if(MAType == "wma")
ma := wma(source,length)
ma
f_getTrailingStop(atr, atrMult)=>
stop = close - atrMult*atr
stop := strategy.position_size > 0 ? max(stop, stop[1]) : stop
stop
f_getMaAlignment(MAType, includePartiallyAligned)=>
ma5 = f_getMovingAverage(close,MAType,5)
ma10 = f_getMovingAverage(close,MAType,10)
ma20 = f_getMovingAverage(close,MAType,20)
ma30 = f_getMovingAverage(close,MAType,30)
ma50 = f_getMovingAverage(close,MAType,50)
ma100 = f_getMovingAverage(close,MAType,100)
ma200 = f_getMovingAverage(close,MAType,200)
upwardScore = 0
upwardScore := close > ma5? upwardScore+1:upwardScore
upwardScore := ma5 > ma10? upwardScore+1:upwardScore
upwardScore := ma10 > ma20? upwardScore+1:upwardScore
upwardScore := ma20 > ma30? upwardScore+1:upwardScore
upwardScore := ma30 > ma50? upwardScore+1:upwardScore
upwardScore := ma50 > ma100? upwardScore+1:upwardScore
upwardScore := ma100 > ma200? upwardScore+1:upwardScore
upwards = close > ma5 and ma5 > ma10 and ma10 > ma20 and ma20 > ma30 and ma30 > ma50 and ma50 > ma100 and ma100 > ma200
downwards = close < ma5 and ma5 < ma10 and ma10 < ma20 and ma20 < ma30 and ma30 < ma50 and ma50 < ma100 and ma100 < ma200
upwards?1:downwards?-1:includePartiallyAligned ? (upwardScore > 5? 0.5: upwardScore < 2?-0.5:upwardScore>3?0.25:-0.25) : 0
//////////////////////////////////// Calculate new high low condition //////////////////////////////////////////////////
f_calculateNewHighLows(shortHighLowPeriod, longHighLowPeriod, considerNewLongTermHighLows)=>
newHigh = highest(shortHighLowPeriod) == highest(longHighLowPeriod) or not considerNewLongTermHighLows
newLow = lowest(shortHighLowPeriod) == lowest(longHighLowPeriod) or not considerNewLongTermHighLows
[newHigh,newLow]
//////////////////////////////////// Calculate Yearly High Low //////////////////////////////////////////////////
f_getYearlyHighLowCondition(considerYearlyHighLow)=>
yhigh = security(syminfo.tickerid, '12M', high[1])
ylow = security(syminfo.tickerid, '12M', low[1])
yhighlast = yhigh[365]
ylowlast = ylow[365]
yhighllast = yhigh[2 * 365]
ylowllast = ylow[2 * 365]
yearlyTrendUp = na(yhigh)? true : na(yhighlast)? close > yhigh : na(yhighllast)? close > max(yhigh,yhighlast) : close > max(yhigh, min(yhighlast, yhighllast))
yearlyHighCondition = ( (na(yhigh) or na(yhighlast) ? true : (yhigh > yhighlast) ) and ( na(yhigh) or na(yhighllast) ? true : (yhigh > yhighllast))) or yearlyTrendUp or not considerYearlyHighLow
yearlyTrendDown = na(ylow)? true : na(ylowlast)? close < ylow : na(ylowllast)? close < min(ylow,ylowlast) : close < min(ylow, max(ylowlast, ylowllast))
yearlyLowCondition = ( (na(ylow) or na(ylowlast) ? true : (ylow < ylowlast) ) and ( na(ylow) or na(ylowllast) ? true : (ylow < ylowllast))) or yearlyTrendDown or not considerYearlyHighLow
label_x = time+(60*60*24*1000*1)
[yearlyHighCondition,yearlyLowCondition]
donchian(rangeLength)=>
upper = highest(rangeLength)
lower = lowest(rangeLength)
middle = (upper+lower)/2
[middle, upper, lower]
inDateRange = true
[eMiddle, eUpper, eLower] = donchian(donchianEntryLength)
[exMiddle, exUpper, exLower] = donchian(donchianExitLength)
maAlignment = f_getMaAlignment(MAType, false)
[yearlyHighCondition, yearlyLowCondition] = f_getYearlyHighLowCondition(considerYearlyHighLow)
[newHigh,newLow] = f_calculateNewHighLows(shortHighLowPeriod, longHighLowPeriod, considerNewLongTermHighLows)
maAlignmentLongCondition = highest(maAlignment, LookbackPeriod) == 1 or not considerMAAlignment
atr = atr(atrLength)
tsl = f_getTrailingStop(atr, atrMult)
//U = plot(eUpper, title="Up", color=color.green, linewidth=2, style=plot.style_linebr)
//D = plot(exLower, title="Ex Low", color=color.red, linewidth=2, style=plot.style_linebr)
longCondition = crossover(close, eUpper[1]) and yearlyHighCondition and newHigh and maAlignmentLongCondition
exitLongCondition = crossunder(close, exLower[1])
shortCondition = crossunder(close, eLower[1]) and yearlyLowCondition and newLow
exitShortCondition = crossover(close, exUpper[1])
strategy.entry("Buy", strategy.long, when=longCondition and inDateRange, oca_name="oca_buy")
strategy.exit("ExitBuyDC", "Buy", when=exitStrategy=='dc', stop=exLower)
strategy.exit("ExitBuyTSL", "Buy", when=exitStrategy=='tsl', stop=tsl)
plot(strategy.position_size > 0 ? (exitStrategy=='dc'?exLower:tsl) : na, title="Trailing Stop", color=color.red, linewidth=2, style=plot.style_linebr)
//strategy.close("Buy", when=exitLongCondition)