স্টোকাস্টিক আরএসআই মম্পটম ওসিলেশন ট্রেডিং কৌশল

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

img

সারসংক্ষেপ

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

কৌশল নীতি

কৌশলটির মূল সূচক হল স্টোকাস্টিক আরএসআই। স্টোকাস্টিক আরএসআই এর গণনার সূত্র হল:

স্টোকাস্টিক আরএসআই = (আরএসআই - আরএসআই নিম্ন) / (আরএসআই উচ্চ - আরএসআই নিম্ন) * 100

যেখানে RSI lengthRSI প্যারামিটার (ডিফল্ট 12) ব্যবহার করে গণনা করা হয় এবং স্টোকাস্টিক RSI lengthStoch প্যারামিটার (ডিফল্ট 12) ব্যবহার করে গণনা করা হয়।

যখন স্টোকাস্টিক আরএসআই বেগুনি ভরাট এলাকার চেয়ে বেশি হয়, তখন এটি ওভারকোপড এলাকা, তারপর শর্ট যান; যখন স্টোকাস্টিক আরএসআই বেগুনি ভরাট এলাকার চেয়ে কম হয়, তখন এটি ওভারসোল্ড এলাকা, তারপর লং যান।

এছাড়াও, কৌশলটি চলমান গড় ফিল্টার শর্তও সেট করে। কেবলমাত্র যখন দ্রুত EMA ধীর EMA এর চেয়ে বেশি হয় তখন আপনি একটি দীর্ঘ অবস্থান খুলতে পারেন; কেবলমাত্র যখন দ্রুত EMA ধীর EMA এর চেয়ে কম হয় তখন আপনি একটি শর্ট অবস্থান খুলতে পারেন। এটি বিপরীত প্রবণতা ট্রেডিং এড়ায়।

কৌশলটির সুবিধা

একটি একক RSI কৌশল তুলনায়, এই কৌশলটি স্টোক্যাস্টিক সূচককে আরও স্পষ্টভাবে overbought / oversold এলাকা সনাক্ত করতে একত্রিত করে, যার ফলে সংকেতগুলির নির্ভরযোগ্যতা উন্নত হয়।

একটি একক স্টোকাস্টিক কৌশল তুলনায়, এই কৌশলটি স্টোকাস্টিকের ইনপুট ডেটা উত্স হিসাবে আরএসআই ব্যবহার করে, যা কিছু গোলমাল ফিল্টার করতে পারে এবং সংকেতটিকে আরও নির্ভরযোগ্য করে তুলতে পারে।

চলমান গড় ফিল্টার শর্ত কার্যকরভাবে বিপরীত প্রবণতা অবস্থান গঠনের এড়ানোর জন্য সেট করা হয়, যার ফলে অপ্রয়োজনীয় ক্ষতি হ্রাস পায়।

পজিশন হোল্ডিং টাইম ডিলেজ সেট করা হয়েছে যাতে মিথ্যা ব্রেকআউট দ্বারা থামানো না হয়।

কৌশলটির ঝুঁকি

কৌশলটি মূলত স্বল্প-চক্রের সূচক ব্যবহার করে, তাই এটি কেবল স্বল্পমেয়াদী ক্রিয়াকলাপের জন্য উপযুক্ত এবং দীর্ঘমেয়াদে ভাল সম্পাদন করতে পারে না।

স্টোকাস্টিক আরএসআই সূচক নিজেই একটি নির্দিষ্ট বিলম্ব আছে এবং স্বল্পমেয়াদে তীব্র মূল্য পরিবর্তনের পরে সংকেত মিস করতে পারে।

অস্থির বাজারগুলিতে, স্টোকাস্টিক আরএসআই ওভারকোপড/ওভারসোল্ড এলাকার একাধিক অনুপ্রবেশ সৃষ্টি করতে পারে, যা ওভারট্রেডিং এবং লেনদেনের খরচ বৃদ্ধি করতে পারে।

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

  1. স্টোকাস্টিক আরএসআই এর দৈর্ঘ্য, কে এবং ডি মান আরও অনুকূল করার জন্য বিভিন্ন প্যারামিটার সমন্বয় পরীক্ষা করা যেতে পারে।

  2. আরও উপযুক্ত আরএসআই চক্র খুঁজে পেতে বিভিন্ন আরএসআই দৈর্ঘ্য পরামিতি পরীক্ষা করা যেতে পারে।

  3. সিগন্যালের নির্ভুলতা আরও উন্নত করতে অন্যান্য সূচকগুলির সাথে সংযুক্ত করার চেষ্টা করুন, যেমন এমএসিডি, বলিংজার ব্যান্ড ইত্যাদি।

  4. একটি উপযুক্ত প্রস্থান সময় খুঁজে পেতে বিভিন্ন অবস্থান হোল্ডিং বিলম্ব পরামিতি পরীক্ষা করুন।

সিদ্ধান্ত

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


