ট্রেন্ড ব্রেকথ্রু ডাবল মুভিং এভারেজ ফিল্টার কৌশল


সৃষ্টির তারিখ: 2023-11-27 17:03:08 অবশেষে সংশোধন করুন: 2023-11-27 17:03:08
অনুলিপি: 0 ক্লিকের সংখ্যা: 689
1
ফোকাস
1617
অনুসারী

ট্রেন্ড ব্রেকথ্রু ডাবল মুভিং এভারেজ ফিল্টার কৌশল

ওভারভিউ

এটি একটি কৌশল যা সমান্তরাল এবং বুলিং চ্যানেল ব্যবহার করে প্রবণতা বিচার করে এবং ফিল্টার এবং স্টপ-অফ নীতিগুলিকে অতিক্রম করে। এটি প্রবণতা পরিবর্তনের সময় সংকেতগুলিকে সময়মতো ক্যাপচার করতে পারে, ডাবল সমান্তরাল ফিল্টারিংয়ের মাধ্যমে ভুল সংকেত হ্রাস করতে পারে এবং ঝুঁকি নিয়ন্ত্রণের জন্য স্টপ-অফ সেট করতে পারে।

কৌশল নীতি

এই কৌশলটি নিম্নলিখিত অংশগুলি নিয়ে গঠিতঃ

  1. প্রবণতা নির্ণয়ঃ MACD ব্যবহার করে মূল্য প্রবণতা নির্ণয় করা হয়।

  2. পরিসীমা ফিল্টারিংঃ ব্রিন চ্যানেল ব্যবহার করে দামের ওঠানামা পরিসীমা নির্ধারণ করা হয় এবং পরিসীমা অতিক্রম না করে এমন সংকেতগুলি ফিল্টার করা হয়।

  3. ডাবল মিডল লাইন কনফার্মেশনঃ দ্রুত ইএমএ এবং ধীর ইএমএর সমন্বয়ে গঠিত ডাবল মিডল লাইন, ট্রেন্ড সিগন্যাল নিশ্চিত করার জন্য ব্যবহৃত হয়। কেবলমাত্র দ্রুত ইএমএ> ধীর ইএমএ হলেই কেনার সংকেত তৈরি হয়।

  4. স্টপ লস মেকানিজমঃ স্টপ লস পয়েন্ট সেট করে, যখন দাম বিপরীত দিকের স্টপ লস পয়েন্ট অতিক্রম করে তখন পজিশন বন্ধ করে দেয়।

সিগন্যাল প্রবেশের বিচার লজিক হল:

  1. MACD-এর মূল্যায়ন
  2. বুলিন চ্যানেলে দাম বেড়েছে
  3. দ্রুত ইএমএ ধীর ইএমএর চেয়ে বেশি

যখন উপরের তিনটি শর্ত একসাথে পূরণ করা হয় তখন একটি ক্রয় সংকেত তৈরি হয়।

সমতল পজিশনের লজিক দুটি ভাগে বিভক্ত, সমতল পজিশন এবং সমতল পজিশন বন্ধ করুন। স্টপ পয়েন্টটি প্রবেশের দামের একটি নির্দিষ্ট অনুপাত দ্বারা গুণিত হয় এবং স্টপ পয়েন্টটি প্রবেশের দামের একটি নির্দিষ্ট অনুপাত দ্বারা গুণিত হয়। যখন দামটি একটি পয়েন্ট অতিক্রম করে তখন সমতল পজিশন।

সামর্থ্য বিশ্লেষণ

এই কৌশলটির সুবিধাগুলি হলঃ

  1. ট্রেন্ডের পরিবর্তনের সময়মত ধরন, কম ট্র্যাকব্যাক।
  2. ডাবল ইক্যুয়ালিটি ফিল্টারিং দ্বারা ত্রুটিপূর্ণ সংকেত, সংকেত গুণমান উন্নত।
  3. ক্ষতি প্রতিরোধ ব্যবস্থা কার্যকরভাবে একক ক্ষতি নিয়ন্ত্রণ করে।
  4. প্যারামিটার অপ্টিমাইজেশনের জন্য যথেষ্ট জায়গা রয়েছে, যা সর্বোত্তম অবস্থার সাথে সামঞ্জস্য করা যেতে পারে।

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

এই কৌশলটির কিছু ঝুঁকিও রয়েছেঃ

  1. ভূমিকম্পের সময় ত্রুটিপূর্ণ সংকেত ক্ষতির কারণ হতে পারে।
  2. ভুলভাবে স্টপ পয়েন্ট সেট করলে অপ্রয়োজনীয় ক্ষতি হতে পারে।
  3. ভুল প্যারামিটারগুলি নীতির কার্যকারিতা হ্রাস করতে পারে।

