সাইজব্লক কৌশল

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

img

সারসংক্ষেপ

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

নীতিমালা

গণনাটি মূল্য আন্দোলনের শতাংশ বা টিক বিচ্যুতির উপর ভিত্তি করে করা হয় (Deviation পরামিতিতে নির্দেশিত), যা চার্টে সারি আকারে প্রদর্শিত হয়।

এই সারিটি নিম্নলিখিতগুলির মধ্যম রেখা, উপরের এবং নীচের সীমানা নিয়ে গঠিতঃ

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

  • Quality পরামিতি মূল্য আন্দোলনের দিকের উপর নির্ভর করে উপরের বা নীচের সীমাগুলির জন্য বিচ্যুতি নির্ধারণ করে এবং U-turn পরামিতি মূল্য আন্দোলনের দিক পরিবর্তন করার জন্য বিচ্যুতি নির্ধারণ করে।

নতুন সারি তৈরির নিয়মঃ

  • যদি বন্ধ ≥ উপরের সীমা এবং বন্ধ > খোলা হয়, উপরের সীমা ধীরে ধীরে সরানো হবে, এবং নীচের সীমাও সরানো হবে কিন্তু কম।

  • যদি নিম্ন সীমা ≤ নিম্ন সীমা এবং বন্ধ < খোলা হয়, নিম্ন সীমা ধীরে ধীরে নেমে যাবে, এবং উপরের সীমাও নেমে যাবে কিন্তু কম।

নির্দিষ্ট বিচ্যুতিগুলি সামঞ্জস্য করে, আপনি চার্টে স্থানীয় প্রবণতা এবং বিপরীত পয়েন্টগুলি পরিষ্কারভাবে দেখতে পারেন। এটি মূল্যের দিকনির্দেশ অনুসরণ করার জন্য একটি খুব দরকারী সরঞ্জাম।

সুবিধা

  • মূল্য পরিবর্তনের প্রবণতা দৃশ্যমান করুন এবং সমর্থন এবং প্রতিরোধের স্পষ্টভাবে সনাক্ত করুন।

  • ডায়াগোনাল লাইন স্পষ্টভাবে ব্রেকআউট শক্তি এবং pullbacks পরিসীমা দেখায়।

  • বিভিন্ন শক্তির প্রবণতা চিহ্নিত করার জন্য ডায়াগোনাল লাইনগুলির ঢাল প্রয়োজন অনুযায়ী সামঞ্জস্য করা যেতে পারে।

  • এর জন্য তুলনামূলকভাবে বড় সমর্থন এবং প্রতিরোধ পাওয়া যায়।

  • মূল্যের গতিতে পরিবর্তন দেখতে এবং সেই অনুযায়ী পজিশনের আকার সামঞ্জস্য করা সহজ।

ঝুঁকি

  • ডায়াগোনাল লাইনগুলি পরবর্তী মূল্যের গতিবিধি সম্পূর্ণরূপে সঠিকভাবে পূর্বাভাস দিতে পারে না।

  • প্রবণতা যেখানে তির্যক লাইন প্রকৃত দাম থেকে বিচ্যুত হতে পারে মধ্যে divergences জন্য নজর রাখা প্রয়োজন।

  • এটি একটি বিচ্ছিন্ন কৌশল হিসাবে ব্যবহার করা যাবে না, প্রধান প্রবণতা নির্ধারণের জন্য অন্যান্য সূচক অন্তর্ভুক্ত করা প্রয়োজন।

  • অনুপযুক্ত পরামিতি সমন্বয় অত্যধিক ঘন ঘন ট্রেডিং হতে পারে।

  • ধারাবাহিকভাবে অন্ধভাবে প্রবণতা অনুসরণ করার পরিবর্তে প্রত্যাহারের সময় সম্ভাব্য বিপরীতমুখী হতে সতর্ক থাকতে হবে।

মূল প্রবণতাগুলির মধ্যে সহায়ক বিচার হিসাবে অন্যান্য সূচকগুলিকে উল্লেখ করে অবস্থানের আকারকে মাঝারিভাবে হ্রাস করতে পারে।

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

  • পজিশন ম্যানেজমেন্ট মডিউল যোগ করতে পারেন বিভিন্ন ট্রেন্ড পর্যায়ে অবস্থানকে গতিশীলভাবে সামঞ্জস্য করতে।

  • ভোল্টেবিলিটি বাড়ার সময় পজিশন হ্রাস করার জন্য ভোল্টেবিলিটি সূচক অন্তর্ভুক্ত করতে পারে।

  • একক ক্ষতি নিয়ন্ত্রণের জন্য ড্রাউনডাউন শতাংশের উপর ভিত্তি করে স্টপ লস সেট করতে পারেন।

  • দামের বৈষম্যের সময় ট্রেডিং বন্ধ করার জন্য ফিল্টার যুক্ত করতে পারেন।

  • বিভিন্ন শক্তির প্রবণতা পরিবর্তন সনাক্ত করতে ডায়াগনাল ঢালগুলিকে একাধিক স্তরে বিভক্ত করতে পারে।

