S&P500 হাইব্রিড সিজনাল ট্রেডিং কৌশল

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

img

সারসংক্ষেপ

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

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

প্রধান ট্রেডিং সিগন্যাল এবং নিয়মগুলি হলঃ

  1. প্রতিবছর অক্টোবরের প্রথম ট্রেডিং দিনে ওপেনে লম্বা হয়ে যান।
  2. যদি ভিআইএক্স ৬০% এর বেশি হয় বা ১৫ দিনের এটিআর ৯০% এর বেশি হয়, তাহলে মৌসুমী লেনদেন বন্ধ করুন যতক্ষণ না মাস বা বছরের শেষের দিকে অস্থিরতা কমে যায়।
  3. প্রতিবছর আগস্টের প্রথম ট্রেডিং দিনে ওপেন এ লং/শর্ট এক্সাইট করুন।
  4. যদি VIX 120% অতিক্রম করে বা যদি VFI -20 এর নীচে অতিক্রম করে তবে তার 10-দিনের MA নিচে নির্দেশ করে।
  5. অপশনাল শর্ট সেলিং সক্ষম।

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

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

S&P500 হাইব্রিড সিজনাল ট্রেডিং স্ট্র্যাটেজি নিম্নলিখিত প্রধান সুবিধাগুলি রয়েছেঃ

  1. এসএন্ডপি৫০০ সূচকের সমগ্র বছরের মধ্যে পরীক্ষামূলকভাবে পর্যবেক্ষণ করা অসামঞ্জস্যপূর্ণ মাসিক কর্মক্ষমতার ভিত্তিতে লিভারেজ প্রতিষ্ঠিত, স্থিতিশীল মৌসুমী প্যাটার্ন।
  2. ভিআইএক্স, এটিআর এবং ভিএফআই এর মতো একাধিক ফিল্টার শর্ত অন্তর্ভুক্ত করে কার্যকরভাবে গোলমাল ফিল্টার করে এবং আরও নির্ভরযোগ্য ট্রেডিং সংকেত তৈরি করে।
  3. দীর্ঘ/সংক্ষিপ্ত এবং মৌসুমী প্রবেশ এবং প্রস্থান জন্য কাস্টম সময়ের জন্য কনফিগারযোগ্য ট্রেডিং নিয়ম যা পরীক্ষা এবং অপ্টিমাইজেশান সহজতর করে।
  4. বিপণনের প্রভাবকে এড়াতে ভিআইএক্স এবং এটিআর প্রান্তিকের মতো অস্থিরতার পরিমাপের মাধ্যমে ঝুঁকি এড়ানোর অন্তর্নির্মিত প্রক্রিয়া।
  5. বাজারে অংশগ্রহণের সম্ভাব্য পরিবর্তনের প্রতিফলনকারী ভলিউম ফ্লো সূচক থেকে অতিরিক্ত সংকেত ইনপুট।

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

কিছু সম্ভাব্য ঝুঁকিগুলির মধ্যে রয়েছেঃ

  1. ঐতিহাসিক প্যাটার্নের অবৈধ ঝুঁকি। বাজারগুলি স্টোকাস্টিকভাবে বিকশিত হয় তাই ঐতিহাসিক প্রবণতা সবসময় স্থায়ী হতে পারে না।
  2. প্রযুক্তিগত সূচক থেকে ভুল সংকেতের ঝুঁকি। VIX, ATR এবং VFI এছাড়াও মিথ্যা সংকেত তৈরি করতে পারে।
  3. অপ্টিমাম প্যারামিটার ঝুঁকি। বর্তমান মানগুলি বিশ্বব্যাপী অপ্টিমাম নাও হতে পারে বলে আরও প্যারামিটার পরীক্ষা এবং সমন্বয় করা সম্ভব।
  4. অতিরিক্ত শর্ট রিস্ক যেমন সীমাহীন ক্ষতি।

আরও কঠোর ঝুঁকি নিয়ন্ত্রণ, সূচকগুলির সংমিশ্রণ, পরামিতি সামঞ্জস্য, মেশিন লার্নিং ইত্যাদির মাধ্যমে ঝুঁকিগুলি হ্রাস করা যেতে পারে।

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