এই ঝুঁকির জন্য, অপ্টিমাইজেশান প্যারামিটার, স্টপ লস পজিশন এবং আরও অনেক কিছুর মাধ্যমে অপ্টিমাইজেশন এবং উন্নতি করা যেতে পারে।

অপ্টিমাইজেশান দিক

এই কৌশলটি নিম্নলিখিত দিকগুলি থেকে অপ্টিমাইজ করা যেতে পারেঃ

  1. সর্বোত্তম প্যারামিটার সমন্বয় খুঁজতে দ্বি-উপরিমাণের দৈর্ঘ্য সমন্বয় করুন।
  2. ট্র্যাকিং স্টপ, শক স্টপ ইত্যাদির মতো বিভিন্ন ক্ষতি বন্ধ করার পদ্ধতি পরীক্ষা করুন।
  3. MACD প্যারামিটারগুলির উপর পরীক্ষার জন্য সর্বোত্তম প্যারামিটার খুঁজুন।
  4. মেশিন লার্নিং ব্যবহার করে প্যারামিটারগুলি স্বয়ংক্রিয়ভাবে অপ্টিমাইজ করুন।
  5. অতিরিক্ত শর্তাধীন ফিল্টারিং সংকেত যোগ করুন।

বিভিন্ন প্যারামিটার সেটিং পরীক্ষা করে, আয় এবং শার্প অনুপাতের মূল্যায়ন করে, কৌশলটির সর্বোত্তম অবস্থা খুঁজে পাওয়া যায়।

সারসংক্ষেপ

এটি একটি পরিমাপ কৌশল যা প্রবণতা বিচার, পরিসীমা ফিল্টারিং, দ্বি-সমান্তরিত নিশ্চিতকরণ এবং ক্ষতি বন্ধ করার চিন্তাভাবনা ব্যবহার করে। এটি কার্যকরভাবে প্রবণতার দিক নির্ধারণ করতে পারে, মুনাফা সর্বাধিকীকরণ এবং ঝুঁকি নিয়ন্ত্রণের মধ্যে ভারসাম্য খুঁজে পেতে পারে। প্যারামিটার অপ্টিমাইজেশন এবং মেশিন লার্নিং ইত্যাদির মাধ্যমে এই কৌশলটি আরও উন্নত করার জন্য অনেক জায়গা রয়েছে।