ডায়নামিকভাবে পজিশন সামঞ্জস্য করে, স্টপ এবং ফিল্টার সেট করে, দামের প্রবণতা আরও স্থিতিশীলভাবে ট্র্যাক করতে পারে।

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

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


/*backtest
start: 2023-10-06 00:00:00
end: 2023-11-05 00:00:00
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
// **********************************************************************************
// This code is invented and written by @StCogitans.
// The idea presented in this code and the rights to this code belong to @StCogitans.
// © https://www.tradingview.com/u/StCogitans
//
// Description.
// Sizeblock - a price change strategy in the form of diagonal rows.
// **********************************************************************************

// STRATEGY
string NAME        = 'Sizeblock'
string ACRONYM     = 'SB'
bool OVERLAY       = true
int PYRAMIDING     = 0
string QTY_TYPE    = strategy.percent_of_equity
float QTY_VALUE    = 100
float CAPITAL      = 100
string COM_TYPE    = strategy.commission.percent
float COM_VALUE    = 0.1
bool ON_CLOSE      = false
bool BAR_MAGNIFIER = false
bool OHLC          = true
strategy(NAME, ACRONYM, OVERLAY, pyramiding=PYRAMIDING, default_qty_type=QTY_TYPE, default_qty_value=QTY_VALUE, initial_capital=CAPITAL, commission_type=COM_TYPE, commission_value=COM_VALUE, process_orders_on_close=ON_CLOSE, use_bar_magnifier=BAR_MAGNIFIER, fill_orders_on_standard_ohlc=OHLC)

// ARGUMENTS
// Datetime
DTstart  = input(timestamp("01 Jan 2000 00:00 +0000"), 'Start time', group='Datetime')
DTfinish = input(timestamp("01 Jan 2080 23:59 +0000"), 'Finish time', group='Datetime')
DTperiod = true

// Main
dev_source = input.string('Close', title='Source', options=["Close", "HighLow"], tooltip='Price data for settlement.', group='Main')
dev_type   = input.string('Percentage', title='Deviation', options=['Percentage', 'Ticks'], tooltip='The type of deviation to calculate.', group='Main')
dev_value  = input.float(1, title='Quantity', minval=0.001, step=0.01, tooltip='Quantity to be calculated.', group='Main')
dev_back   = input.float(2, title='U-turn', minval=0.001, step=0.01, tooltip='Quantity for reversal.', group='Main')
mode       = input.string('Limit', title='Positions', options=['Limit', 'Market'], tooltip='Limit or market orders.', group='Main')
direct     = input.string('All', title='Direction', options=['All', 'Buy', 'Sell'], tooltip='The type of positions to be opened.', group='Main')
swapping   = input.bool(false, title='Swapping', tooltip='Swap points to open a new position.', group='Main')

// CALCULATION SYSTEM
Assembling(s, t, v, vb) =>

    float a = open
    float b = close
    float c = s == "HighLow" ? math.round_to_mintick(high) : math.round_to_mintick(b)
    float d = s == "HighLow" ? math.round_to_mintick(low) : math.round_to_mintick(b)

    float x = math.round_to_mintick(a)
    x := nz(x[1], x)

    float _v = t == "Ticks" ? syminfo.mintick * v : v
    float _vb = t == "Ticks" ? syminfo.mintick * vb : vb

    float h = t == "Ticks" ? math.round_to_mintick(x + _v) : math.round_to_mintick(x * (1 + _v / 100))
    float l = t == "Ticks" ? math.round_to_mintick(x - _v) : math.round_to_mintick(x * (1 - _v / 100))
    h := nz(h[1], h)
    l := nz(l[1], l)

    if t == "Ticks"
    
        if c >= h and b > a
            while c >= h
            
                x := h
                h := math.round_to_mintick(h + _v)
                l := math.round_to_mintick(x - _vb)
        
        if d <= l and b < a
            while d <= l
            
                x := l
                l := math.round_to_mintick(l - _v)
                h := math.round_to_mintick(x + _vb)

    else if t == "Percentage"
    
        if c >= h and b > a
            while c >= h
        
                x := h
                h := math.round_to_mintick(h * (1 + _v / 100))
                l := math.round_to_mintick(x * (1 - _vb / 100))

        if d <= l and b < a
            while d <= l
        
                x := l
                l := math.round_to_mintick(l * (1 - _v / 100))
                h := math.round_to_mintick(x * (1 + _vb / 100))

    [x, h, l]

[lx, lh, ll] = Assembling(dev_source, dev_type, dev_value, dev_back)

// PLOT
// Lines
plot_up   = plot(lh, color=color.new(color.green, 50), style=plot.style_line, linewidth=1)
plot_main = plot(lx, color=color.new(color.silver, 50), style=plot.style_line, linewidth=1)
plot_down = plot(ll, color=color.new(color.red, 50), style=plot.style_line, linewidth=1)

// Areas
fill(plot_up, plot_main, lh, lx, color.new(color.teal, 80), color.new(color.teal, 80))
fill(plot_main, plot_down, lx, ll, color.new(color.maroon, 80), color.new(color.maroon, 80))

// TRADING
// Alert variables
int Action = -1
int PosType = -1
int OrderType = -1
float Price = -1.0

// Direction variables
bool ifBuy = direct == "All" or direct == "Buy" ? true : false
bool ifSell = direct == "All" or direct == "Sell" ? true : false

// Market entries
if (strategy.closedtrades + strategy.opentrades == 0 or mode == "Market") and DTperiod
    if ((swapping and lx < nz(lx[1], lx)) or (not swapping and lx > nz(lx[1], lx))) and ifBuy
        Action := 1
        PosType := 1
        OrderType := 1
        Price := math.round_to_mintick(close)
        strategy.entry('Long', strategy.long)
    if ((swapping and lx > nz(lx[1], lx)) or (not swapping and lx < nz(lx[1], lx))) and ifSell
        Action := 2
        PosType := 2
        OrderType := 1
        Price := math.round_to_mintick(close)
        strategy.entry('Short', strategy.short)

// Closing positions by market
if DTperiod and mode == "Market"
    if direct == "Buy" and strategy.position_size > 0
        if swapping and lx > nz(lx[1], lx)
            Action := 2
            PosType := 3
            OrderType := 1
            Price := math.round_to_mintick(close)
            strategy.close('Long', comment='Close')
        if not swapping and lx < nz(lx[1], lx)
            Action := 2
            PosType := 3
            OrderType := 1
            Price := math.round_to_mintick(close)
            strategy.close('Long', comment='Close')
    if direct == "Sell" and strategy.position_size < 0
        if swapping and lx < nz(lx[1], lx)
            Action := 1
            PosType := 3
            OrderType := 1
            Price := math.round_to_mintick(close)
            strategy.close('Short', comment='Close')
        if not swapping and lx > nz(lx[1], lx)
            Action := 1
            PosType := 3
            OrderType := 1
            Price := math.round_to_mintick(close)
            strategy.close('Short', comment='Close')

// Limit entries and exits
if swapping and DTperiod and mode == "Limit"
    if strategy.position_size < 0
        Action := 1
        PosType := 1
        OrderType := 2
        Price := ll
        if ifBuy
            strategy.entry('Long', strategy.long, limit=ll)
        else
            PosType := 3
            strategy.exit('Exit', limit=ll)
    if strategy.position_size > 0
        Action := 2
        PosType := 2
        OrderType := 2
        Price := lh
        if ifSell
            strategy.entry('Short', strategy.short, limit=lh)
        else
            PosType := 3
            strategy.exit('Exit', limit=lh)
    if strategy.closedtrades + strategy.opentrades > 0 and strategy.position_size == 0
        if ifBuy
            Action := 1
            PosType := 1
            OrderType := 2
            Price := ll
            strategy.entry('Long', strategy.long, limit=ll)
        if ifSell
            Action := 2
            PosType := 2
            OrderType := 2
            Price := lh
            strategy.entry('Short', strategy.short, limit=lh)
if not swapping and DTperiod and mode == "Limit"
    if strategy.position_size < 0
        Action := 1
        PosType := 1
        OrderType := 2
        Price := lh
        if ifBuy
            strategy.entry('Long', strategy.long, stop=lh)
        else
            PosType := 3
            strategy.exit('Exit', stop=lh)
    if strategy.position_size > 0
        Action := 2
        PosType := 2
        OrderType := 2
        Price := ll
        if ifSell
            strategy.entry('Short', strategy.short, stop=ll)
        else
            PosType := 3
            strategy.exit('Exit', stop=ll)
    if strategy.closedtrades + strategy.opentrades > 0 and strategy.position_size == 0
        if ifBuy
            Action := 1
            PosType := 1
            OrderType := 2
            Price := lh
            strategy.entry('Long', strategy.long, stop=lh)
        if ifSell
            Action := 2
            PosType := 2
            OrderType := 2
            Price := ll
            strategy.entry('Short', strategy.short, stop=ll)

// Everything is closed and canceled
if not DTperiod
    strategy.cancel_all()
    strategy.close_all(comment='Close')

// Alerts
// Convert to string variables
string Action_Txt = Action == 1 ? "Buy" : Action == 2 ? "Sell" : na
string PosType_Txt = PosType == 1 ? "Long" : PosType == 2 ? "Short" : PosType == 3 ? "Flat" : na
string OrderType_Txt = OrderType == 1 ? "Market" : OrderType == 2 ? "Limit" : na
string Price_Txt = Price > 0 ? str.tostring(Price) : na

// Output
if not (Action == nz(Action[1], Action) and Price == nz(Price[1], Price) and OrderType == nz(OrderType[1], OrderType)) and DTperiod
    alert('{"pair": "' + syminfo.ticker + '", "direction": "' + Action_Txt + '", "entertype": "' + OrderType_Txt + '", "position": "' + PosType_Txt + '", "price": "' + Price_Txt + '"}')

// *********************
// Good job, Soldier! ;>
// *********************

আরো