EMA এবং RSI এর উপর ভিত্তি করে ট্রেন্ড ট্রেডিং কৌশল


সৃষ্টির তারিখ: 2023-09-20 14:21:16 অবশেষে সংশোধন করুন: 2023-09-20 14:21:16
অনুলিপি: 0 ক্লিকের সংখ্যা: 894
1
ফোকাস
1617
অনুসারী

ওভারভিউ

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

কৌশল নীতি

  1. ২০০ দিনের ইএমএ গণনা করুন, এটি প্রবণতা নির্ধারণের জন্য একটি গড় রেখা নির্দেশক। ইএমএ দ্রুত দামের পরিবর্তনের প্রতিক্রিয়া জানায়, যাতে প্রবণতার দিকনির্দেশনা কার্যকরভাবে নির্ধারণ করা যায়।

  2. ১৪ দিনের আরএসআই গণনা করুন এবং সিদ্ধান্ত নিন যে এটি একটি ওভার-বিক্রয় কিনা। আরএসআই 50 এর নীচে ওভার-বিক্রয় হিসাবে বিবেচিত হয়, 50 এর উপরে ওভার-বিক্রয় হিসাবে বিবেচিত হয়। আর আরএসআইয়ের উপরে-নিচে প্রবণতা এবং ক্রয়-বিক্রয় সময় নির্ধারণের সাথে মিলিত।

  3. শেষ দুটি কে লাইনের বন্ধের দামের আকারের তুলনা, প্রবণতার দিকনির্দেশনা নির্ধারণ করুন। শেষ দুটি বন্ধের দামকে ক্রমবর্ধমান হিসাবে উচ্চতর প্রবণতা হিসাবে বিবেচনা করা হয় এবং হ্রাসকে নিম্নমুখী হিসাবে বিবেচনা করা হয়।

  4. যখন মূল্য 200 দিনের ইএমএর উপরে থাকে এবং আরএসআই 50 এর নিচে থাকে তখন একটি ক্রয় সংকেত দেওয়া হয়।

  5. যখন দাম ২০০ দিনের ইএমএর নিচে থাকে এবং আরএসআই ৫০ এর উপরে থাকে এবং এটি নেমে যায়, তখন একটি বিক্রয় সংকেত দেওয়া হয়।

  6. এটিআর এবং সর্বশেষ ১৪টি কে লাইনের সর্বোচ্চ এবং সর্বনিম্ন মূল্যের জন্য স্টপ লস এবং স্টপ স্টপ পয়েন্ট ব্যবহার করা হয়।

  7. ঝুঁকি নিয়ন্ত্রণের জন্য মোবাইল স্টপ লস কৌশল ব্যবহার করুন।

