आकार ब्लॉक रणनीति

लेखक:चाओझांग, दिनांक: 2023-11-06 09:20:34
टैगः

img

अवलोकन

साइजब्लॉक रणनीति विकर्ण पंक्तियों में प्रदर्शित मूल्य परिवर्तनों के प्रतिशत या टिक विचलन पर आधारित एक ट्रेडिंग रणनीति है। यह चार्ट पर स्थानीय रुझानों और उलट बिंदुओं को स्पष्ट रूप से दिखा सकता है। यह मूल्य दिशा को ट्रैक करने के लिए एक बहुत ही उपयोगी उपकरण है।

सिद्धांत

गणना मूल्य आंदोलन के प्रतिशत या टिक विचलन (पैरामीटर Deviation में इंगित) पर आधारित है, जो चार्ट पर पंक्तियों के रूप में प्रदर्शित होता है।

पंक्ति में आधार मध्य रेखा, ऊपरी और निचली सीमाएं शामिल हैंः

  • आधार मध्य रेखा पिछली पंक्ति की ऊपरी या निचली सीमा के बराबर होती है (यदि कीमत एक समय अंतराल में तेजी से बदलती है, तो वर्तमान पंक्ति की आधार मध्य रेखा पिछली पंक्ति की ऊपरी सीमा से अधिक या पिछली पंक्ति की निचली सीमा से कम होती है। मूल्य आंदोलन की दिशा के आधार पर विचलन की समान संख्या में) । गणना की शुरुआत में, आधार मध्य रेखा पहली पंक्ति के प्रारंभिक मूल्य के बराबर होती है।

  • Quantity पैरामीटर मूल्य आंदोलन की दिशा के आधार पर ऊपरी या निचली सीमाओं के लिए विचलन निर्धारित करता है, और U-turn पैरामीटर मूल्य आंदोलन की दिशा बदलने के लिए विचलन निर्धारित करता है।

नई पंक्ति के निर्माण का नियमः

  • यदि बंद ≥ ऊपरी सीमा और बंद > खुला, ऊपरी सीमा धीरे-धीरे ऊपर चलेगी, और निचली सीमा भी ऊपर चलेगी लेकिन कम।

  • यदि निचली सीमा निचली सीमा तक है और बंद < खुला है, तो निचली सीमा धीरे-धीरे नीचे की ओर बढ़ेगी, और ऊपरी सीमा भी नीचे की ओर बढ़ेगी लेकिन कम।

कुछ विचलनों को समायोजित करके, आप चार्ट पर स्थानीय प्रवृत्ति और उलट बिंदुओं को स्पष्ट रूप से देख सकते हैं। यह मूल्य दिशा को ट्रैक करने के लिए एक बहुत ही उपयोगी उपकरण है।

लाभ

  • मूल्य परिवर्तन के रुझानों को चित्रित करें और समर्थन और प्रतिरोध को स्पष्ट रूप से पहचानें।

  • विकर्ण रेखाएं स्पष्ट रूप से ब्रेकआउट की ताकत और पॉलबैक की सीमा दिखाती हैं।

  • विकर्ण रेखाओं की ढलान को विभिन्न शक्ति के रुझानों की पहचान करने के लिए आवश्यकतानुसार समायोजित किया जा सकता है।

  • ब्रेकआउट के लिए अपेक्षाकृत बड़ा समर्थन और प्रतिरोध पा सकते हैं।

  • मूल्य गति में परिवर्तन को देखना और तदनुसार स्थिति आकार को समायोजित करना आसान है।

जोखिम

  • विकर्ण रेखाएं भाव की आगे की चाल को पूरी तरह सटीक रूप से भविष्यवाणी नहीं कर सकती हैं।

  • रुझानों में विचलन की निगरानी करने की आवश्यकता है जहां विकर्ण रेखाएं वास्तविक कीमतों से विचलित हो सकती हैं।

  • एक अलग रणनीति के रूप में इस्तेमाल नहीं किया जा सकता है, मुख्य प्रवृत्ति निर्धारित करने के लिए अन्य संकेतकों को शामिल करने की आवश्यकता है।

  • अनुचित पैरामीटर समायोजन से अत्यधिक बार-बार व्यापार हो सकता है।

  • यांत्रिक रूप से अंधाधुंध रूप से रुझानों का पीछा करने के बजाय पलकें हटाने के दौरान संभावित उलटफेरों से सावधान रहने की आवश्यकता है।

स्थिति आकार को मामूली रूप से कम कर सकता है और प्रमुख रुझानों के भीतर सहायक निर्णय के रूप में अन्य संकेतकों का उल्लेख कर सकता है।

अनुकूलन

  • विभिन्न रुझान चरणों में स्थिति को गतिशील रूप से समायोजित करने के लिए स्थिति प्रबंधन मॉड्यूल जोड़ सकते हैं।

  • अस्थिरता में वृद्धि होने पर पदों को कम करने के लिए अस्थिरता संकेतकों को शामिल कर सकता है।

  • एकल हानि को नियंत्रित करने के लिए ड्रॉडाउन प्रतिशत के आधार पर स्टॉप लॉस सेट कर सकता है।

  • मूल्य विचलन होने पर ट्रेडिंग को रोकने के लिए फ़िल्टर जोड़ सकते हैं।

  • विभिन्न शक्ति के रुझान परिवर्तनों की पहचान करने के लिए विकर्ण ढलानों को कई स्तरों में विभाजित कर सकता है।

गतिशील रूप से पदों को समायोजित करके, स्टॉप और फ़िल्टर सेट करके, अधिक स्थिर रूप से मूल्य रुझानों को ट्रैक कर सकते हैं।

सारांश

साइजब्लॉक रणनीति मूल्य प्रवृत्ति परिवर्तनों को सहज रूप से प्रदर्शित करने और समर्थन, प्रतिरोध और ब्रेकआउट स्तरों की स्पष्ट रूप से पहचान करने के लिए विकर्ण रेखाओं का उपयोग करती है। लेकिन निर्णय के लिए केवल विकर्ण रेखाओं पर भरोसा नहीं किया जा सकता है, अन्य संकेतकों से विश्लेषण को शामिल करने और जोखिमों का प्रबंधन करने की आवश्यकता है। यह व्यापारियों को बाजार की लय को बेहतर ढंग से समझने में मदद करने के लिए एक बहुत ही मूल्यवान सहायक उपकरण है। अनुकूलन रणनीति को अधिक मजबूत और कुशल बना सकता है।


/*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! ;>
// *********************

अधिक