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

مصنف:چاؤ ژانگ، تاریخ: 2023-11-16 15:33:40
ٹیگز:

جائزہ

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

حکمت عملی منطق

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

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

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

فوائد کا تجزیہ

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

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

خطرے کا تجزیہ

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

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

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

اصلاح کی ہدایات

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

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

خلاصہ

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

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


مزید