ব্রেকআউট ট্র্যাকিং কৌশল

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

img

সারসংক্ষেপ

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

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

  1. ডনচিয়ান চ্যানেল সূচকের জন্য প্যারামিটার সেট করুন, ডিফল্ট সময় 20 হয়;

  2. EMA চলমান গড় সেট করুন, ডিফল্ট সময়কাল 200;

  3. সেট রিস্ক/রিওয়ার্ড রেসিও, ডিফল্ট হল 1.5;

  4. দীর্ঘ এবং সংক্ষিপ্ত জন্য ব্রেকআউট পরে pullback পরামিতি সেট করুন;

  5. পূর্ববর্তী ব্রেকআউট উচ্চ বা নিম্ন পয়েন্ট ছিল কিনা তা রেকর্ড করুন;

  6. লং সিগন্যালঃ যদি পূর্ববর্তী ব্রেকআউটটি একটি নিম্ন ছিল, তবে দাম ডনচিয়ান উপরের ব্যান্ড এবং ইএমএ লাইনের উপরে ভেঙে যায়;

  7. সংক্ষিপ্ত সংকেতঃ যদি পূর্ববর্তী ব্রেকআউটটি একটি উচ্চ ছিল, তবে দামটি ডনচিয়ান নিম্ন ব্যান্ডের নীচে এবং ইএমএ লাইনের নীচে ভেঙে যায়;

  8. লং এন্ট্রি করার পর, স্টপ লস সেট করুন ৫ পয়েন্ট বিয়োগ করে ডনচিয়ান নিম্ন ব্যাংকে, ঝুঁকি/উপার্জনের অনুপাতের সময় লাভ নিন স্টপ লস দূরত্ব;

  9. সংক্ষিপ্ত প্রবেশের পর, স্টপ লস সেট করুন ডোনচিয়ান উপরের ব্যান্ডে + ৫ পয়েন্ট, ঝুঁকি/প্রতিদান অনুপাতের সময়ে লাভ নিন স্টপ লস দূরত্ব।

এইভাবে, কৌশলটি ট্রেন্ড অনুসরণ এবং ব্রেকআউট ট্রেডিংকে একত্রিত করে, প্রধান ট্রেন্ডের সাথে ট্রেড করার জন্য। এদিকে, স্টপ লস এবং লাভ নিন প্রতিটি ব্যবসায়ের ঝুঁকি / পুরষ্কার নিয়ন্ত্রণ করে।

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

  1. প্রধান প্রবণতা অনুসরণ করুন, প্রবণতার বিরুদ্ধে ট্রেডিং এড়িয়ে চলুন।

  2. দীর্ঘমেয়াদী সূচক হিসেবে ডোনচিয়ান চ্যানেল, ইএমএ ফিল্টারের সাথে মিলিয়ে প্রবণতা কার্যকরভাবে চিহ্নিত করতে পারে।

  3. স্টপ লস এবং লভ্যাংশ গ্রহণ ট্রেড প্রতি ঝুঁকি নিয়ন্ত্রণ করে, সম্ভাব্য ক্ষতি সীমাবদ্ধ।

  4. ঝুঁকি/উপার্জনের অনুপাতকে অনুকূল করে তোলা লাভের ফ্যাক্টর বাড়িয়ে তুলতে পারে, অতিরিক্ত রিটার্ন অনুসরণ করে।

  5. নমনীয় ব্যাকটেস্ট প্যারামিটার, বিভিন্ন বাজারের জন্য প্যারামিটার অপ্টিমাইজ করতে পারেন।

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

  1. ডোনচিয়ান চ্যানেল এবং ইএমএ মাঝে মাঝে ভুল সংকেত দিতে পারে।

  2. ব্রেকআউট ট্রেডিং সহজেই ফাঁদে পড়তে পারে, ট্রেন্ড ব্যাকগ্রাউন্ড পরিষ্কারভাবে চিহ্নিত করতে হবে।

  3. ফিক্সড স্টপ লস এবং টেক প্রফিট বাজারের অস্থিরতার ভিত্তিতে সামঞ্জস্য করা যায় না।

  4. প্যারামিটারগুলির জন্য সীমিত অপ্টিমাইজেশান স্পেস, লাইভ পারফরম্যান্স গ্যারান্টিযুক্ত নয়।

  5. ব্ল্যাক সোয়ান ইভেন্টের জন্য ঝুঁকিপূর্ণ ট্রেডিং সিস্টেম, গুরুতর ক্ষতি হতে পারে।

