কৌশল অনুসরণ করে RSI ট্রেন্ড

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

সারসংক্ষেপ

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

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

কৌশলটি প্রথমে আরএসআই এবং ওয়েটেড মুভিং এভারেজ গণনা করে। আরএসআই দৈর্ঘ্য 20 পিরিয়ড এবং ওয়েটেড এমএ দৈর্ঘ্য 20 উচ্চতর ওজনের সাথে যা স্বল্পমেয়াদী অস্থিরতার প্রভাব হ্রাস করে। যখন আরএসআই 60 এর উপরে এবং ওয়েটেড এমএ হারের পরিবর্তন -1% এর নীচে হয় তখন এটি দীর্ঘ হয়। যখন আরএসআই 40 এর নীচে এবং ওয়েটেড এমএ হারের পরিবর্তন 1% এর উপরে হয় তখন এটি সংক্ষিপ্ত হয়।

লং বা শর্ট খোলার পরে, স্টপ লস এবং ট্রেইলিং টেক প্রফিট অর্ডার একযোগে স্থাপন করা হয়। স্টপ লস বর্তমান মূল্য থেকে 3 ATR এ সেট করা হয়। প্রাথমিক ট্রেইলিং টেক প্রফিট অ্যাক্টিভেশন 4 ATR দূরে, এবং 3% বৃদ্ধিতে অনুসরণ করে। যখন দাম স্টপ লস বা ট্রেইলিং টেক প্রফিট অ্যাক্টিভেশন আঘাত করে, তখন অবস্থানটি বন্ধ হয়ে যাবে।

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

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

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

সামগ্রিক দিকটি হ'ল প্রবণতা অনুসরণ করার ক্ষমতা, ঝুঁকি নিয়ন্ত্রণের জন্য স্টপ লস এবং ট্রেলিং লাভের ব্যবস্থা গ্রহণ করে, এইভাবে শক্তিশালী প্রবণতাগুলিতে উল্লেখযোগ্য লাভ অর্জন করে।

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

  • আরএসআই থেকে মিথ্যা সংকেত অপ্রয়োজনীয় ট্রেডের কারণ হতে পারে
  • যখন দামের লঙ্ঘন বন্ধ হয় বা লাভের স্তর হ্রাস পায় তখন বন্ধ করতে বাধ্য হয়, প্রবণতা অনুসরণ করতে অক্ষম
  • টাকার ব্যবস্থাপনা সংক্রান্ত কঠোর নিয়মের ফলে বড় ধরনের ক্ষতি হতে পারে

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

সমাধানগুলির মধ্যে আরএসআই পরামিতিগুলি অনুকূলিতকরণ বা সংকেত নিশ্চিতকরণের জন্য অন্যান্য সূচক যুক্ত করা অন্তর্ভুক্ত। বিভিন্ন পণ্য এবং অস্থিরতার অবস্থার উপর ভিত্তি করে স্টপ / ট্রেলিং লাভের স্তরগুলি সামঞ্জস্য করুন। অতিরিক্ত ঝুঁকি এড়াতে অর্থ পরিচালনার নিয়মগুলির সাথেও সতর্ক থাকুন।

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

  • সিগন্যাল নিশ্চিতকরণের জন্য RSI এর সাথে অন্যান্য সূচক পরীক্ষা করুন, যেমন KD, MACD ইত্যাদি
  • পণ্যের বৈশিষ্ট্য এবং অস্থিরতা পরিসীমা উপর ভিত্তি করে স্টপ লস এবং ট্রেলিং লাভ গ্রহণ পরামিতি অপ্টিমাইজ
  • ফিক্সড সাইজ ট্রেডিং, কেলি ফর্মুলা ইত্যাদির মতো অন্যান্য অর্থ পরিচালনার কৌশল চেষ্টা করুন।
  • এন্ট্রি শর্ত যেমন বোলিংজার ব্রেকআউট, আরএসআই ডিভার্জেন্স ইত্যাদি যোগ করুন।
  • শক্তিশালী প্রবণতা উপর অবস্থান যোগ বিবেচনা করুন

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

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

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

[/trans]