সামর্থ্য বিশ্লেষণ

  1. ডাবল সূচকগুলি ট্রেন্ডের দিকনির্দেশনা নির্ধারণের সাথে মিলিত হয়, যা সঠিকতা বাড়ায়। ইএমএ মূল প্রবণতা নির্ধারণ করে, আরএসআই এবং কে-লাইন সম্পর্ক স্থানীয় প্রবণতা এবং কেনার সময় নির্ধারণ করে।

  2. RSI সূচকটি কার্যকরভাবে মিথ্যা ব্রেকডাউন এড়ায়। RSI এর ফাঁকা অবস্থার মাধ্যমে EMA সূচকের পিছনে থাকা অপ্রয়োজনীয় লেনদেন এড়ানো যায়।

  3. মোবাইল স্টপ লস কার্যকরভাবে বড় আকারের স্বতন্ত্র ওঠানামা দ্বারা সৃষ্ট ক্ষতি নিয়ন্ত্রণ করে।

  4. অপ্টিমাইজড প্যারামিটার সমন্বয়গুলি কৌশলগত প্যারামিটারগুলিকে আরও শক্তিশালী করে তোলে।

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

  1. বড় আকারের কম্পনের ক্ষেত্রে, ইএমএ এবং আরএসআইয়ের ত্রুটিপূর্ণ সংকেত হওয়ার সম্ভাবনা বেশি। এ ধরনের ঘটনা এড়ানো উচিত।

  2. স্টপ পয়েন্ট খুব ছোট হলে খুব ঘন ঘন ক্ষতি হতে পারে; স্টপ পয়েন্ট খুব বড় হলে ক্ষতি নিয়ন্ত্রণ করা কঠিন। এটিআর প্যারামিটারগুলি যথাযথভাবে সামঞ্জস্য করা উচিত।

  3. দিনের সময় EMA অতিক্রম করার পরে পুনরায় সংশোধন হওয়ার সম্ভাবনা বেশি, এই সময়ে RSI প্যারামিটারগুলিকে যথাযথভাবে শিথিল করা উচিত যাতে ট্রেন্ডটি মিস করা যায় না।

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

  1. এটিআর প্যারামিটার এবং স্টপ-ড্র্যাপের দূরত্বকে যথাযথভাবে সামঞ্জস্য করুন যাতে আপনি আরও ভাল স্টপ-ড্র্যাপ পয়েন্ট খুঁজে পান।

  2. ইএমএ এবং আরএসআই সূচক প্যারামিটারগুলিকে আরও উপযুক্ত প্যারামিটার সমন্বয় খুঁজে পেতে অপ্টিমাইজ করুন।

  3. অন্যান্য সহায়ক সূচক যেমন MACD, ব্রিন ব্যান্ড ইত্যাদি যুক্ত করে ফিল্টার করা হয়, যা সংকেতের নির্ভুলতা বাড়ায়।

  4. বিভিন্ন জাতের প্যারামিটার সেটিংসের বৈচিত্র্য পরীক্ষা করা যায়, যা প্যারামিটারগুলির স্থায়িত্বকে আরও উন্নত করে।

  5. একটি নির্দিষ্ট সময়সীমার মধ্যে কৌশলটি বন্ধ করার চেষ্টা করুন যাতে ভুল সংকেত প্রাপ্তির সম্ভাবনা থাকে।

সারসংক্ষেপ

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