অপ্টিমাইজেশান নির্দেশাবলী

  1. সিগন্যালের গুণমান উন্নত করার জন্য আরো ফিল্টার যুক্ত করার কথা বিবেচনা করুন।

  2. বাজারের অস্থিরতা এবং ATR এর উপর ভিত্তি করে অভিযোজিত স্টপ লস এবং লাভ নিন।

  3. মেশিন লার্নিং ব্যবহার করে পরীক্ষার জন্য এবং বাস্তব বাজারে ফিট করার জন্য প্যারামিটার অপ্টিমাইজ।

  4. ফাঁদ এড়ানোর শর্ত হিসাবে ভলিউম বা অস্থিরতার সাথে এন্ট্রি লজিককে অনুকূল করুন।

  5. ট্রেন অনুসরণকারী সিস্টেম বা মেশিন লার্নিং এর সাথে মিলিয়ে স্থিতিশীলতার জন্য হাইব্রিড মডেল তৈরি করুন।

সিদ্ধান্ত

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


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

//@version=4
// Welcome to my second script on Tradingview with Pinescript
// First of, I'm sorry for the amount of comments on this script, this script was a challenge for me, fun one for sure, but I wanted to thoroughly go through every step before making the script public
// Glad I did so because I fixed some weird things and I ended up forgetting to add the EMA into the equation so our entry signals were a mess
// This one was a lot tougher to complete compared to my MACD crossover trend strategy but I learned a ton from it, which is always good and fun
// Also I'll explain the strategy and how I got there through some creative coding(I'm saying creative because I had to figure this stuff out by myself as I couldn't find any reference codes)
// First things first. This is a Donchian Channel Breakout strategy which follows the following rules
// If the price hits the upperband of the Donchian Channel + price is above EMA and the price previously hit the lowerband of the Donchian Channel it's a buy signal
// If the price hits the lowerband of the Donchian Channel + price is below EMA and the price prevbiously hit the upper band of the Donchian Channel it's a sell signal
// Stop losses are set at the lower or upper band with a 0.5% deviation because we are acting as if those two bands are the resistance in this case
// Last but not least(yes, this gave BY FAR the most trouble to code), the profit target is set with a 1.5 risk to reward ratio
// If you have any suggestions to make my code more efficient, I'll be happy to hear so from you
// So without further ado, let's walk through the code

// The first line is basically standard because it makes backtesting so much more easy, commission value is based on Binance futures fees when you're using BNB to pay those fees in the futures market
// strategy(title="Donchian Channels", shorttitle="DC", overlay=true, default_qty_type = strategy.cash, default_qty_value = 150, initial_capital = 1000, currency = currency.USD, commission_type = "percent", commission_value = 0.036)
// The built-in Donchian Channels + an added EMA input which I grouped with the historical bars from the Donchian Channels
length          = input(20, minval=1, group = "Indicators")
lower           = lowest(length)
upper           = highest(length)
basis           = avg(upper, lower)
emaInput        = input(title = "EMA Input", type = input.integer, defval = 200, minval = 10, maxval = 400, step = 1, group = "Indicators")
// I've made three new inputs, for risk/reward ratio and for the standard pullback deviation. My advise is to not use the pullback inputs as I'm not 100% sure if they work as intended or not
riskreward      = input(title = "Risk/Reward Ratio", type = input.float, defval = 1.50, minval = 0.01, maxval = 100, step = 0.01, group = "Risk/Reward")
pullbackLong    = input(title = "Distance from Long pullback %", type = input.float, defval = 0.995, minval = 0.001, maxval = 2, step = 0.001, group = "Risk/Reward")
pullbackShort   = input(title = "Distance from Short pullback %", type = input.float, defval = 1.005, minval = 0.001, maxval = 2, step = 0.001, group = "Risk/Reward")

