রেঞ্জ ব্রেকআউট ইম্পোমেন্টাম ট্র্যাকিং কৌশল

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

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

এই কৌশলটি স্বল্পমেয়াদী প্রবণতাগুলি ধরার জন্য পরিসীমা, গতি এবং প্রবণতা অনুসরণকারী সূচকগুলিকে একত্রিত করে।

  1. একটি সময়ের মধ্যে মূল্য পরিসীমা গণনা করুন (উচ্চ বিয়োগ নিম্ন) এবং একটি মসৃণ পরিসীমা সূচক পেতে এটি মসৃণ করুন। এটি প্রবণতা শক্তি পরিমাপ করে।

  2. হুল কার্ভের মতো একটি গতির সূচক গণনা করুন। হুল কার্ভ স্বল্পমেয়াদী প্রবণতা দিক এবং শক্তি পরিমাপ করতে কার্যকর।

  3. যখন মসৃণ পরিসীমা সূচকটি রঙ পরিবর্তন করে (উদাহরণস্বরূপ লাল থেকে সবুজ), এটি বিস্তৃত পরিসরের সংকেত দেয় এবং যদি হুল বক্ররেখা সারিবদ্ধ হয় (উদাহরণস্বরূপ উপরে নির্দেশ করে) তবে একটি দীর্ঘ এন্ট্রি নেওয়া হয়।

  4. যখন মসৃণ পরিসীমাটি রঙটি ফ্লিপ করে (উদাহরণস্বরূপ সবুজ থেকে লাল), এটি সঙ্কুচিত পরিসীমাকে সংকেত দেয়, এবং যদি হুল বক্ররেখাটি সারিবদ্ধ হয় (উদাহরণস্বরূপ নীচে নির্দেশ করে) তবে একটি সংক্ষিপ্ত এন্ট্রি নেওয়া হয়।

  5. যদি হুল কার্ভ নিচে যায় তাহলে স্টপ লস মেকানিজম যোগ করুন।

দিকনির্দেশক গতির সাথে বিস্তৃত পরিসীমা স্বল্পমেয়াদী প্রবণতা দ্রুত ক্যাপচার করতে দেয়। প্রবণতা অনুসরণ বন্ধ ঝুঁকি নিয়ন্ত্রণ করে।

সুবিধা

  • শক্তিশালী সংকেতের জন্য একাধিক সূচক একত্রিত করে
  • পরিসীমা বিস্তার পরিমাপ করে, গতিপথ দিকনির্দেশ দেয়
  • স্বল্পমেয়াদী সুযোগগুলো দ্রুত কাজে লাগায়

ঝুঁকি

  • আটকা পড়ার ঝুঁকিতে, সময়মত থামতে হবে
  • বাণিজ্যের উচ্চতর ঘন ঘন মানে আরো খরচ
  • দীর্ঘ পার্শ্ববর্তী পরিসরে কম কার্যকর

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

এই কৌশলটি স্বল্পমেয়াদী প্রবণতাগুলিতে দ্রুত মূলধন অর্জনের জন্য একাধিক প্রযুক্তিগত সূচক ব্যবহার করে। দীর্ঘমেয়াদী কৌশলগুলির তুলনায়, এটি দামের ওঠানামা ক্যাপচার করার জন্য আরও ঘন ঘন বাণিজ্য করে। ঝুঁকি নিয়ন্ত্রণের জন্য কঠোর স্টপ প্রয়োজন।


