প্রবণতা অনুসরণকারী কৌশল যা চলমান গড়ের উপর ভিত্তি করে

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

img

সারসংক্ষেপ

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

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

কৌশলটি পাইন স্ক্রিপ্টে তৈরি করা হয়েছে এবং নিম্নলিখিত প্রধান উপাদানগুলি নিয়ে গঠিতঃ

  1. ইনপুট

    ইনপুট প্যারামিটার সময়কালকে চলমান গড় সময়কাল হিসাবে সংজ্ঞায়িত করে, ডিফল্ট 200; এবং বার টাইমফ্রেম হিসাবে টাইমফ্রেম, ডি (দৈনিক বার) হিসাবে ডিফল্ট।

  2. চলমান গড়

    তা.ইমা ফাংশন ব্যবহার করে এক্সপোনেন্সিয়াল মুভিং মিডিয়ার (ইএমএ) গণনা করে।

  3. ব্রেকআউট সনাক্তকরণ

    ta.crossover এবং ta.crossunder ফাংশন ব্যবহার করে ব্রেকআউট এবং ব্রেকডাউন সনাক্ত করে।

  4. সিগন্যাল প্লটিং

    পলায়নের সময় বারগুলিতে উপরে এবং নীচে তীরগুলি প্লট করে।

  5. বাণিজ্যিক প্রবেশ ও প্রস্থান

    ট্রেডিং শুরু করে এবং যখন দাম 2x স্টপ লস দূরত্বে পৌঁছায় তখন সেখান থেকে বের হয়।

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

সুবিধা বিশ্লেষণ

এই কৌশলটির প্রধান সুবিধাগুলির মধ্যে রয়েছেঃ

  1. সহজ যুক্তি, সহজেই বোঝা যায় এবং আয়ত্ত করা যায়।

  2. শুধুমাত্র একটি সূচক উপর নির্ভর করে, ন্যূনতম পরামিতি মিটিং সঙ্গে।

  3. ব্রেকআউট সংকেতগুলি প্রবণতা অনুসারে, অত্যধিক ট্রেডিং এড়ানো।

  4. উচ্চতর সময়সীমাগুলি স্পষ্টভাবে প্রধান প্রবণতাগুলিকে শব্দ ছাড়াই চিত্রিত করে।

  5. নমনীয় সময়সীমার সমন্বয় বিভিন্ন পণ্যের জন্য উপযুক্ত।

  6. সহজেই বিভিন্ন পণ্যের মধ্যে স্কেলযোগ্য, একযোগে ড্রাউনডাউন এড়ানো।

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

সম্ভাব্য ঝুঁকিগুলি হলঃ

  1. ব্রেকআউট সিগন্যালগুলি মিথ্যা সিগন্যাল হতে পারে, যা বাজারের গোলমালকে কার্যকরভাবে ফিল্টার করতে অক্ষম।

  2. স্বল্পমেয়াদী সুযোগগুলোকে কাজে লাগাতে অক্ষম।

  3. যদি প্রধান প্রবণতা ভুল হয় তাহলে বিশাল ক্ষতি হবে।

  4. মুভিং মিডিয়ার সাথে ট্রেডিং টাইমফ্রেমের মধ্যে সময়সীমার অসঙ্গতি হতে পারে অতিরিক্ত ট্রেডিং বা মিসড মুনাফা।

  5. রিয়েল-টাইম স্টপ লস না থাকলে ক্ষতি বাড়তে পারে।

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

উন্নতির সুযোগ

কৌশলটি নিম্নলিখিত দিকগুলিতে উন্নত করা যেতে পারেঃ

  1. ব্রেকআউটের নির্ভরযোগ্যতা বাড়াতে MACD, KD এর মতো প্রবণতা অনুসরণকারী সূচক যুক্ত করুন।

  2. ভূল ব্রেকআউট এড়াতে ভলিউম বা বোলিংজার ব্যান্ডের উপর ভিত্তি করে ফিল্টার যুক্ত করুন।

  3. ট্রেন্ড চক্রের সাথে হোল্ডিং সময়ের সাথে মেলে এমন প্যারামিটার টিউনিং অপ্টিমাইজ করুন।

  4. একক ট্রেড লস নিয়ন্ত্রণের জন্য রিয়েল টাইম স্টপ লস অন্তর্ভুক্ত করুন।

  5. গতিশীল পরামিতি অপ্টিমাইজেশান জন্য মেশিন লার্নিং কৌশল অন্বেষণ।

  6. সামগ্রিক স্থিতিশীলতা বাড়ানোর জন্য বিভিন্ন সম্পদ বরাদ্দের সমন্বয় পরীক্ষা করুন।