কৌশল সোর্স কোড
/*backtest
start: 2023-01-01 00:00:00
end: 2023-08-10 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
// strategy("EMA RSI Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=1)


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Author       : AJ Rupasinghege
// Date         : 06/11/2022
// Release      : v6.0
// Description  : If the last two closes are in ascending order, the rsi is below 50 and ascending, and the current candle is above 200 ema, then LONG. 
//                If the last two closes are in descending order, the rsi is above 50 and descending, and the current candle is below 200 ema, then SHORT. 
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////// INPUTS //////////////////////////////////////////////////////////////

ema_length = input(200, "EMA Length")
rsi_buy_value = input(50, "RSI Buy Value")
rsi_sell_value = input(50, "RSI Sell Value")
show_data = input.bool(0, "Show Data")


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////// VARIABLES //////////////////////////////////////////////////////////

var stop_loss = 0.0
var last_trade_entry_price = 0.0
var low_value= 0.0
var atr = 0.0
var high_value = 0.0
var stop_loss_points = 0.0
var limit = 0.0
var bar_id_entry = 0


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////// FUNCTIONS //////////////////////////////////////////////////////////

getTradeConditionsLong() =>
    //@function         Used to calculate stop_loss, stop_loss points, limit and label values for long trades
    //@param direction  (float) // strategy.poistion.size
    //@returns          stop_loss, stop_loss_points, limit
    //@Dependancies     low_value, atr, last_trade_entry_price,bar_id_entry
    _stop_loss = low_value - atr
    _stop_lossPoints = (last_trade_entry_price - _stop_loss) *100000
    _limit = last_trade_entry_price + (last_trade_entry_price - low_value + atr) 
    value = "OpenValue: " + str.tostring(last_trade_entry_price) + 
         "\n OpenBarIndex: " + str.tostring(bar_id_entry) + 
         "\n LowValue: " + str.tostring(low_value) + 
         "\n atr: " + str.tostring(atr) + "\n stop_loss: " + 
         str.tostring(_stop_loss) + "\n Limit: " +
         str.tostring(_limit)

    [_stop_loss,_stop_lossPoints,_limit, value]

getTradeConditionsShort() =>
    //@function         Used to calculate stop_loss, stop_loss points, limit and label values for short trades
    //@param direction  (float) // strategy.poistion.size
    //@returns          stop_loss, stop_loss_points, limit
    //@Dependancies     high_value, atr, last_trade_entry_price,bar_id_entry
    _stop_loss = high_value + atr
    _stop_lossPoints = (_stop_loss  -last_trade_entry_price) * 100000
    _limit = last_trade_entry_price - (high_value - last_trade_entry_price + atr)
    value = "OpenValue: " + str.tostring(last_trade_entry_price) + 
         "\n OpenBarIndex: " + str.tostring(bar_id_entry) + 
         "\n HighValue: " + str.tostring(high_value) + 
         "\n atr: " + str.tostring(atr) + "\n stop_loss: " + 
         str.tostring(_stop_loss)  + "\n Limit: " +
         str.tostring(_limit)
    [_stop_loss,_stop_lossPoints,_limit, value]




/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////// SIGNALS //////////////////////////////////////////////////////////

ema = ta.ema(close,ema_length)
rsi = ta.rsi(close,14)

ema_buy_signal = ema < low
ema_sell_signal = ema > high


rsi_buy_signal = rsi < rsi_buy_value and rsi[1] < rsi[0]
rsi_sell_signal = rsi > rsi_sell_value and rsi[1] > rsi[0]

trend_buy_signal = close[2] < close[1] and close[1] < close[0]
trend_sell_signal = close[2] > close[1] and close[1] > close[0]

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////// TRADES //////////////////////////////////////////////////////////
long = trend_buy_signal 
         and ema_buy_signal 
         and rsi_buy_signal
short = trend_sell_signal 
         and ema_sell_signal  
         and rsi_sell_signal

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////// STRATEGY //////////////////////////////////////////////////////////



if long 
    strategy.entry("Long", strategy.long)

if short 
    strategy.entry("Short", strategy.short)
   

// Calculate Trade Entry Variables
last_trade_entry_price := strategy.opentrades.entry_price(strategy.opentrades - 1)
bar_id_entry := strategy.opentrades.entry_bar_index(strategy.opentrades - 1) 
atr := ta.atr(14) 
low_value := ta.lowest(14)
high_value := ta.highest(14)


// Exit Strategy for Long Positions 
if (strategy.position_size[1] != strategy.position_size and strategy.position_size>0)
    [_stop_loss,_stop_loss_points, _limit, value] = getTradeConditionsLong()
    stop_loss := _stop_loss
    stop_loss_points := _stop_loss_points
    limit := _limit
    

    if show_data
        label.new(bar_id_entry,stop_loss - 0.005,str.tostring(value),xloc = xloc.bar_index,yloc = yloc.price,style = label.style_none) 
    strategy.exit("Long Exit", "Long", trail_offset = stop_loss_points/2, trail_points = stop_loss_points/2 , stop = stop_loss , limit = limit   )


// Exit Strategy for Short Positions 
if (strategy.position_size[1] != strategy.position_size and strategy.position_size<0)
    [_stop_loss,_stop_loss_points, _limit, value] = getTradeConditionsShort()
    stop_loss := _stop_loss
    stop_loss_points := _stop_loss_points
    limit := _limit

    if show_data
        label.new(bar_id_entry,stop_loss + 0.005,str.tostring(value),xloc = xloc.bar_index,yloc = yloc.price,style = label.style_none) 
    strategy.exit("Short Exit", "Short", trail_offset = stop_loss_points/2, trail_points = stop_loss_points/2 , stop = stop_loss , limit = limit )


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////// PLOTS //////////////////////////////////////////////////////////

plot(ema, "SMA", color = color.blue, linewidth = 2 )


p1 = plot(strategy.position_size>0? stop_loss:na, style = plot.style_linebr , color = color.rgb(82, 240, 42) )
p2 = plot(strategy.position_size<0? stop_loss:na, style = plot.style_linebr , color = color.rgb(223, 85, 85) )
p3 = plot(strategy.position_size!=0?limit : na, style = plot.style_linebr , color = color.rgb(94, 85, 223, 100) )


fill(p1, p3, color = color.new(color.green, 90))
fill(p2, p3, color = color.new(#e98787, 90))