غیر فعال رینج ریورسنگ کی حکمت عملی

مصنف:چاؤ ژانگ، تاریخ: 2023-10-30 10:54:00
ٹیگز:

img

جائزہ

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

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

حکمت عملی سب سے پہلے ایک غیر فعال رینج کی نشاندہی کرتی ہے ، جو اس وقت ہوتی ہے جب قیمت پچھلے تجارتی دن کی قیمت کی حد میں ہوتی ہے۔ اس سے یہ ظاہر ہوتا ہے کہ چند دن پہلے کے مقابلے میں اتار چڑھاؤ کم ہوگیا ہے۔ ہم چیک کرتے ہیں کہ موجودہ دن کا اعلی < n دن پہلے کا اعلی (عام طور پر 4 دن) اور موجودہ دن کی کم > کم > n دن پہلے کی حد کو غیر فعال رینج کے طور پر اہل بنانے کے ل.

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

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

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

فوائد

اس حکمت عملی کے فوائد یہ ہیں:

  1. سگنل کے طور پر کم اتار چڑھاؤ کا استعمال کرتے ہوئے آنے والے رجحان کو پکڑتا ہے.

  2. دو طرفہ احکامات اپ ٹرینڈ یا ڈاؤن ٹرینڈ کو پکڑتے ہیں۔

  3. سٹاپ نقصان اور منافع لے واحد تجارت کے خطرے کو کنٹرول.

  4. فکسڈ فریکشنل سائزنگ سرمایہ کاری کی کارکردگی کو بہتر بناتی ہے۔

  5. سادہ منطق آسان عملدرآمد.

خطرات

جن خطرات پر غور کیا جانا چاہئے وہ یہ ہیں:

  1. غلط بھاگنے کی سمت اگر رینج بھاگنا واضح نہیں ہے۔

  2. بریکآؤٹ صرف ایک مختصر الٹ ہو سکتا ہے، دیرپا رجحان نہیں.

  3. سٹاپ نقصان کا خطرہ بڑی چالوں کی طرف سے باہر لے جایا جا رہا ہے.

  4. فکسڈ فریکشن سائزنگ نقصانات کو بڑھا سکتی ہے جب نقصان دہ تجارت میں اضافہ ہوتا ہے۔

  5. خراب کارکردگی اگر پیرامیٹرز مناسب طریقے سے مقرر نہیں ہیں.

بہتر مواقع

حکمت عملی کو بہتر بنانے کے کچھ طریقے:

  1. غلط بریک آؤٹ سے بچنے کے لیے متغیر کی طرح فلٹرز شامل کریں۔

  2. ٹرائلنگ یا آرڈر سٹاپ نقصان کے ساتھ سٹاپ نقصان کو بہتر بنائیں.

  3. ٹرینڈ فلٹر شامل کریں تاکہ مخالف ٹرینڈ اندراجات سے بچ سکے۔

  4. متوازن خطرہ / انعام کے لئے فکسڈ فریکشن تناسب کو بہتر بنائیں.

  5. کنارے کو بہتر بنانے کے لئے متعدد ٹائم فریم پر نظر ڈالیں۔

  6. خودکار پیرامیٹر کی اصلاح کے لئے مشین لرننگ کا استعمال کریں.

نتیجہ

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