কৌশল সোর্স কোড
/*backtest
start: 2022-11-20 00:00:00
end: 2023-11-26 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy(title="Range Filter Buy and Sell Strategies", shorttitle="Range Filter Strategies", overlay=true,pyramiding = 5)

// Original Script > @DonovanWall
// Adapted Version > @guikroth
// 
// Updated PineScript to version 5
// Republished by > @tvenn
// Strategizing by > @RonLeigh
//////////////////////////////////////////////////////////////////////////
// Settings for 5min chart, BTCUSDC. For Other coin, change the parameters
//////////////////////////////////////////////////////////////////////////



SS = input.bool(false,"Percentage Take Profit Stop Loss")


longProfitPerc = input.float(title='LongProfit(%)', minval=0.0, step=0.1, defval=1.5) * 0.01

shortProfitPerc = input.float(title='ShortProfit(%)', minval=0.0, step=0.1, defval=1.5) * 0.01


longLossPerc = input.float(title='LongStop(%)', minval=0.0, step=0.1, defval=1.5) * 0.01

shortLossPerc = input.float(title='ShortStop(%)', minval=0.0, step=0.1, defval=1.5) * 0.01


// Color variables
upColor   = color.white
midColor  = #90bff9
downColor = color.blue

// Source
src = input(defval=close, title="Source")

// Sampling Period
// Settings for 5min chart, BTCUSDC. For Other coin, change the paremeters
per = input.int(defval=100, minval=1, title="Sampling Period")

// Range Multiplier
mult = input.float(defval=3.0, minval=0.1, title="Range Multiplier")

// Smooth Average Range
smoothrng(x, t, m) =>
    wper = t * 2 - 1
    avrng = ta.ema(math.abs(x - x[1]), t)
    smoothrng = ta.ema(avrng, wper) * m
    smoothrng
smrng = smoothrng(src, per, mult)

// Range Filter
rngfilt(x, r) =>
    rngfilt = x
    rngfilt := x > nz(rngfilt[1]) ? x - r < nz(rngfilt[1]) ? nz(rngfilt[1]) : x - r : 
       x + r > nz(rngfilt[1]) ? nz(rngfilt[1]) : x + r
    rngfilt
filt = rngfilt(src, smrng)

// Filter Direction
upward = 0.0
upward := filt > filt[1] ? nz(upward[1]) + 1 : filt < filt[1] ? 0 : nz(upward[1])
downward = 0.0
downward := filt < filt[1] ? nz(downward[1]) + 1 : filt > filt[1] ? 0 : nz(downward[1])

// Target Bands
hband = filt + smrng
lband = filt - smrng

// Colors
filtcolor = upward > 0 ? upColor : downward > 0 ? downColor : midColor
barcolor = src > filt and src > src[1] and upward > 0 ? upColor :
   src > filt and src < src[1] and upward > 0 ? upColor : 
   src < filt and src < src[1] and downward > 0 ? downColor : 
   src < filt and src > src[1] and downward > 0 ? downColor : midColor

filtplot = plot(filt, color=filtcolor, linewidth=2, title="Range Filter")

// Target
hbandplot = plot(hband, color=color.new(upColor, 70), title="High Target")
lbandplot = plot(lband, color=color.new(downColor, 70), title="Low Target")

// Fills
fill(hbandplot, filtplot, color=color.new(upColor, 90), title="High Target Range")
fill(lbandplot, filtplot, color=color.new(downColor, 90), title="Low Target Range")

// Bar Color
barcolor(barcolor)

// Break Outs
longCond = bool(na)
shortCond = bool(na)
longCond := src > filt and src > src[1] and upward > 0 or 
   src > filt and src < src[1] and upward > 0
shortCond := src < filt and src < src[1] and downward > 0 or 
   src < filt and src > src[1] and downward > 0

CondIni = 0
CondIni := longCond ? 1 : shortCond ? -1 : CondIni[1]
longCondition = longCond and CondIni[1] == -1
shortCondition = shortCond and CondIni[1] == 1



// alertcondition(longCondition, title="Buy alert on Range Filter", message="Buy alert on Range Filter")
// alertcondition(shortCondition, title="Sell alert on Range Filter", message="Sell alert on Range Filter")
// alertcondition(longCondition or shortCondition, title="Buy and Sell alert on Range Filter", message="Buy and Sell alert on Range Filter")


////////////// 副

sensitivity = input(150, title='Sensitivity')
fastLength = input(20, title='FastEMA Length')
slowLength = input(40, title='SlowEMA Length')
channelLength = input(20, title='BB Channel Length')
multt = input(2.0, title='BB Stdev Multiplier')

DEAD_ZONE = nz(ta.rma(ta.tr(true), 100)) * 3.7

calc_macd(source, fastLength, slowLength) =>
    fastMA = ta.ema(source, fastLength)
    slowMA = ta.ema(source, slowLength)
    fastMA - slowMA

calc_BBUpper(source, length, multt) =>
    basis = ta.sma(source, length)
    dev = multt * ta.stdev(source, length)
    basis + dev

calc_BBLower(source, length, multt) =>
    basis = ta.sma(source, length)
    dev = multt * ta.stdev(source, length)
    basis - dev

t1 = (calc_macd(close, fastLength, slowLength) - calc_macd(close[1], fastLength, slowLength)) * sensitivity

e1 = calc_BBUpper(close, channelLength, multt) - calc_BBLower(close, channelLength, multt)

trendUp = t1 >= 0 ? t1 : 0
trendDown = t1 < 0 ? -1 * t1 : 0

duoad = trendUp > 0 and trendUp > e1

kongad = trendDown > 0 and trendDown > e1



duo =  longCondition and duoad

kong = shortCondition and kongad


//Alerts
plotshape(longCondition  and trendUp > e1 and  trendUp > 0 , title="Buy Signal", text="Buy", textcolor=color.white, style=shape.labelup, size=size.small, location=location.belowbar, color=color.new(#aaaaaa, 20))
plotshape(shortCondition  and trendDown > e1 and  trendDown > 0 , title="Sell Signal", text="Sell", textcolor=color.white, style=shape.labeldown, size=size.small, location=location.abovebar, color=color.new(downColor, 20))




if  longCondition and trendUp > e1 and  trendUp > 0 
    strategy.entry('Long',strategy.long, comment = "buy" )

if  shortCondition and trendDown > e1 and  trendDown > 0 
    strategy.entry('Short',strategy.short, comment = "sell" )




longlimtPrice  = strategy.position_avg_price * (1 + longProfitPerc)
shortlimtPrice = strategy.position_avg_price * (1 - shortProfitPerc)
   
longStopPrice  = strategy.position_avg_price * (1 - longLossPerc)
shortStopPrice = strategy.position_avg_price * (1 + shortLossPerc)



if (strategy.position_size > 0)  and SS == true
    
    strategy.exit(id="Long",comment_profit = "Profit",comment_loss = "StopLoss", stop=longStopPrice,limit = longlimtPrice)
    

if (strategy.position_size < 0)  and SS == true
    
    strategy.exit(id="Short",comment_profit = "Profit",comment_loss = "StopLoss", stop=shortStopPrice,limit = shortlimtPrice)