Bollinger Bands ATR ট্রেইলিং স্টপ কৌশল

লেখক:চাওঝাং, তারিখঃ 2024-01-03 11:20:06
ট্যাগঃ

img

সারসংক্ষেপ

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

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

ধাপ ১, মাঝারি ব্যান্ড, উপরের ব্যান্ড এবং নিম্ন ব্যান্ড গণনা করুন। মধ্যবর্তী ব্যান্ডটি দামের সহজ চলমান গড় (এসএমএ) এবং উপরের এবং নিম্ন ব্যান্ডগুলি দামের মান বিচ্যুতির গুণক। যখন দাম নিম্ন ব্যান্ড থেকে উপরে ভাঙবে, তখন দীর্ঘ যান। যখন দাম উপরের ব্যান্ড থেকে নীচে ভাঙবে, তখন সংক্ষিপ্ত যান।

ধাপ 2, ATR সূচক গণনা করুন। ATR সূচক মূল্যের গড় অস্থিরতা প্রতিফলিত করে। ATR মান অনুযায়ী, লং পজিশন এবং শর্ট পজিশনের জন্য স্টপ লস সেট করুন। একই সময়ে, ঝুঁকি / পুরষ্কার অনুপাত নিয়ন্ত্রণ করতে ATR মানের উপর ভিত্তি করে লাভের অবস্থান সেট করুন।

ধাপ ৩, বড় বড় সংবাদের কারণে মারাত্মক ওঠানামা এড়ানোর জন্য শুধুমাত্র নির্দিষ্ট সময়ের মধ্যে ট্রেড করার জন্য টাইম ফিল্টার ব্যবহার করুন।

ধাপ ৪, ট্রেইলিং স্টপ মেকানিজম। আরও লাভের জন্য সর্বশেষ এটিআর অবস্থানের উপর ভিত্তি করে স্টপ লস সামঞ্জস্য করা চালিয়ে যান।

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

  1. একক চলমান গড়ের তুলনায় বোলিংজার ব্যান্ডগুলি মূল্য ভারসাম্যকে আরও কার্যকরভাবে প্রতিফলিত করে;

  2. ATR স্টপ লস নিয়ন্ত্রণ করে প্রতিটি ট্রেডের ঝুঁকি/উপার্জনের অনুপাত;

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

  4. প্রচুর কৌশল পরামিতি উচ্চ কাস্টমাইজযোগ্যতা সক্ষম।

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

  1. বাজারের একত্রীকরণের সময় একাধিক ছোট ক্ষতি হতে পারে;

  2. বোলিংজার ব্যান্ড ক্রসওভারের সাথে ব্যর্থ ব্রেকআউট বিপরীতমুখী;

  3. রাতারাতি সেশন এবং প্রধান সংবাদ ইভেন্টের সাথে যুক্ত উচ্চ ঝুঁকি।

প্রতিরোধ ব্যবস্থাঃ

  1. ঝুঁকি ব্যবস্থাপনার নীতিগুলি কঠোরভাবে অনুসরণ করুন, ট্রেড প্রতি ক্ষতি নিয়ন্ত্রণ করুন;
  2. জয়ের হার বাড়ানোর জন্য পরামিতিগুলি অপ্টিমাইজ করুন;
  3. উচ্চ ঝুঁকিপূর্ণ সময় এড়াতে সময় ফিল্টার প্রয়োগ করুন।

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

  1. বিভিন্ন প্যারামিটার সমন্বয় পরীক্ষা করুন;
  2. OBV এর মত টাইমিং ইন্ডিকেটর যোগ করুন;
  3. মেশিন লার্নিং মডেল অন্তর্ভুক্ত করুন।

সিদ্ধান্ত

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


