RSI رجحان کی پیروی کرنے والی حکمت عملی


تخلیق کی تاریخ: 2023-11-16 15:33:40 آخر میں ترمیم کریں: 2023-11-16 15:33:40
کاپی: 2 کلکس کی تعداد: 832
1
پر توجہ دیں
1617
پیروکار

RSI رجحان کی پیروی کرنے والی حکمت عملی

جائزہ

اس حکمت عملی میں آر ایس آئی اشارے اور وزن والی متحرک اوسط کا امتزاج کیا گیا ہے تاکہ رجحانات کی پیروی کی جاسکے۔ آر ایس آئی 60 سے اوپر جانے پر بیعانہ اور آر ایس آئی 40 سے نیچے جانے پر بیعانہ ، اور اس کے ساتھ ساتھ چلنے والی اوسط کو رجحانات کی شرائط پر پورا اترنے کی ضرورت ہے۔ رجحانات کی پیروی کرنے والے اشارے کے طور پر آر ایس آئی کے 40 ادوار کو اپنانا۔ وزن والی متحرک اوسط مختلف وزنوں کے ذریعہ مختصر مدت کے اتار چڑھاؤ کے اثرات کو کم کرتی ہے۔ حکمت عملی میں ایک ہی وقت میں اسٹاپ نقصان اور متحرک اسٹاپ کو خطرہ پر قابو پانے کے لئے مقرر کیا گیا ہے۔

حکمت عملی کا اصول

یہ حکمت عملی سب سے پہلے آر ایس آئی اور وزن والی حرکت پذیر اوسط کا حساب لگاتی ہے۔ آر ایس آئی کی لمبائی 20 سیکنڈ ہے اور وزن والی حرکت پذیر اوسط کی لمبائی 20 ہے۔ وزن کی ترتیب مختصر مدت کے اتار چڑھاؤ کے اثرات کو کم کرنے کے لئے بڑی ہے۔ جب آر ایس آئی 60 سے زیادہ ہے اور وزن والی حرکت پذیر اوسط میں تبدیلی کی شرح 1٪ سے کم ہے تو ، ایک سے زیادہ آپریشن انجام دیں۔ جب آر ایس آئی 40 سے کم ہے اور وزن والی حرکت پذیر اوسط میں تبدیلی کی شرح 1٪ سے زیادہ ہے تو ، خالی آپریشن انجام دیں۔

زیادہ کھلے کرنے کے بعد ، ایک ہی وقت میں اسٹاپ اور موبائل اسٹاپ آرڈر مرتب کریں گے۔ اسٹاپ نقصان موجودہ قیمت سے 3 گنا اے ٹی آر ہے۔ موبائل اسٹاپ ابتدائی طور پر قیمت کو موجودہ قیمت سے 4 گنا اے ٹی آر سے چالو کرتا ہے ، اور پھر 3٪ کی حد تک منتقل ہوتا ہے۔ جب قیمت اسٹاپ نقصان یا موبائل اسٹاپ کو چالو کرنے کی قیمت کو چھوتی ہے تو ، متعلقہ پوزیشن بند کردی جاتی ہے۔

اس حکمت عملی میں فنڈ مینجمنٹ کے قواعد بھی شامل ہیں ، جس میں فکسڈ تناسب کے ذریعہ پوزیشن کو ایڈجسٹ کیا جاتا ہے۔ جب بھی منافع یا نقصان ایک مقررہ رقم تک پہنچ جاتا ہے تو ، تجارت کی ایک مقررہ تعداد میں اضافہ یا کمی ہوتی ہے۔

طاقت کا تجزیہ

  • رجحانات کا اندازہ لگانے کے لئے RSI کا استعمال کریں ، تاکہ رجحانات کو مؤثر طریقے سے ٹریک کیا جاسکے
  • وزن میں لائی جانے والی اوسط مختلف وزنوں کے ذریعہ مختصر مدت کے اتار چڑھاو کے اثرات کو کم کرتی ہے تاکہ اس سے بچایا جاسکے
  • منافع کو زیادہ سے زیادہ کرنے کے لئے موبائل اسٹاپس کا استعمال
  • فکسڈ تناسب فنڈ مینجمنٹ مؤثر طریقے سے خطرے کو کنٹرول

اس حکمت عملی کا مجموعی فائدہ یہ ہے کہ اس میں رجحانات کی پیروی کی جاسکتی ہے ، جبکہ خطرے کو کنٹرول کرنے کے لئے اسٹاپ نقصانات اور موبائل اسٹاپس کا استعمال کیا جاتا ہے ، جس سے مضبوط حالات میں بہتر منافع حاصل کیا جاسکتا ہے۔