/*backtest
start: 2023-11-25 00:00:00
end: 2023-12-25 00:00:00
period: 1h
basePeriod: 15m
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/
// © Drun30 (Federico Magnani)

//@version=4
//STRATEGIA PRINCIPALE
capitaleIniziale=10000

var sizeordineInit= 50 // → % di capitale investita per ogni trade
var deltaSize = 25 // → delta% di capitale investito se trade precedente è stato in perdita
var sizeLimite = 100 //il trade non userà mai questa percentuale di capitale investito
var sizeordine = sizeordineInit

//Parametri ottimali 30 min
usiShort=false
usiLong=true
ipercomprato=85.29
ipervenduto=30.6
//

strategy("Momentum Strategy (V7.B.4)", initial_capital=capitaleIniziale, currency="USD", default_qty_type=strategy.percent_of_equity, commission_type=strategy.commission.percent, commission_value=0.1, slippage = 5, default_qty_value=sizeordineInit, overlay=false, pyramiding=0)

backtest = input(title="------------------------Backtest Period------------------------", defval = false)
start = timestamp(input(2020, "start year"), input(1, "start month"), input(1, "start day"), 00, 00)
end = timestamp(input(0, "end year"), input(0, "end month"), input(0, "end day"), 00, 00) 

siamoindata=time > start?true:false
if end > 0
    siamoindata:=time > start and time <= end?true:false

basicParameters = input(title="------------------------Basic Parameters------------------------", defval = false)
smoothK = input(3, minval=1)
smoothD = input(6, minval=1)
lengthRSI = input(12, minval=1) 
src = input(close, title="RSI Source")
rsi1 = rsi(src, lengthRSI)
lengthStoch = input(12, minval=1)
k = ema(stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
d = ema(k, smoothD)
altezzaipercomprato= input(ipercomprato, title="Overbought Height", minval=1, type=input.float)
altezzaipervenduto= input(ipervenduto, title="Oversold Height", minval=1,type=input.float) 

BarsDelay = input(6,title="Bars delay",minval=0) 

GambleSizing = input(true, title = "Gamble Sizing?",type=input.bool)
gambleAdd = input(deltaSize,title="Gamble Add (%)",minval=0,type=input.integer)
gambleLimit = input(sizeLimite,title="Gamble MAX (%)",minval=0,type=input.integer)
if GambleSizing and strategy.closedtrades[0]>strategy.closedtrades[1]
    if strategy.losstrades[0]>strategy.losstrades[1] and sizeordine<gambleLimit
        sizeordine:=sizeordine+gambleAdd
    if strategy.wintrades[0]>strategy.wintrades[1]
        sizeordine:=sizeordineInit

periodomediamobile_fast = input(1, title="Fast EMA length",minval=1)
periodomediamobile_slow = input(60, title="Slow EMA length",minval=1)

plot(k, color=color.blue)
plot(d, color=color.orange)
h0 = hline(altezzaipercomprato)
h1 = hline(altezzaipervenduto)
fill(h0, h1, color=color.purple, transp=80)
// n=input(Vicinanzadalcentro,title="Vicinanza dal centro",minval=0) 
//sarebbe il livello di D in cui si acquista o si vende, maggiore è la vicinanza maggiore sarà la frequenza dei trades, SE 0 è DISABILITATO

//     siamoinipervenduto= d<=altezzaipervenduto and d<=d[n] and d>d[1]?true:false //and d<d[3] and d>d[1]
//     siamoinipercomprato= d>=altezzaipercomprato and d>=d[n] and d<d[1]?true:false //and d>d[3] and d<d[1]
goldencross = crossover(k,d)
deathcross = crossunder(k,d)
// METTI VARIABILE IN CUI AVVIENE CROSSOVER O CROSSUNDER
valoreoro = valuewhen(goldencross,d,0)
valoremorte = valuewhen(deathcross,d,0)

siamoinipervenduto = goldencross and valoreoro<=altezzaipervenduto?true:false//d<=altezzaipervenduto?true:false
siamoinipercomprato = deathcross and valoremorte>=altezzaipercomprato?true:false//d>=altezzaipercomprato?true:false

long_separator = input(title="------------------------LONG------------------------", defval = usiLong)

sl_long_inp = input(10, title="Stop Loss LONG %", type=input.float) 
tp_long_inp = input(8, title="Take Profit LONG %",type=input.float)
stop_level_long = strategy.position_avg_price * (1 - (sl_long_inp/100)) //strategy.position_avg_price corrisponde al prezzo con cui si è aperta la posizione
take_level_long = strategy.position_avg_price * (1 + (tp_long_inp/100))

//BINANCE
JSON_long = 'OPEN LONG: PUT THE JSON HERE FOR THE API CALL'
JSON_chiusura = 'CLOSE POSITION: PUT THE JSON HERE FOR THE API CALL' 

webhookLong = JSON_long
webhookClose= JSON_chiusura

trendFilterL = input(title="TREND FILTER LONG?", defval = true)

EMAfast=ema(close,periodomediamobile_fast)
EMAslow=ema(close,periodomediamobile_slow)

siamoinuptrend_ema=EMAfast>EMAslow?true:false //close>=EMAfast and EMAfast>EMAslow
siamoinuptrend = siamoinuptrend_ema

// CondizioneAperturaLong = siamoinipervenduto and siamoindata // and siamoinuptrend
CondizioneAperturaLong = siamoinipervenduto and siamoindata and long_separator
if trendFilterL
    CondizioneAperturaLong := siamoinipervenduto and siamoindata and long_separator and siamoinuptrend

CondizioneChiusuraLong = siamoinipercomprato and siamoindata 

possiamoAprireLong=0
if trendFilterL and siamoinuptrend
    possiamoAprireLong:=5
plot(possiamoAprireLong,color=color.green)

sonPassateLeBarreG = barssince(CondizioneAperturaLong) == BarsDelay?true:false
sonPassateLeBarreD = barssince(CondizioneChiusuraLong) == BarsDelay?true:false

haiUnLongAncoraAperto = false
haiUnLongAncoraAperto := strategy.position_size>0?true:false

// Se l'ultimo valore della serie "CondizioneAperturaLong" è TRUE, allora hai un long ancora aperto
// Se l'ultimo valore della serie "CondizioneAperturaLong" è FALSE, allora:
//       Se l'ultimo valore della serie "CondizioneChiusuraLong" è TRUE, allora NON hai un long ancora aperto 
//       Se l'ultimo valore della serie "CondizioneChiusuraLong" è FALSE, allora restituisce l'ultimo valore della serie "haiUnLongAncoraAperto"

haiUnLongAncoraAperto_float = if(haiUnLongAncoraAperto==true)
    10
else
    0

plot(haiUnLongAncoraAperto_float,color=color.red) //FInché la linea rossa si trova a livello "1" allora c'è un ordine long in corso

quantita = (sizeordine/100*(capitaleIniziale+strategy.netprofit))/valuewhen(haiUnLongAncoraAperto==false and CondizioneAperturaLong,close,0)

plot(sizeordine,color=color.purple, linewidth=3)

if  strategy.position_size<=0 and CondizioneAperturaLong //and sonPassateLeBarreG and haiUnLongAncoraAperto==false strategy.opentrades==0
    strategy.entry("Vamonos",strategy.long, alert_message=webhookLong, comment="OPEN LONG", qty=quantita)

if  strategy.position_size>0 //and sonPassateLeBarreD // and CondizioneChiusuraLong 
    if siamoinuptrend == true and sonPassateLeBarreD
        strategy.close("Vamonos", alert_message=webhookClose, comment="CLOSE LONG")
    else if siamoinuptrend == false and CondizioneChiusuraLong
        strategy.close("Vamonos", alert_message=webhookClose, comment="CLOSE LONG")

    
if strategy.position_size>0 and siamoindata
    strategy.exit("Vamonos", stop=stop_level_long, limit=take_level_long, comment="CLOSE LONG (LIMIT/STOP)")


short_separator = input(title="------------------------SHORT------------------------", defval = usiShort)    

sl_short_inp = input(20, title="Stop Loss SHORT %")
tp_short_inp = input(35, title="Take Profit SHORT %")
stop_level_short = strategy.position_avg_price * (1 + (sl_short_inp/100))
take_level_short= strategy.position_avg_price * (1 - (tp_short_inp/100))

// BINANCE 
JSON_short = 'OPEN SHORT: PUT THE JSON HERE FOR THE API CALL'

webhookShort = JSON_short

trendFilterS = input(title="TREND FILTER SHORT?", defval = true)

siamoindowntrend_ema=EMAfast<EMAslow?true:false //close<=EMAfast and EMAfast<EMAslow
siamoindowntrend=siamoindowntrend_ema

CondizioneAperturaShort = short_separator and siamoinipercomprato and siamoindata 
if trendFilterS
    CondizioneAperturaShort:=short_separator and siamoinipercomprato and siamoindata and siamoindowntrend

CondizioneChiusuraShort = siamoinipervenduto and siamoindata

sonPassateLeBarreGs = barssince(CondizioneAperturaShort) == BarsDelay?true:false
sonPassateLeBarreDs = barssince(CondizioneChiusuraShort) == BarsDelay?true:false

haiUnoShortAncoraAperto = false
haiUnoShortAncoraAperto := strategy.position_size<0?true:false

haiUnoShortAncoraAperto_float = if(haiUnoShortAncoraAperto==true)
    15
else
    0

plot(haiUnoShortAncoraAperto_float,color=color.purple) //FInché la linea viola si trova a livello "2" allora c'è un ordine short in corso

if CondizioneAperturaShort and strategy.position_size>=0 //and haiUnoShortAncoraAperto==false
    strategy.entry("Andale",strategy.short,alert_message=webhookShort, comment="OPEN SHORT")

if  strategy.position_size<0 //and sonPassateLeBarreD // and CondizioneChiusuraLong 
    if siamoindowntrend == true and sonPassateLeBarreDs
        strategy.close("Andale",alert_message=webhookClose, comment="CLOSE SHORT")
    else if siamoindowntrend == false and CondizioneChiusuraShort
        strategy.close("Andale",alert_message=webhookClose, comment="CLOSE SHORT")

if strategy.position_size<0 and siamoindata
    strategy.exit("Andale", stop=stop_level_short, limit=take_level_short, comment="CLOSE SHORT (LIMIT/STOP)")

আরো