/*backtest
start: 2023-01-01 00:00:00
end: 2023-06-24 00:00:00
period: 1d
basePeriod: 1h
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/
// © gsanson66


//This code is based on RSI and a backed weighted MA
//@version=5
strategy("RSI + MA BACKTESTING", overlay=true, initial_capital=1000, default_qty_type=strategy.fixed, commission_type=strategy.commission.percent, commission_value=0.18)


//------------------------FUNCTIONS---------------------------//

//@function which calculate a retro weighted moving average to minimize the impact of short term reversal
rwma(source, length) =>
    sum = 0.0
    denominator = 0.0
    weight = 0.0
    weight_x = 100/(4+(length-4)*1.30)
    weight_y = 1.30*weight_x
    for i=0 to length - 1
        if i <= 3
            weight := weight_x
        else
            weight := weight_y
        sum := sum + source[i] * weight
        denominator := denominator + weight
    rwma = sum/denominator

//@function which permits the user to choose a moving average type
ma(source, length, type) =>
    switch type
        "SMA" => ta.sma(source, length)
        "RWMA" => rwma(source, length)

//@function Displays text passed to `txt` when called.
debugLabel(txt, color) =>
    label.new(bar_index, high, text = txt, color=color, style = label.style_label_lower_right, textcolor = color.black, size = size.small)

//@function which looks if the close date of the current bar falls inside the date range
inBacktestPeriod(start, end) => (time >= start) and (time <= end)


//--------------------------------USER INPUTS-------------------------------//

//Technical parameters
rsiLengthInput = input.int(20, minval=1, title="RSI Length", group="RSI Settings")
maTypeInput = input.string("RWMA", title="MA Type", options=["SMA", "RWMA"], group="MA Settings", inline="1")
maLenghtInput = input.int(20, minval=1, title="MA Length", group="MA Settings", inline="1")
rsiLongSignalValue = input.int(60, minval=1, maxval=99, title="RSI Long Signal", group="Strategy parameters", inline="3")
rsiShortSignalValue = input.int(40, minval=1, maxval=99, title="RSI Short Signal", group="Strategy parameters", inline="3")
rocMovAverLongSignalValue = input.float(-1, maxval=0, title="ROC MA Long Signal", group="Strategy parameters", inline="4")
rocMovAverShortSignalValue = input.float(1, minval=0, title="ROC MA Short Signal", group="Strategy parameters", inline="4")
//TP Activation and Trailing TP
takeProfitActivationInput = input.float(4, minval=1.0, title="TP activation in multiple of ATR", group="Strategy parameters")
trailingStopInput = input.float(3, minval=0, title="Trailing TP in percentage", group="Strategy parameters")
//Money Management
fixedRatio = input.int(defval=400, minval=1, title="Fixed Ratio Value ($)", group="Money Management")
increasingOrderAmount = input.int(defval=200, minval=1, title="Increasing Order Amount ($)", group="Money Management")
//Backtesting period
startDate = input(title="Start Date", defval=timestamp("1 Jan 2018 00:00:00"), group="Backtesting Period")
endDate = input(title="End Date", defval=timestamp("1 July 2024 00:00:00"), group="Backtesting Period")

strategy.initial_capital = 50000

//------------------------------VARIABLES INITIALISATION-----------------------------//

float rsi = ta.rsi(close, rsiLengthInput)
float ma = ma(close, maLenghtInput, maTypeInput)
float roc_ma = ((ma/ma[maLenghtInput]) - 1)*100
float atr = ta.atr(20)
var float trailingStopOffset = na
var float trailingStopActivation = na
var float trailingStop = na
var float stopLoss = na
var bool long = na
var bool short = na
var bool bufferTrailingStopDrawing = na
float theoreticalStopPrice = na
bool inRange = na
equity = strategy.equity - strategy.openprofit
var float capital_ref = strategy.initial_capital
var float cashOrder = strategy.initial_capital * 0.95


//------------------------------CHECKING SOME CONDITIONS ON EACH SCRIPT EXECUTION-------------------------------//

//Checking if the date belong to the range
inRange := true

//Checking performances of the strategy
if equity > capital_ref + fixedRatio
    spread = (equity - capital_ref)/fixedRatio
    nb_level = int(spread)
    increasingOrder = nb_level * increasingOrderAmount
    cashOrder := cashOrder + increasingOrder
    capital_ref := capital_ref + nb_level*fixedRatio
if equity < capital_ref - fixedRatio
    spread = (capital_ref - equity)/fixedRatio
    nb_level = int(spread)
    decreasingOrder = nb_level * increasingOrderAmount
    cashOrder := cashOrder - decreasingOrder
    capital_ref := capital_ref - nb_level*fixedRatio

//Checking if we close all trades in case where we exit the backtesting period
if strategy.position_size!=0 and not inRange
    debugLabel("END OF BACKTESTING PERIOD : we close the trade", color=color.rgb(116, 116, 116))
    strategy.close_all()
    bufferTrailingStopDrawing := false
    stopLoss := na
    trailingStopActivation := na
    trailingStop := na
    short := false
    long := false


//------------------------------STOP LOSS AND TRAILING STOP ACTIVATION----------------------------//

// We handle the stop loss and trailing stop activation 
if (low <= stopLoss or high >= trailingStopActivation) and long
    if high >= trailingStopActivation
        bufferTrailingStopDrawing := true
    else if low <= stopLoss
        long := false
    stopLoss := na
    trailingStopActivation := na
if (low <= trailingStopActivation or high >= stopLoss) and short
    if low <= trailingStopActivation
        bufferTrailingStopDrawing := true
    else if high >= stopLoss
        short := false
    stopLoss := na
    trailingStopActivation := na


//-------------------------------------TRAILING STOP--------------------------------------//

// If the traling stop is activated, we manage its plotting with the bufferTrailingStopDrawing
if bufferTrailingStopDrawing and long
    theoreticalStopPrice := high - trailingStopOffset * syminfo.mintick
    if na(trailingStop)
        trailingStop := theoreticalStopPrice
    else if theoreticalStopPrice > trailingStop
        trailingStop := theoreticalStopPrice
    else if low <= trailingStop
        trailingStop := na
        bufferTrailingStopDrawing := false
        long := false
if bufferTrailingStopDrawing and short
    theoreticalStopPrice := low + trailingStopOffset * syminfo.mintick
    if na(trailingStop)
        trailingStop := theoreticalStopPrice
    else if theoreticalStopPrice < trailingStop
        trailingStop := theoreticalStopPrice
    else if high >= trailingStop
        trailingStop := na
        bufferTrailingStopDrawing := false
        short := false


//---------------------------------LONG CONDITION--------------------------//

if rsi >= 60 and roc_ma <= rocMovAverLongSignalValue and inRange and not long
    if short
        bufferTrailingStopDrawing := false
        stopLoss := na
        trailingStopActivation := na
        trailingStop := na
        short := false
    trailingStopActivation := close + takeProfitActivationInput*atr
    trailingStopOffset := (trailingStopActivation * trailingStopInput/100) / syminfo.mintick
    stopLoss := close - 3*atr
    long := true
    qty = cashOrder/close
    strategy.entry("Long", strategy.long, qty)
    strategy.exit("Exit Long", "Long", stop = stopLoss, trail_price = trailingStopActivation,
                 trail_offset = trailingStopOffset)


//--------------------------------SHORT CONDITION-------------------------------//

if rsi <= 40 and roc_ma >= rocMovAverShortSignalValue and inRange and not short
    if long
        bufferTrailingStopDrawing := false
        stopLoss := na
        trailingStopActivation := na
        trailingStop := na
        long := false
    trailingStopActivation := close - takeProfitActivationInput*atr
    trailingStopOffset := (trailingStopActivation * trailingStopInput/100) / syminfo.mintick
    stopLoss := close + 3*atr
    short := true
    qty = cashOrder/close
    strategy.entry("Short", strategy.short, qty)
    strategy.exit("Exit Short", "Short", stop = stopLoss, trail_price = trailingStopActivation,
                 trail_offset = trailingStopOffset)


//--------------------------------PLOTTING ELEMENT---------------------------------//

// Plotting of element in the graph
plotchar(rsi, "RSI", "", location.top, color.rgb(0, 214, 243))
plot(ma, "MA", color.rgb(219, 219, 18))
plotchar(roc_ma, "ROC MA", "", location.top, color=color.orange)
// Visualizer trailing stop and stop loss movement
plot(stopLoss, "SL", color.red, 3, plot.style_linebr)
plot(trailingStopActivation, "Trigger Trail", color.green, 3, plot.style_linebr)
plot(trailingStop, "Trailing Stop",  color.blue, 3, plot.style_linebr)


আরো