
এই কৌশলটি একটি ট্রেডিং সিস্টেম যা সমান্তরাল ক্রস সিগন্যাল এবং মার্কেট স্ট্যাটাস ফিল্টারকে একত্রিত করে। এটি 9-চক্র এবং 21-চক্রের সরল চলমান গড় (এসএমএ) এর ক্রস দ্বারা বাজারের প্রবণতা ক্যাপচার করে, এবং গড় দিকনির্দেশক সূচক (এডিএক্স) এবং বিশৃঙ্খলা সূচক (চোপ্পিসনেস ইনডেক্স, সিআই) ব্যবহার করে বাজার পরিবেশকে ফিল্টার করে, কেবলমাত্র ট্রেডিং নিশ্চিত করার জন্য ট্রেডিং নিশ্চিত করে। এই পদ্ধতিটি কার্যকরভাবে প্রচলিত প্রবণতা ট্র্যাকিং কৌশলগুলিকে আধুনিক প্রযুক্তিগত সূচকগুলির সাথে একত্রিত করে, যা একটি আরও শক্তিশালী ট্রেডিং ফ্রেমওয়ার্ক সরবরাহ করে।
এই কৌশলটির মূল তত্ত্বের তিনটি মূল উপাদান রয়েছেঃ
কৌশলটি একটি অপ্টিমাইজড প্রযুক্তিগত সূচক গণনা পদ্ধতি ব্যবহার করে, যার মধ্যে রয়েছে কাস্টমাইজড সমীকরণ ফাংশন, সর্বোচ্চ এবং সর্বনিম্ন মান গণনা, এবং মানককৃত প্রকৃত তরঙ্গদৈর্ঘ্য ((TR) গণনা, যা সংকেতের সঠিকতা এবং গণনার দক্ষতা নিশ্চিত করে।
এই কৌশলটি ক্লাসিক সমান্তরাল ক্রস কৌশলকে আধুনিক প্রযুক্তিগত সূচকগুলির সাথে একত্রিত করে একটি সম্পূর্ণ ট্রেডিং সিস্টেম তৈরি করে। এটি কেবল প্রবণতা ক্যাপচারের দিকে মনোযোগ দেয় না, তবে বিশেষত বাজার পরিবেশের উপযুক্ততার দিকে মনোযোগ দেয়, একাধিক ফিল্টারিং প্রক্রিয়া দ্বারা ব্যবসায়ের স্থায়িত্ব বাড়ায়। যদিও কিছু প্যারামিটার সংবেদনশীলতা এবং পিছিয়ে পড়া সমস্যা রয়েছে, তবে প্রস্তাবিত অপ্টিমাইজেশনের দিকনির্দেশের মাধ্যমে কৌশলটি এখনও অনেক উন্নতির জায়গা রয়েছে। সামগ্রিকভাবে, এটি একটি যৌক্তিকভাবে সম্পূর্ণ, কার্যকরী এবং শক্তিশালী ট্রেডিং কৌশল।
/*backtest
start: 2024-02-22 00:00:00
end: 2024-12-06 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"ETH_USDT"}]
*/
//@version=6
strategy("MA9/MA21 Cross with ADX & CHOP Filter", overlay=true, initial_capital=10000, currency=currency.USD)
// ─── CUSTOM FUNCTIONS ──────────────────────────────────────────────────────
// Custom function to compute the sum over the last 'len' bars.
f_sum(src, len) =>
s = 0.0
for i = 0 to len - 1
s += src[i]
s
// Custom function to compute the highest value over the last 'len' bars.
f_highest(src, len) =>
h = src[0]
for i = 1 to len - 1
h := math.max(h, src[i])
h
// Custom function to compute the lowest value over the last 'len' bars.
f_lowest(src, len) =>
l = src[0]
for i = 1 to len - 1
l := math.min(l, src[i])
l
// ─── INPUTS ──────────────────────────────────────────────────────────────
ma9Period = input.int(9, title="MA 9 Period", minval=1)
ma21Period = input.int(21, title="MA 21 Period", minval=1)
adxLength = input.int(7, title="ADX Smoothing / DI Length", minval=1)
adxThresh = input.float(20.0, title="ADX Threshold", step=0.1)
chopLen = input.int(7, title="CHOP Length", minval=1)
chopOff = input.int(0, title="CHOP Offset", minval=0) // Not applied in calculation
chopThresh = input.float(50.0, title="CHOP Maximum (do not trade if above)", step=0.1)
// ─── CALCULATE INDICATORS ────────────────────────────────────────────────────
// Moving Averages
ma9 = ta.sma(close, ma9Period)
ma21 = ta.sma(close, ma21Period)
// --- True Range Calculation ---
// Manual implementation of true range (tr)
tr = math.max(math.max(high - low, math.abs(high - nz(close[1]))), math.abs(low - nz(close[1])))
// --- ADX Calculation (Manual Implementation) ---
// Calculate directional movements
upMove = high - nz(high[1])
downMove = nz(low[1]) - low
plusDM = (upMove > downMove and upMove > 0) ? upMove : 0.0
minusDM = (downMove > upMove and downMove > 0) ? downMove : 0.0
// Smooth the values using the built-in rma function
atr = ta.rma(tr, adxLength)
plusDI = 100 * ta.rma(plusDM, adxLength) / atr
minusDI = 100 * ta.rma(minusDM, adxLength) / atr
dx = 100 * math.abs(plusDI - minusDI) / (plusDI + minusDI)
adxValue = ta.rma(dx, adxLength)
// --- Choppiness Index Calculation ---
// Compute the sum of true range over chopLen periods
atrSum = f_sum(tr, chopLen)
// Compute highest high and lowest low over chopLen periods using custom functions
highestHigh = f_highest(high, chopLen)
lowestLow = f_lowest(low, chopLen)
priceRange = highestHigh - lowestLow
chop = priceRange != 0 ? 100 * math.log(atrSum / priceRange) / math.log(chopLen) : 0
// ─── STRATEGY CONDITIONS ─────────────────────────────────────────────────────
// MA Crossover Signals
longCond = ta.crossover(ma9, ma21)
shortCond = ta.crossunder(ma9, ma21)
// Filter: Only trade if ADX > threshold and CHOP ≤ threshold.
filterCond = (adxValue > adxThresh) and (chop <= chopThresh)
// Entries and Exits
if longCond and filterCond
strategy.entry("Long", strategy.long)
if shortCond and filterCond
strategy.entry("Short", strategy.short)
if shortCond
strategy.close("Long")
if longCond
strategy.close("Short")
// ─── PLOTTING ──────────────────────────────────────────────────────────────
plot(ma9, color=color.red, title="MA 9")
plot(ma21, color=color.blue, title="MA 21")
plot(adxValue, title="ADX", color=color.purple)
hline(adxThresh, title="ADX Threshold", color=color.purple, linestyle=hline.style_dotted)
plot(chop, title="CHOP", color=color.orange)
hline(chopThresh, title="CHOP Threshold", color=color.orange, linestyle=hline.style_dotted)