رینج توڑ دوہری منتقل اوسط فلٹرنگ کی حکمت عملی

مصنف:چاؤ ژانگ، تاریخ: 2023-11-27 17:03:08
ٹیگز:

img

جائزہ

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

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

حکمت عملی میں مندرجہ ذیل اہم حصے شامل ہیں:

  1. رجحان کا فیصلہ: قیمت کے رجحان کا فیصلہ کرنے اور تیزی اور کمی کے رجحانات میں فرق کرنے کے لئے ایم اے سی ڈی کا استعمال کریں۔

  2. رینج فلٹرنگ: قیمتوں میں اتار چڑھاؤ کی حد کا فیصلہ کرنے کے لئے بولنگر بینڈ کا استعمال کریں اور ان سگنلز کو فلٹر کریں جو رینج کو نہیں توڑتے ہیں۔

  3. دوہری حرکت پذیر اوسط کی تصدیق: تیز EMA اور سست EMA رجحان سگنلز کی تصدیق کے لئے دوہری حرکت پذیر اوسط تشکیل دیتے ہیں۔ خریدنے کے سگنل صرف اس وقت پیدا ہوتے ہیں جب تیز EMA > سست EMA۔

  4. اسٹاپ نقصان کا طریقہ کار: اسٹاپ نقصان کے مقامات مرتب کریں۔ جب قیمتیں غیر موافق سمتوں میں اسٹاپ نقصان کے مقامات سے گزرتی ہیں تو پوزیشن بند کردیں۔

انٹری سگنلز کے لئے منطق یہ ہے:

  1. ایم اے سی ڈی نے بڑھتی ہوئی رجحان کا جائزہ لیا
  2. قیمت بولنگر بینڈز کے اوپری ریل سے گزرتی ہے
  3. تیز EMA سست EMA سے زیادہ ہے

جب تینوں شرائط ایک ہی وقت میں پوری ہوجاتی ہیں تو ، خریدنے کا اشارہ پیدا ہوتا ہے۔

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

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

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

  1. کم ٹریس بیک کے ساتھ بروقت انداز میں رجحان کی تبدیلیوں کو پکڑ سکتے ہیں.
  2. دوہری حرکت پذیر اوسط کے ساتھ فلٹرنگ کی طرف سے جھوٹے سگنل کو کم کریں، سگنل کی کیفیت کو بہتر بنائیں.
  3. سٹاپ نقصان کا طریقہ کار مؤثر طریقے سے واحد نقصان کو کنٹرول کرتا ہے۔
  4. بڑی پیرامیٹر اصلاح کی جگہ ہے جو زیادہ سے زیادہ حالت میں ایڈجسٹ کیا جا سکتا ہے.

خطرے کا تجزیہ

اس حکمت عملی میں کچھ خطرات بھی ہیں:

  1. ضمنی بازاروں میں پیدا ہونے والے غلط سگنل نقصانات کا باعث بن سکتے ہیں۔
  2. سٹاپ نقصانات کی غلط ترتیب سے غیر ضروری نقصانات ہو سکتے ہیں۔
  3. نامناسب پیرامیٹرز کی وجہ سے حکمت عملی کی کارکردگی خراب ہوسکتی ہے۔

ان خطرات سے نمٹنے کے لئے، حکمت عملی پیرامیٹرز کو ایڈجسٹ کرنے، سٹاپ نقصان کی پوزیشنوں کو قائم کرنے، وغیرہ کی طرف سے بہتر بنایا جا سکتا ہے.

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

حکمت عملی کو مندرجہ ذیل پہلوؤں میں بہتر بنایا جاسکتا ہے:

  1. دوہری چلتی اوسط لمبائی کو بہتر پیرامیٹر مجموعہ تلاش کرنے کے لئے ایڈجسٹ کریں.
  2. مختلف سٹاپ نقصان کے طریقوں کی جانچ کریں، جیسے ٹریلنگ سٹاپ نقصان، آسکیلنگ سٹاپ نقصان وغیرہ.
  3. بہترین ترتیبات تلاش کرنے کے لئے MACD پیرامیٹرز کی جانچ کریں.
  4. خودکار پیرامیٹر کی اصلاح کے لئے مشین لرننگ کا استعمال کریں۔
  5. فلٹر سگنلز کو اضافی حالات شامل کریں.