/*backtest
start: 2023-01-01 00:00:00
end: 2023-04-30 00:00:00
period: 4h
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/
// © flygalaxies

// Strategy based on the Follow Line Indicator by Dreadblitz, Hull Suite by InSilico and Range Filter Buy and Sell 5 min by guikroth
// Designed for the purpose of back testing
// Strategy:
//  - When the Range Filter Color Changes, And the HULL Suite is in that direction, Enter In that direction
//  - e.g Range Filter Changes color from red to green, and Hull Suite is in Green. Enter Long
//  - e.g Range Filter Changes color from green to red, and Hull Suite is in red. Enter Short
//
// Credits:
// Hull Suite by InSilico  https://www.tradingview.com/u/InSilico/
// Range Filter Buy and Sell 5 min https://www.tradingview.com/u/guikroth/
// Follow Line Indicator by Dreadblitz https://www.tradingview.com/u/Dreadblitz/
// Follow line not used at this moment

//@version=5
strategy("Follow The Ranging Hull", overlay=true, initial_capital = 50000)




////////////////////
// COLOR INPUTS ///
//////////////////
rngFilterColorUp = input.color(title="Range Filter Color Up", defval = color.green, group="Color")
rngFilterColorDown = input.color(title="Range Filter Color Up", defval = color.red, group="Color")
hullColorUp = input.color(title="Hull Color Up", defval = color.green, group="Color")
hullColorDown = input.color(title="Hull Color Up", defval = color.red, group="Color")
fliColorUp = input.color(title="Follow Line Color Up", defval = color.green, group="Color")
fliColorDown = input.color(title="Follow Line Color Up", defval = color.red, group="Color")
    

///////////////////////////
// Range Filter INPUTS ///
/////////////////////////
src = input(defval=ohlc4, title="Source", group="Range Filter")
per = input.int(defval=33, minval=1, title="Sampling Period", group="Range Filter")
mult = input.float(defval=2.1, minval=0.1, title="Range Multiplier", group="Range Filter", step=0.1)

/////////////////////////
// Hull Suite INPUTS ///
///////////////////////
srcHull = input(close, title="Source", group="Hull Suite")
modeSwitch = input("Ehma", title="Hull Variation", options=["Hma", "Thma", "Ehma"], group="Hull Suite")
length = input(55, title="Length(180-200 for floating S/R , 55 for swing entry)")
switchColor = input(true, "Color Hull according to trend?", group="Hull Suite")
visualSwitch  = input(true, title="Show as a Band?", group="Hull Suite")
thicknesSwitch = input(1, title="Line Thickness", group="Hull Suite")
transpSwitch = input.int(40, title="Band Transparency",step=5, group="Hull Suite")

//////////////////////////
// FOLLOW LINE INPUTS ///
////////////////////////
BBperiod      = input.int(defval = 21, title = "BB Period", minval = 1)
BBdeviations  = input.float(defval = 1.00, title = "BB Deviations", minval = 0.1, step=0.05)
UseATRfilter  = input.bool(defval = true, title = "ATR Filter")
ATRperiod     = input.int(defval = 5, title = "ATR Period", minval = 1)
hl            = input.bool(defval = false, title = "Hide Labels")

//////////////////////////
// Range Filter Logic ///
////////////////////////

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)

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)

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])

filtcolor = upward > 0 ? rngFilterColorUp : downward > 0 ? rngFilterColorDown : color.orange

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

////////////////////////
// Hull Suite Logic ///
//////////////////////


HMA(_srcHull, _length) =>  ta.wma(2 * ta.wma(_srcHull, _length / 2) - ta.wma(_srcHull, _length), math.round(math.sqrt(_length)))
EHMA(_srcHull, _length) =>  ta.ema(2 * ta.ema(_srcHull, _length / 2) - ta.ema(_srcHull, _length), math.round(math.sqrt(_length)))
THMA(_srcHull, _length) =>  ta.wma(ta.wma(_srcHull,_length / 3) * 3 - ta.wma(_srcHull, _length / 2) - ta.wma(_srcHull, _length), _length)

Mode(modeSwitch, src, len) =>
      modeSwitch == "Hma"  ? HMA(src, len) :
      modeSwitch == "Ehma" ? EHMA(src, len) : 
      modeSwitch == "Thma" ? THMA(src, len/2) : na

_hull = Mode(modeSwitch, src, int(length))
HULL =  _hull
MHULL = HULL[0]
SHULL = HULL[2]

hullColor = switchColor ? (HULL > HULL[2] ? hullColorUp : hullColorDown) : #ff9800
Fi1 = plot(MHULL, title="MHULL", color=hullColor, linewidth=thicknesSwitch, transp=50)
Fi2 = plot(visualSwitch ? SHULL : na, title="SHULL", color=hullColor, linewidth=thicknesSwitch, transp=50)

fill(Fi1, Fi2, title="Band Filler", color=hullColor, transp=transpSwitch)


/////////////////////////
// Follow Line Logic ///
///////////////////////
BBUpper=ta.sma (close,BBperiod)+ta.stdev(close, BBperiod)*BBdeviations
BBLower=ta.sma (close,BBperiod)-ta.stdev(close, BBperiod)*BBdeviations

TrendLine = 0.0
iTrend = 0.0
buy = 0.0
sell = 0.0

BBSignal = close>BBUpper? 1 : close<BBLower? -1 : 0

if BBSignal == 1 and UseATRfilter == 1
    TrendLine:=low-ta.atr(ATRperiod)
    if TrendLine<TrendLine[1] 
        TrendLine:=TrendLine[1]
if BBSignal == -1 and UseATRfilter == 1
    TrendLine:=high+ta.atr(ATRperiod)
    if TrendLine>TrendLine[1]
        TrendLine:=TrendLine[1]
if BBSignal == 0 and UseATRfilter == 1
    TrendLine:=TrendLine[1]
//
if BBSignal == 1 and UseATRfilter == 0
    TrendLine:=low
    if TrendLine<TrendLine[1] 
        TrendLine:=TrendLine[1]
if BBSignal == -1 and UseATRfilter == 0
    TrendLine:=high
    if TrendLine>TrendLine[1]
        TrendLine:=TrendLine[1]
if BBSignal == 0 and UseATRfilter == 0
    TrendLine:=TrendLine[1]
//
iTrend:=iTrend[1]
if TrendLine>TrendLine[1] 
    iTrend:=1
if TrendLine<TrendLine[1] 
    iTrend:=-1
//
buy:=iTrend[1]==-1 and iTrend==1 ? 1 : na
sell:=iTrend[1]==1 and iTrend==-1? 1 : na
//
plot(TrendLine, color=iTrend > 0? fliColorUp : fliColorDown ,style=plot.style_line,linewidth=2,transp=0,title="Trend Line") 
plotshape(buy == 1 and hl == false? TrendLine-ta.atr(8) :na, text='💣', style= shape.labelup, location=location.absolute, color=color.blue, textcolor=color.white, offset=0, transp=0,size=size.auto)
plotshape(sell == 1 and hl == false ?TrendLine+ta.atr(8):na, text='🔨', style=shape.labeldown, location=location.absolute, color=color.red, textcolor=color.white, offset=0, transp=0,size=size.auto)



if(true)
    // RANGE FILTER ENTRY LONG WITH HULL
    // if(filtcolor[1] == rngFilterColorDown and filtcolor == rngFilterColorUp)
    strategy.entry("rngFiltLong", strategy.long, when = buy == 1 and hl == false)
    // RANGE FILTER ENTRY SHORT WITH HULL
    // if(filtcolor[1] == rngFilterColorUp and filtcolor == rngFilterColorDown)
    strategy.entry("rngFiltShort", strategy.short, when = sell == 1 and hl == false)
        
    
    // strategy.close("rngFiltLong", when = HULL < HULL[2] )
    // strategy.close("rngFiltShort", when = HULL > HULL[2] )
    
    
    



আরো