/*backtest
start: 2023-12-26 00:00:00
end: 2024-01-02 00:00:00
period: 1m
basePeriod: 1m
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/
// © sadeq_haddadi

//@version=5

strategy('Bollinger Bands + ATR / trail- V2', overlay=true ) // Interactive Brokers rate)



//date and time
startDate   = input(title="Start Date", defval=timestamp("01 Aug 2023 00:00 +0000"), tooltip="Date & time to begin analysis",group = 'Time Filter')
endDate     = input(title="End Date", defval=timestamp("1 Jan 2099 00:00 +0000"), tooltip="Date & time to stop analysis")
timeSession = input(title="Time Session To Analyze", defval="0300-1700", tooltip="Time session to analyze")
inSession(sess) => true

// indicators 

length = input.int(20, minval=1,group = 'Bollinger Band')
maType = input.string("SMA", "Basis MA Type", options = ["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"])
src = input(close, title="Source")
mult1 = input.float(2.0, minval=0.001, maxval=50, title="StdDev1")
mult2 = input.float(3.0, minval=0.001, maxval=50, title="StdDev2")

ma(source, length, _type) =>
    switch _type
        "SMA" => ta.sma(source, length)
        "EMA" => ta.ema(source, length)
        "SMMA (RMA)" => ta.rma(source, length)
        "WMA" => ta.wma(source, length)
        "VWMA" => ta.vwma(source, length)

basis = ma(src, length, maType)
dev1 = mult1 * ta.stdev(src, length)
dev2 = mult2 * ta.stdev(src, length)
upper1 = basis + dev1
lower1 = basis - dev1
upper2 = basis + dev2
lower2 = basis - dev2
offset = input.int(0, "Offset", minval = -500, maxval = 500)
plot(basis, "Basis", color=#2962FF, offset = offset,linewidth=2)
p1 = plot(upper1, "Upper", color=color.new(color.white,50), offset = offset,linewidth=2)
p2 = plot(lower1, "Lower", color=color.new(color.white,50), offset = offset,linewidth=2)
p3 = plot(upper2, "Upper", color=color.new(color.white,80), offset = offset,linewidth=1)
p4 = plot(lower2, "Lower", color=color.new(color.white,80), offset = offset,linewidth=1)

fill(p1, p2, title = "Background", color=color.rgb(33, 150, 243, 95))
fill(p3, p4, title = "Background", color=color.rgb(33, 150, 243, 95))

show_crosses = input(false, "Show Cross the Bands?")

plotshape(show_crosses and ta.crossover(close, upper2)  ? src : na, "S", style = shape.triangledown, location =location.abovebar, color = color.yellow, size = size.tiny)
plotshape(show_crosses and ta.crossunder(low, lower2) ? src : na ,"L", style = shape.triangleup, location =  location.belowbar, color = color.purple, size = size.tiny)

second_entry = input(true, "Show second deviation entry point?")

//atr

length_ATR = input.int(title="Length", defval=5, minval=1,group = 'ATR')
smoothing = input.string(title="Smoothing", defval="RMA", options=["RMA", "SMA", "EMA", "WMA"])
m = input.float(1, "Multiplier")
src1 = input(high)
src2 = input(low)
pline = input.bool(title = 'show ATR lines ?', defval=false)



ma_function(source, length_ATR) =>
	if smoothing == "RMA"
		ta.rma(source, length_ATR)
	else
		if smoothing == "SMA"
			ta.sma(source, length_ATR)
		else
			if smoothing == "EMA"
				ta.ema(source, length_ATR)
			else
				ta.wma(source, length_ATR)
				
a = ma_function(ta.tr(true), length_ATR) * m
x = ma_function(ta.tr(true), length_ATR) * m + src1
x2 = src2 - ma_function(ta.tr(true), length_ATR) * m

PP1 = plot(pline ? x :na , title = "ATR Short Stop Loss", color= color.new(color.red,20) )
PP2 = plot(pline ? x2:na , title = "ATR Long Stop Loss",  color=color.new(color.green,20) )

Tp_to_Sl = input.float(1.5, "TP/SL")
candle_size =  input.float(10, "candle/pip")
distance_source =  input.float(1.5, "distance to midline/pip")
//strategy

buyCondition = low[2] < lower1 and  ta.crossover(close[1], lower1)  and strategy.position_size == 0 and (close[1] - open[1]) < candle_size * 0.0001 and close > open and ( basis - close) > distance_source * 0.0001

sellCondition = high[2] > upper1 and ta.crossunder(close[1], upper1)  and strategy.position_size == 0 and (open[1] - close[1]) < candle_size * 0.0001 and close < open  and (close - basis) > distance_source * 0.0001
//
buyCondition2 = low[2] < lower2 and  ta.crossover(close[1], lower2)  and (close[1] - open[1]) < candle_size * 0.0001 and close > open and ( basis - close) > distance_source * 0.0001
sellCondition2 = high[2] > upper2 and ta.crossunder(close[1], upper2)   and (open[1] - close[1]) < candle_size * 0.0001 and close < open  and (close - basis) > distance_source * 0.0001

plotshape(second_entry and  sellCondition2 ? src : na, "S", style = shape.triangledown, location =location.abovebar, color = color.rgb(241, 153, 177), size = size.tiny)
plotshape(second_entry and buyCondition2 ? src : na ,"L", style = shape.triangleup, location =  location.belowbar, color = color.rgb(177, 230, 168), size = size.tiny)
//
since_buy  =ta.barssince(buyCondition)
since_sell =ta.barssince(sellCondition)
entry_price = ta.valuewhen(buyCondition or sellCondition, src, 0)

sl_long = ta.valuewhen(buyCondition, x2[1], 0)
sl_short = ta.valuewhen(sellCondition, x[1], 0)
buyprofit = entry_price + (Tp_to_Sl*( entry_price - sl_long))
sellprofit= entry_price + (Tp_to_Sl*( entry_price - sl_short))

//alert_massage = "new strategy position is {{strategy.position_size}}"
//prof = ta.crossover(high,upper1)
//buyexit=ta.valuewhen(prof,upper1,0)

if buyCondition and inSession(timeSession)

    strategy.entry( id = "long", direction = strategy.long , alert_message='Open Long Position' )

if sellCondition and inSession(timeSession)
   
    strategy.entry(id= "short", direction = strategy.short, alert_message='Open Short Position')

//trail-stop loss
use_trailing = input.bool(title = 'use trailing stop loss?', defval=true)
pricestop_long=0.00
pricestop_short=100000.00
if (strategy.position_size > 0)
   
    if use_trailing == false
        pricestop_long := sl_long
    else
        pricestop_long := math.max (x2, pricestop_long[1]) //trail - long

if (strategy.position_size < 0)
   
    if use_trailing == false
        pricestop_short := sl_short
    else
        pricestop_short := math.min (x, pricestop_short[1])  // trail - short 

if strategy.position_size > 0 
   
    strategy.exit(id = 'close', limit =  buyprofit , stop = pricestop_long  )

if strategy.position_size < 0 

    strategy.exit(id = 'close', limit = sellprofit  , stop = pricestop_short  )

alertcondition(buyCondition or sellCondition, 'Enter_position')



আরো