
اس حکمت عملی کا بنیادی خیال یہ ہے کہ داخلے کے نقطہ کو بے ترتیب تعداد کے ذریعہ طے کیا جائے ، جس میں ہر تجارت پر منافع کو کنٹرول کرنے کے لئے خطرے کا انتظام کرنے کے لئے تین اسٹاپ پوائنٹس اور ایک اسٹاپ نقصان کا انتظام کیا جائے۔
اس حکمت عملی کا استعمال کرتے ہوئے بے ترتیب تعدادrd_number_entry 11 اور 13 کے درمیان زیادہ داخلے کے پوائنٹس کا فیصلہ کرنے کے لئے، اور 20 اور 22 کے درمیان rd_number_exit کا استعمال کرتے ہوئے خالی پوزیشن کا فیصلہ کرنے کے لئے. زیادہ کرنے کے بعد اسٹاپ نقصان کو داخلہ کی قیمت کے طور پر کم کر دیا گیا ہےatr(14) * slx。 ساتھ ہی ساتھ تین اسٹاپ پوائنٹس قائم کیے گئے ہیں ، پہلا اسٹاپ پوائنٹ داخلہ کی قیمت کے لئے شامل کیا گیا ہےatr(14) * tpx ، دوسرا اسٹاپ پوائنٹ داخلہ کی قیمت کے لئے شامل کیا گیا ہے 2 * tpx ، اور تیسرا اسٹاپ پوائنٹ داخلہ کی قیمت کے لئے شامل کیا گیا ہے 3 * tpx。 خالی کرنے کے اسی طرح کے اصول ، فرق یہ ہے کہ داخلے کا فیصلہ rd_number_entry پر مختلف اقدار لینے کے لئے کیا گیا تھا ، اسٹاپ نقصان کی سمت مخالف تھی۔
اس حکمت عملی کو tpx () اور slx () کو ایڈجسٹ کرکے خطرے کو کنٹرول کیا جاسکتا ہے۔
یہ حکمت عملی مندرجہ ذیل فوائد رکھتی ہے:
اس حکمت عملی میں مندرجہ ذیل خطرات بھی ہیں:
سٹاپ اسٹاپ نقصان فیکٹر کو ایڈجسٹ کرکے اور بے ترتیب انٹری منطق کو بہتر بنا کر خطرے کو کم کیا جاسکتا ہے۔
اس حکمت عملی کو مندرجہ ذیل پہلوؤں سے بہتر بنایا جاسکتا ہے:
یہ حکمت عملی بے ترتیب اندراج پر مبنی ہے ، جس میں متعدد اسٹاپ اسٹاپ پوائنٹس ہیں جو ایک ہی تجارت کے خطرے کو کنٹرول کرتے ہیں۔ چونکہ بے ترتیب ہونے کی وجہ سے منحرف فٹ ہونے کا امکان کم ہوجاتا ہے ، پیرامیٹرز کی اصلاح کے ذریعہ تجارت کے خطرے کو کم کیا جاسکتا ہے۔ اس کے بعد کی اصلاح کی گنجائش بہت زیادہ ہے ، اور اس پر مزید تحقیق کرنے کے قابل ہے۔
/*backtest
start: 2023-12-01 00:00:00
end: 2023-12-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy("Random Strategy with 3 TP levels and SL", overlay=true,max_bars_back = 50)
tpx = input(defval = 0.8, title = 'Atr multiplication for TPs?')
slx = input(defval = 1.2, title = 'Atr multiplication for SL?')
isLong = false
isLong := nz(isLong[1])
isShort = false
isShort := nz(isShort[1])
entryPrice = 0.0
entryPrice := nz(entryPrice[1])
tp1 = true
tp1 := nz(tp1[1])
tp2 = true
tp2 := nz(tp2[1])
sl_price = 3213.0
sl_price := nz(sl_price[1])
sl_atr = atr(14)*slx
tp_atr = atr(14)*tpx
rd_number_entry = 1.0
rd_number_entry := (16708 * nz(rd_number_entry[1], 1) % 2147483647)%17
rd_number_exit = 1.0
rd_number_exit := ((16708 * time % 2147483647) %17)
//plot(rd_number_entry)
shortCondition = (rd_number_entry == 13? true:false) and (year >= 2017) and not isLong and not isShort
longCondition = (rd_number_entry == 11 ? true:false) and (year >= 2017) and not isShort and not isShort
//Never exits a trade:
exitLong = (rd_number_exit == 22?true:false) and (year >= 2018) and not isShort
exitShort = (rd_number_exit == 22?true:false) and (year >= 2018) and not isLong
//shortCondition = crossunder(sma(close, 14), sma(close, 28)) and year >= 2017
//longCondition = crossover(sma(close, 14), sma(close, 28)) and year >= 2017
//exitLong = crossunder(ema(close, 14), ema(close, 28)) and year >= 2017
//exitShort = crossover(ema(close, 14), ema(close, 28)) and year >= 2017
if (longCondition and not isLong)
strategy.entry('Long1', strategy.long)
strategy.entry('Long2', strategy.long)
strategy.entry('Long3', strategy.long)
isLong := true
entryPrice := close
isShort := false
tp1 := false
tp2 := false
sl_price := close-sl_atr
if (shortCondition and not isShort)
strategy.entry('Short1', strategy.short)
strategy.entry('Short2', strategy.short)
strategy.entry('Short3', strategy.short)
isShort := true
entryPrice := close
isLong := false
tp1 := false
tp2 := false
sl_price := close+sl_atr
if (exitShort and isShort)
strategy.close('Short1')
strategy.close('Short2')
strategy.close('Short3')
isShort := false
if (exitLong and isLong)
strategy.close('Long1')
strategy.close('Long2')
strategy.close('Long3')
isLong := false
if isLong
if (close > entryPrice + tp_atr) and not tp1
strategy.close('Long1')
tp1 := true
sl_price := close - tp_atr
if (close > entryPrice + 2*tp_atr) and not tp2
strategy.close('Long2')
tp2 := true
sl_price := close - tp_atr
if (close > entryPrice + 3*tp_atr)
strategy.close('Long3')
isLong := false
if (close < sl_price)
strategy.close('Long1')
strategy.close('Long2')
strategy.close('Long3')
isLong := false
if isShort
if (close < entryPrice - tp_atr) and not tp1
strategy.close('Short1')
sl_price := close + tp_atr
tp1 := true
if (close < entryPrice - 2*tp_atr) and not tp2
strategy.close('Short2')
sl_price := close + tp_atr
tp2 := true
if (close < entryPrice - 3*tp_atr)
strategy.close('Short3')
isShort := false
if (close > sl_price)
strategy.close('Short1')
strategy.close('Short2')
strategy.close('Short3')
isShort := false
plot(atr(14)*slx)
plot(sl_price)