خطرے کا تجزیہ

  • RSI اشارے غلط سگنل دے رہے ہیں جو غیر ضروری تجارت کا باعث بن سکتے ہیں
  • اسٹاپ نقصان کو توڑنے یا اسٹاپ قیمتوں کو منتقل کرنے پر اسٹاپ نقصان کا سامنا کرنا پڑتا ہے ، جس سے رجحان کا پیچھا نہیں کیا جاسکتا ہے۔
  • فنڈ مینجمنٹ کے قواعد زیادہ سخت ہوسکتے ہیں اور اس سے زیادہ نقصانات ہوسکتے ہیں

اس حکمت عملی کا بنیادی خطرہ آر ایس آئی اشارے کی وشوسنییتا اور اس بات پر ہے کہ آیا اسٹاپ نقصانات کی نقل و حرکت کی روک تھام کی ترتیب معقول ہے۔ اگر پیرامیٹرز کو غلط طریقے سے ترتیب دیا گیا ہو تو ، اس سے غیر ضروری طور پر کھلی پوزیشن یا برداشت کرنے کی صلاحیت سے زیادہ نقصان ہوسکتا ہے۔ اس کے علاوہ ، اسٹاپ نقصانات یا اسٹاپ قیمتوں کو توڑنے پر روکنے پر مجبور کیا جاسکتا ہے ، اور رجحان کی پیروی جاری رکھنے کا موقع کھو دیتا ہے۔

آر ایس آئی پیرامیٹرز کو بہتر بنانے پر غور کیا جاسکتا ہے ، یا دوسرے اشارے کے ساتھ معاون فیصلے کو تبدیل کیا جاسکتا ہے۔ مختلف اقسام اور اتار چڑھاؤ کے حالات کے مطابق اسٹاپ لمیٹڈ اسٹاپ پیرامیٹرز کو ایڈجسٹ کریں۔ آخر میں ، فنڈ مینجمنٹ کے قواعد کو احتیاط سے ترتیب دیں ، جو خطرہ برداشت کرنے کی صلاحیت سے زیادہ سے زیادہ ہونے سے بچنے کے لئے زیادہ شدت پسند نہیں ہوسکتے ہیں۔

اصلاح کی سمت

  • RSI کے ساتھ مل کر KD، MACD، وغیرہ کے طور پر سگنل کی توثیق کرنے کی کوشش کریں
  • مختلف نسل کی خصوصیات اور اتار چڑھاو کی حد کے مطابق اسٹاپ نقصان کے لئے موبائل اسٹاپ پیرامیٹرز کو بہتر بنائیں
  • فکسڈ حجم ٹریڈنگ، کیلی فارمولہ وغیرہ جیسے دیگر فنڈز مینجمنٹ کے طریقوں کو آزمائیں
  • پوزیشن کھولنے کی شرائط شامل کریں ، جیسے بلین لائن کو توڑنا ، RSI سے انحراف کرنا وغیرہ۔
  • ایک مضبوط رجحان میں اضافی پوزیشن پر غور کرنے کے لئے ایک آؤٹ پٹ قیمت شامل کریں

اس حکمت عملی کو متعدد پہلوؤں سے بہتر بنایا جاسکتا ہے۔ پہلا ، سگنل کی وشوسنییتا کو بہتر بنانے کے لئے دوسرے تکنیکی اشارے کی تلاش کرنا جو RSI اشارے کی معاونت یا تصدیق کرسکیں۔ دوسرا ، اسٹاپ نقصان کے متحرک اسٹاپ پیرامیٹرز کو بہتر بنانا خاص قسم کی خصوصیات کے مطابق بہت ضروری ہے۔ مختلف پیرامیٹرز کی تاریخی اعداد و شمار پر منافع کے اثر کی جانچ کی جاسکتی ہے۔ فنڈ مینجمنٹ کو دیگر اقسام کے طریقوں میں بھی ایڈجسٹ کیا جاسکتا ہے۔ آخر میں ، پوزیشن کھولنے اور پوزیشن بڑھانے کے حالات کو مزید بہتر بنایا جاسکتا ہے ، جب رجحان مضبوط ہوتا ہے تو پوزیشن میں مناسب اضافہ ہوتا ہے۔

خلاصہ کریں۔

