
نیند کی حد کی واپسی کی حکمت عملی کم قیمت کی اتار چڑھاؤ کی مدت کو ایک پوزیشن سازی سگنل کے طور پر استعمال کرتی ہے اور جب قیمت کی اتار چڑھاؤ دوبارہ بڑھتی ہے تو منافع کی پوزیشن حاصل کرتی ہے۔ یہ قیمتوں کے قریب آنے والے ٹرینڈ کو پکڑنے کے لئے اس صورت حال کی نشاندہی کرتی ہے جب قیمتوں میں ایک تنگ اتار چڑھاؤ کی نیند کی حد تک محدود ہے۔ یہ حکمت عملی عام طور پر اس وقت ہوتی ہے جب موجودہ اتار چڑھاؤ کی سطح کم ہوتی ہے ، لیکن مستقبل میں ہونے والے دھماکے کے امکان پر لاگو ہوتی ہے۔
اس حکمت عملی نے سب سے پہلے ایک نیند کی حد کی نشاندہی کی ، یعنی یہ کہ قیمت پچھلے ٹریڈنگ دن کی قیمت کی حد کے اندر محدود ہے۔ اس سے ظاہر ہوتا ہے کہ موجودہ اتار چڑھاؤ کی شرح پچھلے کچھ دنوں میں کم ہوگئی ہے۔ ہم موجودہ ٹریڈنگ دن کی اعلی قیمت کو n دن پہلے (عام طور پر 4 دن) کی اعلی قیمت سے موازنہ کرتے ہیں ، اور موجودہ ٹریڈنگ دن کی کم قیمت کو n دن پہلے کی کم قیمت سے موازنہ کرتے ہیں تاکہ یہ معلوم کیا جاسکے کہ آیا نیند کی حد کی شرائط کو پورا کیا گیا ہے۔
ایک بار جب ایک نیند کی حد کی تصدیق ہوجاتی ہے تو ، اس حکمت عملی میں ایک ہی وقت میں دو لاک لسٹ کھل جاتے ہیں۔ ایک خرید لنگٹ لسٹ رینج کی اونچائی کے قریب رکھا جاتا ہے ، اور ایک بیچ لنگٹ لنگٹ رینج کی نچلی حد کے قریب رکھا جاتا ہے۔ اس کے بعد قیمت کے نیند کی حد کو توڑنے کے لئے انتظار کیا جاتا ہے۔ اگر قیمت اوپر کی طرف بڑھتی ہے تو ، خرید لنگٹ ایک کثیر پوزیشن قائم کرنے کے لئے متحرک ہوجاتی ہے۔ اگر نیچے کی طرف بڑھتی ہے تو ، فروخت لنگٹ خالی پوزیشن قائم کرنے کے لئے متحرک ہوجاتی ہے۔
ایک پوزیشن قائم کرنے کے بعد ، حکمت عملی اسٹاپ نقصان اور اسٹاپ آؤٹ آرڈر کا تعین کرتی ہے۔ اسٹاپ نقصان کا خطرہ کم کرنے کے لئے اسٹاپ آؤٹ آرڈر استعمال کیا جاتا ہے ، اور منافع کے بعد اسٹاپ آؤٹ آرڈر کا استعمال کیا جاتا ہے۔ اسٹاپ نقصان کا آرڈر داخلے کی قیمت سے ایک تناسب فاصلہ ہے ، یہ تناسب رسک مینجمنٹ پیرامیٹرز کے ذریعہ طے کیا گیا ہے۔ اسٹاپ آؤٹ آرڈر داخلے کی قیمت سے زیادہ فاصلے پر ہے۔
آخر میں ، اس حکمت عملی میں فنڈ مینجمنٹ ماڈیول بھی شامل ہے۔ فکسڈ ضرب کے طریقہ کار کے ذریعہ آرڈر ٹریڈنگ فنڈز کی مقدار کو ایڈجسٹ کریں ، منافع بخش ہونے پر فنڈز کے استعمال میں اضافہ کریں ، اور نقصان ہونے پر خطرہ کم کریں۔
اس حکمت عملی کے درج ذیل فوائد ہیں:
کم اتار چڑھاؤ کے اوقات کو پوزیشن کے اشارے کے طور پر استعمال کریں ، تاکہ قیمت کے رجحانات سے پہلے مواقع کو پکڑ سکیں۔
ایک ہی وقت میں، ایک کثیر کھلی دو طرفہ تجارت کے احکامات قائم کریں، جو اوپر یا نیچے کی رجحانات کو پکڑ سکتے ہیں.
اسٹاپ نقصان کی روک تھام کی حکمت عملی کا استعمال کرتے ہوئے ، ایک ہی تجارت کے خطرے کو مؤثر طریقے سے کنٹرول کیا جاسکتا ہے۔
فکسڈ ضرب فنڈ مینجمنٹ کا اطلاق فنڈز کے استعمال کی کارکردگی کو بڑھا سکتا ہے۔
حکمت عملی کی منطق سادہ، واضح اور لاگو کرنے میں آسان ہے۔
اس حکمت عملی کے کچھ خطرات بھی ہیں جن کے بارے میں آگاہ ہونا ضروری ہے:
نیند کی حد کو توڑنے کی سمت کا غلط فیصلہ کرنے کا خطرہ۔ قیمتوں میں ممکنہ طور پر اوپر یا نیچے کی طرف سے کوئی واضح خرابی نہیں ہے ، جس سے داخلے کی سمت میں غلطی پیدا ہوسکتی ہے۔
اس کے بعد ، آپ کو اس خطرے کا سامنا کرنا پڑتا ہے کہ آپ کو راستہ نہیں مل سکے گا۔
اسٹاپ نقصان کو شکست دینے کا خطرہ۔ خاص حالات میں براہ راست اسٹاپ نقصان کی لائن کو توڑ سکتا ہے۔
فکسڈ ضرب قانون ہراساں نقصان کی توسیع کا خطرہ۔ فکسڈ ضرب کی قدر کو کم کرکے خطرہ کم کیا جاسکتا ہے۔
غلط پیرامیٹرز کی ترتیب سے حکمت عملی کا اثر خراب ہوسکتا ہے۔
اس حکمت عملی کو مندرجہ ذیل پہلوؤں سے بہتر بنایا جاسکتا ہے:
غلطیوں سے بچنے کے لئے، فلٹر سگنل کو توڑنے کے لئے اور اس سے بچنے کے لئے.
نقصانات کو روکنے کی حکمت عملی میں بہتری لانا ، مثال کے طور پر ، نقصانات کو روکنے کے ل move منتقل کرنا ، نقصانات کو روکنا وغیرہ۔
رجحانات کو سمجھنے کے لئے اشارے میں اضافہ کریں اور واپسی سے بچیں.
فکسڈ ضرب قدر کو بہتر بنائیں ، منافع اور نقصان کا تناسب متوازن کریں۔
ایک سے زیادہ ٹائم سائیکل تجزیہ کے ساتھ مل کر ، منافع کے امکانات کو بہتر بنائیں۔
مشین سیکھنے کے طریقوں کا استعمال کرتے ہوئے پیرامیٹرز کو خود کار طریقے سے بہتر بنائیں۔
اسٹریٹجک استحکام کو پیرامیٹرز کی اصلاح ، رسک مینجمنٹ ، سگنل فلٹرنگ وغیرہ کے ذریعہ مزید بڑھایا جاسکتا ہے۔ تاہم ، کسی بھی رجحان کی الٹ حکمت عملی میں کچھ خطرہ ہوتا ہے ، اسے احتیاط سے استعمال کرنے اور پوزیشن کی مناسب حد تک ایڈجسٹ کرنے کی ضرورت ہے۔ یہ حکمت عملی ان لوگوں کے لئے موزوں ہے جو الٹ کے ساتھ واقف ہیں اور جو خطرہ سے آگاہ ہیں۔
/*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)