/*backtest
start: 2023-09-29 00:00:00
end: 2023-10-29 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 the Narrow Range strategy
//Interactive Broker fees are applied on this strategy
//@version=5
strategy("NARROW RANGE BACKTESTING", shorttitle="NR BACKTESTING", overlay=true, initial_capital=1000, default_qty_type=strategy.fixed, commission_type=strategy.commission.percent, commission_value=0.18)


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

//@function to print label
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------------------------------------//

//Narrow Range Length 
nrLength = input.int(4, minval=2, title="Narrow Range Length", group="Strategy parameters")
//Risk Management
stopLossInput = input.float(0.5, title="Stop Loss (in percentage of reference range)", 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 Janv 2020 00:00:00"), group="Backtesting Period")
endDate = input(title="End Date", defval=timestamp("1 July 2024 00:00:00"), group="Backtesting Period")


//--------------------------------VARIABLES INITIALISATION--------------------------//
strategy.initial_capital = 50000
bool nr = na
var bool long = na
var bool short = na
var float stopPriceLong = na
var float stopLossLong = na
var float takeProfitLong = na
var float stopPriceShort = na
var float stopLossShort = na
var float takeProfitShort = na
var float takeProfit = na
var float stopLoss = na
bool inRange = na
int closedtrades = strategy.closedtrades
equity = math.abs(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

//We check if a trade has been closed to cancel all previous orders
if closedtrades > closedtrades[1]
    strategy.cancel("Long")
    strategy.cancel("Short")
    stopPriceLong := na
    stopPriceShort := na

//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()
    long := na
    short := na
    stopPriceLong := na
    stopLossLong := na
    takeProfitLong := na
    stopPriceShort := na
    stopLossShort := na
    takeProfitShort := na
    takeProfit := na
    stopLoss := na

//----------------------------------FINDING NARROW RANGE DAY------------------------------------------//

// We find the Narrow Range Day
if low > low[nrLength] and high < high[nrLength]
    nr := true 


//------------------------------------STOP ORDERS--------------------------------------------//

// We handle plotting of stop orders and cancellation of other side order if one order is triggered
if strategy.position_size > 0 and not na(stopPriceLong) and not na(stopPriceShort)
    long := true
    strategy.cancel("Short")
    stopPriceLong := na
    stopPriceShort := na
    takeProfit := takeProfitLong
    stopLoss := stopLossLong
if strategy.position_size < 0 and not na(stopPriceLong) and not na(stopPriceShort)
    short := true
    strategy.cancel("Long") 
    stopPriceLong := na
    stopPriceShort := na
    takeProfit := takeProfitShort
    stopLoss := stopLossShort


//------------------------------------STOP LOSS & TAKE PROFIT--------------------------------//

// If an order is triggered we plot TP and SL
if not na(takeProfit) and not na(stopLoss) and long
    if high >= takeProfit and closedtrades == closedtrades[1] + 1
        takeProfit := na
        stopLoss := na
        long := na
    if low <= stopLoss and closedtrades == closedtrades[1] + 1
        takeProfit := na
        stopLoss := na
        long := na
if not na(takeProfit) and not na(stopLoss) and short
    if high >= stopLoss and closedtrades == closedtrades[1] + 1
        takeProfit := na
        stopLoss := na
        short := na
    if low <= takeProfit and closedtrades == closedtrades[1] + 1
        takeProfit := na
        stopLoss := na
        short := na


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

// Conditions to create two stop orders (one for Long and one for Short) and SL & TP calculation
if nr and inRange and strategy.position_size == 0
    stopPriceLong := high[4]
    takeProfitLong := high[4] + (high[4] - low[4])
    stopLossLong := high[4] - (high[4] - low[4])*stopLossInput
    qtyLong = cashOrder/stopPriceLong
    strategy.entry("Long", strategy.long, qtyLong, stop=stopPriceLong)
    strategy.exit("Exit Long", "Long", limit=takeProfitLong ,stop=stopLossLong)
    stopPriceShort := low[4]
    takeProfitShort := low[4] - (high[4] - low[4])
    stopLossShort := low[4] + (high[4] - low[4])*stopLossInput
    qtyShort = cashOrder/stopPriceShort
    strategy.entry("Short", strategy.short, qtyShort, stop=stopPriceShort)
    strategy.exit("Exit Short", "Short", limit=takeProfitShort ,stop=stopLossShort)


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

plotshape(nr, "NR", shape.arrowdown, location.abovebar, color.rgb(255, 132, 0), text= "NR4", size=size.huge)
plot(stopPriceLong, "Stop Order", color.blue, 3, plot.style_linebr)
plot(stopPriceShort, "Stop Order", color.blue, 3, plot.style_linebr)
plot(takeProfit, "Take Profit", color.green, 3, plot.style_linebr)
plot(stopLoss, "Stop Loss", color.red, 3, plot.style_linebr)

مزید