مختلف پیرامیٹرز کی ترتیبات کی جانچ اور واپسی اور شارپ تناسب کا اندازہ کرکے ، حکمت عملی کی بہترین حالت مل سکتی ہے۔

نتیجہ

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


/*backtest
start: 2022-11-20 00:00:00
end: 2023-11-26 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy(title="Range Filter Buy and Sell Strategies", shorttitle="Range Filter Strategies", overlay=true,pyramiding = 5)

// Original Script > @DonovanWall
// Adapted Version > @guikroth
// 
// Updated PineScript to version 5
// Republished by > @tvenn
// Strategizing by > @RonLeigh
//////////////////////////////////////////////////////////////////////////
// Settings for 5min chart, BTCUSDC. For Other coin, change the parameters
//////////////////////////////////////////////////////////////////////////



SS = input.bool(false,"Percentage Take Profit Stop Loss")


longProfitPerc = input.float(title='LongProfit(%)', minval=0.0, step=0.1, defval=1.5) * 0.01

shortProfitPerc = input.float(title='ShortProfit(%)', minval=0.0, step=0.1, defval=1.5) * 0.01


longLossPerc = input.float(title='LongStop(%)', minval=0.0, step=0.1, defval=1.5) * 0.01

shortLossPerc = input.float(title='ShortStop(%)', minval=0.0, step=0.1, defval=1.5) * 0.01


// Color variables
upColor   = color.white
midColor  = #90bff9
downColor = color.blue

// Source
src = input(defval=close, title="Source")

// Sampling Period
// Settings for 5min chart, BTCUSDC. For Other coin, change the paremeters
per = input.int(defval=100, minval=1, title="Sampling Period")

// Range Multiplier
mult = input.float(defval=3.0, minval=0.1, title="Range Multiplier")

// Smooth Average Range
smoothrng(x, t, m) =>
    wper = t * 2 - 1
    avrng = ta.ema(math.abs(x - x[1]), t)
    smoothrng = ta.ema(avrng, wper) * m
    smoothrng
smrng = smoothrng(src, per, mult)

// Range Filter
rngfilt(x, r) =>
    rngfilt = x
    rngfilt := x > nz(rngfilt[1]) ? x - r < nz(rngfilt[1]) ? nz(rngfilt[1]) : x - r : 
       x + r > nz(rngfilt[1]) ? nz(rngfilt[1]) : x + r
    rngfilt
filt = rngfilt(src, smrng)

// Filter Direction
upward = 0.0
upward := filt > filt[1] ? nz(upward[1]) + 1 : filt < filt[1] ? 0 : nz(upward[1])
downward = 0.0
downward := filt < filt[1] ? nz(downward[1]) + 1 : filt > filt[1] ? 0 : nz(downward[1])

// Target Bands
hband = filt + smrng
lband = filt - smrng

// Colors
filtcolor = upward > 0 ? upColor : downward > 0 ? downColor : midColor
barcolor = src > filt and src > src[1] and upward > 0 ? upColor :
   src > filt and src < src[1] and upward > 0 ? upColor : 
   src < filt and src < src[1] and downward > 0 ? downColor : 
   src < filt and src > src[1] and downward > 0 ? downColor : midColor

filtplot = plot(filt, color=filtcolor, linewidth=2, title="Range Filter")

// Target
hbandplot = plot(hband, color=color.new(upColor, 70), title="High Target")
lbandplot = plot(lband, color=color.new(downColor, 70), title="Low Target")

// Fills
fill(hbandplot, filtplot, color=color.new(upColor, 90), title="High Target Range")
fill(lbandplot, filtplot, color=color.new(downColor, 90), title="Low Target Range")

// Bar Color
barcolor(barcolor)

// Break Outs
longCond = bool(na)
shortCond = bool(na)
longCond := src > filt and src > src[1] and upward > 0 or 
   src > filt and src < src[1] and upward > 0
shortCond := src < filt and src < src[1] and downward > 0 or 
   src < filt and src > src[1] and downward > 0

CondIni = 0
CondIni := longCond ? 1 : shortCond ? -1 : CondIni[1]
longCondition = longCond and CondIni[1] == -1
shortCondition = shortCond and CondIni[1] == 1



// alertcondition(longCondition, title="Buy alert on Range Filter", message="Buy alert on Range Filter")
// alertcondition(shortCondition, title="Sell alert on Range Filter", message="Sell alert on Range Filter")
// alertcondition(longCondition or shortCondition, title="Buy and Sell alert on Range Filter", message="Buy and Sell alert on Range Filter")


////////////// 副

sensitivity = input(150, title='Sensitivity')
fastLength = input(20, title='FastEMA Length')
slowLength = input(40, title='SlowEMA Length')
channelLength = input(20, title='BB Channel Length')
multt = input(2.0, title='BB Stdev Multiplier')

DEAD_ZONE = nz(ta.rma(ta.tr(true), 100)) * 3.7

calc_macd(source, fastLength, slowLength) =>
    fastMA = ta.ema(source, fastLength)
    slowMA = ta.ema(source, slowLength)
    fastMA - slowMA

calc_BBUpper(source, length, multt) =>
    basis = ta.sma(source, length)
    dev = multt * ta.stdev(source, length)
    basis + dev

calc_BBLower(source, length, multt) =>
    basis = ta.sma(source, length)
    dev = multt * ta.stdev(source, length)
    basis - dev

t1 = (calc_macd(close, fastLength, slowLength) - calc_macd(close[1], fastLength, slowLength)) * sensitivity

e1 = calc_BBUpper(close, channelLength, multt) - calc_BBLower(close, channelLength, multt)

trendUp = t1 >= 0 ? t1 : 0
trendDown = t1 < 0 ? -1 * t1 : 0

duoad = trendUp > 0 and trendUp > e1

kongad = trendDown > 0 and trendDown > e1



duo =  longCondition and duoad

kong = shortCondition and kongad


//Alerts
plotshape(longCondition  and trendUp > e1 and  trendUp > 0 , title="Buy Signal", text="Buy", textcolor=color.white, style=shape.labelup, size=size.small, location=location.belowbar, color=color.new(#aaaaaa, 20))
plotshape(shortCondition  and trendDown > e1 and  trendDown > 0 , title="Sell Signal", text="Sell", textcolor=color.white, style=shape.labeldown, size=size.small, location=location.abovebar, color=color.new(downColor, 20))




if  longCondition and trendUp > e1 and  trendUp > 0 
    strategy.entry('Long',strategy.long, comment = "buy" )

if  shortCondition and trendDown > e1 and  trendDown > 0 
    strategy.entry('Short',strategy.short, comment = "sell" )




longlimtPrice  = strategy.position_avg_price * (1 + longProfitPerc)
shortlimtPrice = strategy.position_avg_price * (1 - shortProfitPerc)
   
longStopPrice  = strategy.position_avg_price * (1 - longLossPerc)
shortStopPrice = strategy.position_avg_price * (1 + shortLossPerc)



if (strategy.position_size > 0)  and SS == true
    
    strategy.exit(id="Long",comment_profit = "Profit",comment_loss = "StopLoss", stop=longStopPrice,limit = longlimtPrice)
    

if (strategy.position_size < 0)  and SS == true
    
    strategy.exit(id="Short",comment_profit = "Profit",comment_loss = "StopLoss", stop=shortStopPrice,limit = shortlimtPrice)


مزید