সিদ্ধান্ত

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


/*backtest
start: 2023-09-29 00:00:00
end: 2023-10-29 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// @version=5
// Open-Range-Breakout strategy
// No license. Free and Open Source.    

strategy('Strategy: ORB', shorttitle="ORB", overlay=true , currency=currency.NONE, initial_capital=100000)

// Inputs
period = input.int(defval=15, title="TimeRange", tooltip="The range in minutes (default: 15m)")
sessionInput = input(defval="0915-0930", title="Time Range", group="ORB settings", tooltip='What is the timeperiod (default 9:15AM to 9:30AM, exchange timezone')
hide = input.bool(defval = false, title="Hide ORB Range", group="ORB setting", tooltip = 'Hide the ORB range drawing')

// SL Related
slAtrLen = input.int(defval=14, title="ATR Period for placing SL", group="StopLoss settings")
showSLLines = input.bool(defval=false, title="Show SL lines in chart", tooltip="Show SL lines also as dotted lines in chart. Note: chart may look untidy.", group="StopLoss settings")

// Further Filtering
ignoreMementumVolume = input.bool(defval=false, title="Ignore Momentum & Volume", tooltip="Ignore Momentum & Volume to find out trades", group="Strengh Settings")
rsiLen = input.int(defval=14, title="Momentum Period", group="Strengh Settings", tooltip = 'To determine the momentum, RSI period is set default to 100')
rsiBullish = input.int(defval=50, step=1, title="Bullish Momentum", group="Strengh Settings", tooltip = 'Bullish Momentum, default set to RSI as 50')
rsiBearish = input.int(defval=50, step=1, title="Bearish Momentum", group="Strengh Settings", tooltip = 'Bearish Momentum, default set to RSI as 50')
volAvg = input.int(defval=20, step=1, title="Volume Average Period", group="Strengh Settings", tooltip = 'To calculate average volume, how many historical bars are considered. Default: 20.')
volThreshold = input.float(defval=1, step=0.1, title="Volume Strengh", group="Strengh Settings", tooltip = 'Multiplier: How big the current bar volume compared to average of last 20')

trendPeriod = input.int(defval=200, step=1, title="Trend Period", group="Trend Settings", tooltip = 'To calculate trend, what period is considered. Default: 200.')
hideTrend = input.bool(defval = false, title="Hide the trend line", group="Trend Settings", tooltip = 'Hide the trend')

hidePDHCL = input.bool(defval = false, title="Hide the PDHCL (prev day High Close Low range)", tooltip = 'Hide the Previous Day High, Close, Low lines')

hideTable = input.bool(defval = false, title="Hide the Summary Table", tooltip = 'Hide the summary table.')

// Trade related
rrRatio = input.float(title='Risk:Reward', step=0.1, defval=2.0, group="Trade settings")
endOfDay = input.int(defval=1500, title="Close all trades, default is 3:00 PM, 1500 hours (integer)", group="Trade settings")
mktAlwaysOn = input.bool(defval=true, title="Markets that never closed (Crypto, Forex, Commodity)", tooltip="Some markers never closes. For those cases, make this checked.", group="Trade settings")
lotSize = input.int(title='Lot Size', step=1, defval=1, group="Trade settings")

// Util method

is_newbar(res) => 
	timeframe.change(time(res)) != 0

// print table
printTable(txt) =>
    var table t = table.new(position.bottom_right, 1, 1)
    table.cell(t, 0, 0, txt, text_halign = text.align_left, bgcolor = color.lime)
	
// globals
t = time(timeframe.period, sessionInput + ":1234567") // everyday
in_session = not na(t)
is_first = in_session and not in_session[1]
is_end_session = in_session[1] and not in_session
green(open, close) => close > open ? true : false
red(open, close) => close < open ? true : false

var float orb_high = na
var float orb_low = na
if is_first
    orb_high := high
    orb_low := low
else
    orb_high := orb_high[1]
    orb_low := orb_low[1]
if high > orb_high and in_session
    orb_high := high
if low < orb_low and in_session
    orb_low := low

plot(hide ? na : orb_high, style=plot.style_line, color=orb_high[1] != orb_high ? na : color.green, title="ORB High", linewidth=2)
plot(hide ? na : orb_low, style=plot.style_line, color=orb_low[1] != orb_low ? na : color.red, title="ORB Low", linewidth=2)



// PDHCL (Previous Day High Close Low)
[dh,dl,dc] = request.security(syminfo.ticker, "D", [high[1],low[1], close[1]], lookahead=barmerge.lookahead_on)
plot(hidePDHCL ? na : dh, title="Prev High",  color=color.red,  linewidth=2, trackprice=true, show_last = 1)
plot(hidePDHCL ? na : dl, title="Prev Low",  color=color.green,  linewidth=2, trackprice=true, show_last = 1)
plot(hidePDHCL ? na : dc, title="Prev Close",  color=color.black,  linewidth=2, trackprice=true, show_last = 1)
plot(hidePDHCL ? na : ta.vwap(close), title="Prev VWAP",  color=color.fuchsia,  linewidth=2, trackprice=true, show_last = 1)

var l1 = label.new(bar_index, hidePDHCL ? na : dh, 'PDH', style=label.style_label_right)

// Previous Day WWAP


// For SL calculation
atr = ta.atr(slAtrLen)	
highestHigh = ta.highest(high, 7)
lowestLow = ta.lowest(low, 7)
longStop = showSLLines ? lowestLow - (atr * 1) : na
shortStop = showSLLines ? highestHigh + (atr * 1) : na
plot(longStop, title="Buy SL", color=color.green, style=plot.style_cross)
plot(shortStop, title="Sell SL", color=color.red, style=plot.style_cross)

// Momentum: rsi
rsi = ta.rsi(close, rsiLen)

// trend: EMA200
ema = ta.ema(close, trendPeriod)
plot(hideTrend ? na : ema, "EMA Trend", color=close > ema ? color.green : color.red, linewidth = 1)

// Volume-Weighed Moving Average calculation
vwmaAvg = ta.vwma(close, volAvg)
vwma_latest = volume
// plotshape((barstate.isconfirmed and (vwma_latest > (vwmaAvg * volThreshold))), title='VolumeData', text='', location=location.abovebar, style=shape.diamond, color=color.gray, textcolor=color.gray, size=size.tiny)

// Trade signals

longCond = barstate.isconfirmed and (ta.crossover(close, orb_high) or ta.crossover(close, dh)) and green(open, close) and (ignoreMementumVolume ? true : rsi > rsiBullish and (vwma_latest > (vwmaAvg * volThreshold)))
shortCond = barstate.isconfirmed and (ta.crossunder(close, orb_low) or ta.crossunder(close, dl)) and red(open, close) and (ignoreMementumVolume ? true : rsi < rsiBearish and (vwma_latest > (vwmaAvg * volThreshold)))

plotshape(longCond, title='Breakout', text='BO', location=location.belowbar, style=shape.triangleup, color=color.green, textcolor=color.green)
plotshape(shortCond, title='Breakout', text='BD', location=location.abovebar, style=shape.triangledown, color=color.red, textcolor=color.red)


// Trade execute
h = hour(time('1'), syminfo.timezone)
m = minute(time('1'), syminfo.timezone)
hourVal = h * 100 + m
totalTrades = strategy.opentrades + strategy.closedtrades
if (mktAlwaysOn or (hourVal < endOfDay))
    // Entry
    var float sl = na
    var float target = na
    if (longCond)
        strategy.entry("enter long", strategy.long, lotSize, limit=na, stop=na, comment="Enter Long")
        sl := longStop
        target := close + ((close - longStop) * rrRatio)
        alert('Buy:' + syminfo.ticker + ' ,SL:' + str.tostring(math.floor(sl)) + ', Target:' + str.tostring(target), alert.freq_once_per_bar)
    if (shortCond)
        strategy.entry("enter short", strategy.short, lotSize, limit=na, stop=na, comment="Enter Short")
        sl := shortStop
        target := close - ((shortStop - close) * rrRatio)
        alert('Sell:' + syminfo.ticker + ' ,SL:' + str.tostring(math.floor(sl)) + ', Target:' + str.tostring(target), alert.freq_once_per_bar)

    // Exit: target or SL
    if ((close >= target) or (close <= sl))
        strategy.close("enter long", comment=close < sl ? "Long SL hit" : "Long target hit")
    if ((close <= target) or (close >= sl))
        strategy.close("enter short", comment=close > sl ? "Short SL hit" : "Short target hit")
else if (not mktAlwaysOn)
    // Close all open position at the end if Day
    strategy.close_all(comment = "Close all entries at end of day.")


// Plotting table
if (not hideTable and is_end_session)
    message =  syminfo.ticker + " :\n\nORB Upper: " + str.tostring(math.round(orb_high)) + "\nORB Lower: " + str.tostring(math.round(orb_low)) + "\nPDH: " + str.tostring(math.round(dh)) + "\nPDC: " + str.tostring(math.round(dc)) + "\nPDL: " + str.tostring(math.round(dl)) + "\nVWAP: " + str.tostring(math.round(ta.vwap(close)))   
    printTable(message)
    alert(message, alert.freq_once_per_bar_close)



আরো