// Input backtest range, you can adjust these in the input options, just standard stuff
fromMonth       = input(defval = 1,    title = "From Month",      type = input.integer, minval = 1, maxval = 12, group = "Backtest Date Range")
fromDay         = input(defval = 1,    title = "From Day",        type = input.integer, minval = 1, maxval = 31, group = "Backtest Date Range")
fromYear        = input(defval = 2000, title = "From Year",       type = input.integer, minval = 1970,           group = "Backtest Date Range")
thruMonth       = input(defval = 1,    title = "Thru Month",      type = input.integer, minval = 1, maxval = 12, group = "Backtest Date Range")
thruDay         = input(defval = 1,    title = "Thru Day",        type = input.integer, minval = 1, maxval = 31, group = "Backtest Date Range")
thruYear        = input(defval = 2099, title = "Thru Year",       type = input.integer, minval = 1970,           group = "Backtest Date Range")
// Date variable also standard stuff
inDataRange     = (time >= timestamp(syminfo.timezone, fromYear, fromMonth, fromDay, 0, 0)) and (time < timestamp(syminfo.timezone, thruYear, thruMonth, thruDay, 0, 0))

// I had to makes these variables because the system has to remember whether the previous 'breakout' was a high or a low
// Also, because I based my stoploss on the upper/lower band of the indicator I had to find a way to change this value just once without losing the value, that was added, on the next bar
var previousishigh = false
var previousislow = false
var longprofit = 0.0
var shortprofit = 0.0
var stoplossLong = 0.0
var stoplossShort = 0.0
// These are used as our entry variables
emaCheck = ema(close, emaInput)
longcond = high >= upper and close > emaCheck
shortcond = low <= lower and close < emaCheck

// With these two if statements I'm changing the boolean variable above to true, we need this to decide out entry position
if high >= upper
    previousishigh := true
if low <= lower
    previousislow := true

// Made a last minute change on this part. To clean up our entry signals we don't want our breakouts, while IN a position, to change. This way we do not instantly open a new position, almost always in the opposite direction, upon exiting one
if strategy.position_size > 0 or strategy.position_size < 0 
    previousishigh := false
    previousislow := false

// Strategy inputs
// Long - previous 'breakout' has to be a low, the current price has to be a new high and above the EMA, we're not allowed to be in a position and ofcourse it has to be within our given data for backtesting purposes
if previousislow == true and longcond and strategy.position_size == 0 and inDataRange
    strategy.entry("Long Entry", strategy.long, comment = "Entry Long")
    stoplossLong := lower * pullbackLong
    longprofit := ((((1 - stoplossLong / close) * riskreward) + 1) * close)
    strategy.exit("Long Exit", "Long Entry", limit = longprofit, stop = stoplossLong, comment = "Long Exit")

// Short - Previous 'breakout' has to be a high, current price has to be a new low and lowe than the 200EMA, we're not allowed to trade when we're in a position and it has to be within our given data for backtesting purposes
if previousishigh == true and shortcond and strategy.position_size == 0 and inDataRange
    strategy.entry("Short Entry", strategy.short, comment = "Entry Short")
    stoplossShort := upper * pullbackShort
    shortprofit := (close - ((((1 - close / stoplossShort) * riskreward) * close)))
    strategy.exit("Short Exit", "Short Entry", limit = shortprofit, stop = stoplossShort, comment = "Short Exit")
    
// This plots the Donchian Channels on the chart which is just using the built-in Donchian Channels
plot(basis, "Basis", color=color.blue)
u = plot(upper, "Upper", color=color.green)
l = plot(lower, "Lower", color=color.red)
fill(u, l, color=#0094FF, transp=95, title="Background")

// These plots are to show if the variables are working as intended, it's a mess I know but I didn't have any better ideas, they work well enough for me
// plot(previousislow ? close * 0.95 : na, color=color.red, linewidth=2, style=plot.style_linebr)
// plot(previousishigh ? close * 1.05 : na, color=color.green, style=plot.style_linebr)
// plot(longprofit, color=color.purple)
// plot(shortprofit, color=color.silver)
// plot(stoplossLong)
// plot(stoplossShort)
// plot(strategy.position_size)

আরো