آر ایس آئی ٹرینڈ ٹریکنگ حکمت عملی کا مجموعی نظریہ واضح ہے ، اس کا بنیادی مقصد آر ایس آئی کا استعمال کرتے ہوئے رجحان کی سمت کا تعین کرنا ہے ، اور اس کی درستگی کو بڑھانے کے لئے منتقل اوسط کو بڑھانا ہے۔ حکمت عملی کا فائدہ یہ ہے کہ رجحان کو ٹریک کیا جاسکے اور منافع کو زیادہ سے زیادہ لاک کیا جاسکے ، جبکہ خطرے کو کنٹرول کرنے کے لئے اسٹاپ نقصان اور فنڈ مینجمنٹ بھی ترتیب دی گئی ہے۔ تاہم ، آر ایس آئی اشارے کی کم وشوسنییتا اور پیرامیٹرز کی ترتیب میں اصلاح کی گنجائش ہے۔ ہم اسٹاپ سگنل اشارے ، نقصان کے متحرک اسٹاپ پیرامیٹرز اور فنڈ مینجمنٹ کے طریقوں کو بہتر بنانے کے لئے شروع کرسکتے ہیں ، تاکہ حکمت عملی مختلف اقسام کے لئے موزوں ہو اور بہتر نتائج حاصل کریں۔

||

Overview

This strategy combines the RSI indicator and weighted moving average for trend following trading. It goes long when RSI is above 60 and goes short when RSI is below 40, with the moving average verifying the trend condition. The 40-period RSI acts as a trend following indicator. The weighted moving average uses different weights to reduce the impact of short-term fluctuations. The strategy also employs stop loss and trailing take profit to control risks.

Strategy Logic

The strategy firstly calculates the RSI and weighted moving average. The RSI length is 20 periods and the weighted MA length is 20 with higher weights that reduce the impact of short-term volatility. It goes long when RSI is above 60 and weighted MA rate of change is below -1%. It goes short when RSI is below 40 and weighted MA rate of change is above 1%.

After opening long or short, stop loss and trailing take profit orders are placed simultaneously. The stop loss is set at 3 ATR from the current price. The initial trailing take profit activation is 4 ATR away, and trails in 3% increments. When price hits either stop loss or trailing take profit activation, the position will be closed.

The strategy also incorporates money management rules based on the fixed fractional position sizing approach. Whenever PNL hits a fixed amount, the order size is increased or decreased by a fixed amount.

Advantage Analysis

  • RSI indicator can effectively track trends
  • Weighted MA reduces the impact of short-term fluctuations, avoiding whipsaws
  • Trailing take profit allows profits to be maximized
  • Fixed fraction position sizing controls risk effectively

The overall edge is the ability to follow trends, while taking stop loss and trailing take profit measures to control risks, thus capturing significant gains in strong trends.

Risk Analysis

  • False signals from RSI may cause unnecessary trades
  • Forced to stop out when price breaches stop or trailing take profit levels, unable to keep following trends
  • Aggressive money management rules may lead to large losses

The main risks come from the reliability of RSI signals and the stop loss/trailing take profit settings. Incorrect parameters may result in unnecessary closing of trades or losses beyond risk appetite. Breaking stop loss/take profit may also force unwarranted stop outs, losing the chance to continue trend trading.

Solutions include optimizing RSI parameters or adding other indicators for signal confirmation. Adjust stop/trailing take profit levels based on different products and volatility conditions. Also be prudent with money management rules to avoid excessive risks.

Optimization Directions

  • Test other indicators together with RSI for signal confirmation, e.g. KD, MACD etc
  • Optimize stop loss and trailing take profit parameters based on product characteristics and volatility range
  • Try other money management techniques like fixed size trading, Kelly formula etc
  • Add entry conditions like Bollinger breakouts, RSI divergences etc
  • Consider adding positions on strong trends

There are many aspects to optimize. First is identifying other indicators to supplement RSI signals. Next critical step is optimizing stop loss/trailing take profit parameters based on historical performance. Money management can also switch to other types. Finally, entry, add-on conditions can be enhanced to pyramiding positions in strong trends.

Summary

The RSI trend following strategy has clear logic, using RSI for trend direction and weighted MA for confirmation. Its strength lies in trend trading, maximizing profits with stops/money management controlling risks. But RSI reliability and parameter optimization need improvement. We can look into enhancing signal indicators, stop/trailing parameters, money management methods etc to make the strategy more robust across different products.

[/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)