সম্ভাব্য অপ্টিমাইজেশান সুযোগঃ

  1. আরও প্রশিক্ষণ তথ্যের জন্য দীর্ঘতর ব্যাকটেস্ট সময়কাল।
  2. ট্রেড প্রতি ক্ষতি নিয়ন্ত্রণের জন্য স্টপ লস ব্যবস্থা চালু করা।
  3. VIX, ATR এবং VFI এর মতো সূক্ষ্ম সূচকগুলির সূক্ষ্ম সূচকগুলি সর্বোত্তম সমন্বয় খুঁজে পেতে।
  4. অভিযোজিত অপ্টিমাইজেশান সক্ষম করতে মেশিন লার্নিং মডেল স্থাপন করুন।
  5. সংশ্লিষ্টতা ছাড়াই সিস্টেমিক বাজার ঝুঁকি কমাতে কৌশলগুলি একত্রিত করা।

সিদ্ধান্ত

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


/*backtest
start: 2023-12-01 00:00:00
end: 2023-12-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//  TASC Issue: April 2022 - Vol. 40, Issue 4
//     Article: Sell In May? Stock Market Seasonality                    
//  Article By: Markos Katsanos
//    Language: TradingView's Pine Script v5
// Provided By: PineCoders, for tradingview.com

//@version=5
strategy(title             = "TASC 2022.04 S&P500 Hybrid Seasonal System", 
         shorttitle        = "HSS v2.0",
         overlay           = true, 
         default_qty_type  = strategy.percent_of_equity, 
         default_qty_value = 10, 
         initial_capital   = 100000,
         currency          = currency.USD,
         commission_type   = strategy.commission.percent,
         commission_value  = 0.01
         )

// Helper Functions:

// @function Returns the ratio to max/min of a sample period
// @param src float, data source.
// @param length int, period of the sample.
// @returns [float, float] tuple.
volatility (float src, int length) =>
    [(src / ta.highest(src, length)[1] - 1.0) * 100.0,
     (src / ta.lowest (src, length)[1] - 1.0) * 100.0]

// @function Volume Flow Indicator.
// @param Period int, period of the data sample.
// @param VCoef float, Volume Volatility Coefficient.
// @param Coef float, Cutoff Coefficient.
// @returns float.
// ref: https://mkatsanos.com/volume-flow-vfi-indicator/
vfi (int Period = 130, float VCoef = 2.5, float Coef = 0.2) =>
    lastHLC3 = nz(hlc3[1], hlc3)
	MF     = hlc3  - lastHLC3
    Vinter = ta.stdev(math.log(hlc3) - math.log(lastHLC3), 30)
    Vave   = ta.sma(volume, Period)[1]
    Cutoff = Coef * close * Vinter
    VC     = math.min(volume, Vave * VCoef)
    VCP    = MF >  Cutoff ?  VC :
		     MF < -Cutoff ? -VC : 0.0
    VFI1 = nz(math.sum(VCP, Period) / Vave)
    VFI = ta.ema(VFI1, 3)


// inputs:
// optional strategy obserservation window parameters:
string ig_ow      = 'Observation Window:'
bool i_Sdate      = input(  title   = 'Start date:', 
                                 defval  = timestamp('2021-01-01'), 
                                 inline  = 'Sdate', 
                                 group   = ig_ow
                                 ) < time //
bool i_useSdate   = input.bool(  title   = '', 
                                 defval  = false, 
                                 group   = ig_ow, 
                                 inline  = 'Sdate', 
                                 tooltip = 'Optional start date to clamp strategy observation window.'
                                 ) //
bool i_Edate      = input(  title   = 'End date:', 
                                 defval  = timestamp('2022-01-01'), 
                                 inline  = 'Edate', 
                                 group   = ig_ow
                                 ) > time //
bool i_useEdate   = input.bool(  title   = '', 
                                 defval  = false, 
                                 group   = ig_ow, 
                                 inline  = 'Edate', 
                                 tooltip = 'Optional end date to clamp strategy observation window.'
                                 ) //
//
string ig_ro      = 'Lookback Options:'
int  i_lback      = input.int(   title   = 'Lookback Shift:', 
                                 defval  = 0, minval = 0,
                                 group   = ig_ro,
                                 tooltip = 'Optional, inspect previous signal values.'
                                 ) //
//
string ig_so      = 'Signal Options:'
bool i_onlyL      = input.bool(      title   = 'Long Only:', 
                                     defval  = true,
                                     group   = ig_so, 
                                     tooltip = 'If switched off, short entries are initiated by sell signals.'
                                     ) //
int  i_sMonth     = input.int(       title   = 'Sell Month:', 
                                     defval  = 8, minval = 1, maxval = 12, step = 1,
                                     group   = ig_so, 
                                     tooltip = 'The worst performing month, originally clamped between months 5 and 8.'
                                     ) //
int  i_maxVI      = input.int(       title   = 'Max VIX up:', 
                                     defval  = 60, minval = 50, maxval = 60, step = 5,
                                     group   = ig_so, 
                                     tooltip = 'Volatility maximum threshold.'
                                     ) //
int  i_critVFI    = input.int(       title   = 'Critical VFI Sell:', 
                                     defval  = -20, minval = -20, maxval = -15, step = 5, 
                                     group   = ig_so, 
                                     tooltip = 'Critical money float (VFI) threshold for sell signal.'
                                     ) //
float i_K         = input.float(     title   = 'ATR/VIX Ratio:', 
                                     defval  = 1.5, minval = 1.3, maxval = 1.7, step = 0.2, 
                                     group   = ig_so, 
                                     tooltip = 'ATR to VIX ratio for sell signal.'
                                     ) //
// 
string i_VIticker = input(    title   = 'Volatility Index:',
                                     defval  = 'VIX', 
                                     group   = ig_so,
                                     tooltip = 'Volatility Index Ticker.'
                                     ) //
string i_VItf     = input.timeframe( title   = '',
                                     defval  = 'D', 
                                     group   = ig_so,
                                     tooltip = 'Volatility Index Timeframe.'
                                     ) //
int i_VIiperiod   = input.int(       title   = 'Implied Volatility period:', 
                                     defval  = 25, 
                                     group   = ig_so
                                     ) //
int i_VIhperiod   = input.int(       title   = 'Historical Volatility period:', 
                                     defval  = 15, 
                                     group   = ig_so
                                     ) //
//
int i_VFIperiod   = input.int(   title   = 'VFI period:', 
                                 defval  = 130, 
                                 group   = ig_so, inline = 'VFI1'
                                 ) //
int i_VFIMperiod  = input.int(   title   = 'MA:', 
                                 defval  = 10, 
                                 group   = ig_so, inline = 'VFI1',
                                 tooltip = 'VFI and Moving Average sampling period.'
                                 ) //
float i_VFIcoef   = input.float( title   = 'VFI Coef Cuttoff:', 
                                 defval  = 0.2, 
                                 group   = ig_so, inline = 'VFI2'
                                 ) //
float i_VFIvcoef  = input.float( title   = 'Volat.:',
                                 defval  = 2.5, 
                                 group   = ig_so, inline = 'VFI2',
                                 tooltip = 'VFI Cutoff and Volatility coefficient.'
                                 ) //
int i_ATRperiod   = input.int(   title   = 'ATR length:',
                                 defval  = 15, 
                                 group = ig_so, inline = 'ATR',
                                 tooltip = 'ATR length.'
                                 ) // 
//
string ig_to = 'Table Options:'
bool i_showT =      input.bool(  title   = 'Show Table:',
                                 defval  = false, 
                                 group   = ig_to, 
                                 tooltip = 'Optional toggle.'
                                 ) //
string i_Tpos =     input.string(title   = 'Position:',
                                 defval  = position.middle_right, 
                                 options = [    position.top_left,     position.top_center,    position.top_right, 
                                             position.middle_left,  position.middle_center, position.middle_right,
                                             position.bottom_left,  position.bottom_center, position.bottom_right   ],
                                 group   = ig_to) //
int i_Ttransp  =      input.int( title   = 'Transparency:',
                                 defval  = 0, minval = 1, maxval = 99, 
                                 group   = ig_to
                                 ) //
//
color i_Tcframe =   input.color( title   = 'Table Colors:', 
                                 defval  = #000000, 
                                 group   = ig_to, inline = 'table color'
                                 ) //
color i_Tcrowe =    input.color( title   = '', 
                                 defval  = #d6dae3, 
                                 group   = ig_to, inline = 'table color'
                                 ) //
color i_Tcrowo =    input.color( title   = '', 
                                 defval  = #cccccc, 
                                 group   = ig_to, inline = 'table color', 
                                 tooltip = 'Table background colors, in order: frame, even row, odd row.'
                                 ) //
string i_Ttsize =   input.string(title   = 'Table Text:', 
                                 defval  = size.small,
                                 options = [size.auto, size.huge, size.large, size.normal, size.small, size.tiny],
                                 group   = ig_to, inline = 'table text'
                                 ) //
color i_Tcdeft =    input.color( title   = 'Text Colors:', 
                                 defval  = #000000, 
                                 group   = ig_to, inline = 'table text'
                                 ) //
color i_Tcsigt =    input.color( title   = '', 
                                 defval  = color.red, 
                                 group   = ig_to, inline = 'table text'
                                 ) //
color i_Tctitt =    input.color( title   = '', 
                                 defval  = color.navy, 
                                 group   = ig_to, inline = 'table text', 
                                 tooltip = 'Table text size and colors, in order: default, short signal, title.'
                                 ) //

// Comparison Index
float VIX      = request.security(i_VIticker, i_VItf, close)
[VIdn, VIup]   = volatility(VIX, i_VIiperiod)                   // Implied
[ATRdn, ATRup] = volatility(ta.atr(i_VIhperiod), i_VIiperiod)   // Historical

float VFI   = vfi(i_VFIperiod, i_VFIvcoef, i_VFIcoef)
float VFI10 = ta.sma(VFI, i_VFIMperiod)


//
bool VFIatCrit = VFI > i_critVFI
bool lowVolat  = (VIup < i_maxVI) or (ATRup < (i_K * i_maxVI))
bool VolatC    = VFIatCrit ? lowVolat : false
bool Long      = ((month >= 10) or (month < i_sMonth)) and VolatC[1]
bool Sseasonal = month == i_sMonth                                   // SEASONAL EXIT/SHORT
bool Svol      = VIup > (2.0 * i_maxVI)                              // VOLATILITY EXIT/SHORT
bool Scrit     = ta.cross(i_critVFI, VFI) and (VFI10 < VFI10[1])     // VFI EXIT/SHORT
bool Short     = Sseasonal or Svol[1] or Scrit[1]

bool withinObsWindow = true
//
if withinObsWindow and strategy.equity > 0
    _L = strategy.long
    _S = strategy.short
    strategy.entry('L'               , direction = _L,      when = Long      )
    if i_onlyL
        strategy.close('L', comment = 'EXIT SEASONAL'  ,    when = Sseasonal )
        strategy.close('L', comment = 'EXIT VOLATILITY',    when = Svol[1]   )
        strategy.close('L', comment = 'EXIT MF'        ,    when = Scrit[1]  )
    else
        strategy.entry('S Seasonal'  , direction = _S,      when = Sseasonal )
        strategy.entry('S Volatility', direction = _S,      when = Svol[1]   )
        strategy.entry('S MF Crit.'  , direction = _S,      when = Scrit[1]  )
else
    strategy.close_all()

string SIGNAL = switch
    (Long)                      => 'Long Seasonal'
    (Sseasonal and i_onlyL)     => 'Exit Seasonal'
    (Svol[1]   and i_onlyL)     => 'Exit Volatility'
    (Scrit[1]  and i_onlyL)     => 'Exit Money Flow'
    (Sseasonal and not i_onlyL) => 'Short Seasonal'
    (Svol[1]   and not i_onlyL) => 'Short Volatility'
    (Scrit[1]  and not i_onlyL) => 'Short Money Flow Bearish'
    =>                             'none'

string date = str.format(
  '{0,number,0000}-{1,number,00}-{2,number,00}', 
  year, month, dayofmonth
  )

var table dTable = table.new(position    = i_Tpos, 
                             columns     = 2, 
                             rows        = 17, 
                             frame_color = color.new(#000000, i_Ttransp), 
                             frame_width = 4
                             ) //


// @function Helper to populate the table rows.
tRow(tableId, idx, left, right, tcol=0) =>
    color _bg = color.new(idx % 2 ? i_Tcrowo : i_Tcrowe, i_Ttransp)
    color _tx = switch (tcol)
        (1)  => color.new(i_Tcsigt, i_Ttransp)
        (2)  => color.new(i_Tctitt, i_Ttransp)
        =>      color.new(i_Tcdeft, i_Ttransp)
    // table.cell(  table_id=tableId, 
    //              column=0, row=idx, 
    //              text=left, text_color=_tx, text_halign=text.align_right, text_size=i_Ttsize, 
    //              bgcolor=_bg) //
    // table.cell(  table_id=tableId, 
    //              column=1, row=idx, 
    //              text=str.tostring(right), text_color=_tx, text_halign=text.align_left, text_size=i_Ttsize, 
    //              bgcolor=_bg) //


if i_showT
    float _atr10 = ta.atr(10)[i_lback]
    string _nf = '0.00'
    string _aru = '🔼 ', string _ard = '🔽 '
    //      id | idx |                   left label  |                      right label  |               conditional color |
    tRow(dTable,   00, 'S&P500 Hybrid Seasonal '     , ''                                , 2                               )
    tRow(dTable,   01, 'Created By: Markos Katsanos' , ''                                , 2                               )
    tRow(dTable,   02, 'Date:'                       , date[i_lback]                                                       )
    tRow(dTable,   03, 'Signal:'                     , SIGNAL[i_lback]                                                     )
    tRow(dTable,   04, 'Price:'                      , open[i_lback]                                                       )
    tRow(dTable,   05, 'VIX:'                        , str.tostring(  VIX[i_lback], _nf)                                   )
    tRow(dTable,   06, 'VFI:'                        , str.tostring(  VFI[i_lback], _nf) , VFIatCrit ? 1 : 0               )
    tRow(dTable,   07, 'ATR:'                        , str.tostring(        _atr10, _nf)                                   )
    tRow(dTable,   08, 'VIup%:'                      , str.tostring( VIup[i_lback], _nf) , VIup > i_maxVI ? 1 : 0          )
    tRow(dTable,   09, 'ATRup%:'                     , str.tostring(ATRup[i_lback], _nf) , ATRup > i_K * i_maxVI ? 1 : 0   )
    tRow(dTable,   10, 'VIdn%:'                      , str.tostring( VIdn[i_lback], _nf)                                   )
    tRow(dTable,   11, 'ATRdn%:'                     , str.tostring(ATRdn[i_lback], _nf)                                   )
    tRow(dTable,   12, _aru + 'Long Seasonal:'       , Long[i_lback]                                                       )
    tmp = 12
    if not i_onlyL
        tmp := 13
        tRow(dTable, 13, _ard + 'Short:'             , Short[i_lback]                    , Short[i_lback] ? 1 : 0          )
    tRow(dTable,  tmp+1, _ard + 'Seasonal:'          , Sseasonal[i_lback]                , Sseasonal[i_lback] ? 1 : 0      )
    tRow(dTable,  tmp+2, _ard + 'Volatility:'        , Svol[1+i_lback]                   , Svol[1 + i_lback] ? 1 : 0       )
    tRow(dTable,  tmp+3, _ard + 'Money Flow:'        , Scrit[i_lback]                    , Scrit[i_lback] ? 1 : 0          )


আরো