ای ایچ ایم اے رینج حکمت عملی

مصنف:چاؤ ژانگ، تاریخ: 2022-05-09 23:31:59
ٹیگز:ای ایچ ایم اے

یہ اسکرپٹ @borserman کے اسکرپٹ کا ایک ترمیم شدہ ورژن ہے ایچ ایچ ایم اے کے لئے تمام کریڈٹ اس کے پاس جاتا ہے :)

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

ایچ ایچ ایم اے کے آس پاس کی حد کے ساتھ ، حکمت عملی صرف اس صورت میں لانگ / ایگزٹ شارٹ پوزیشن میں داخل ہوتی ہے جب ایک بار اوپری رینج سے اوپر عبور کرتا ہے۔ اس کے برعکس ، یہ صرف اس صورت میں مختصر / ایگزٹ لانگ پوزیشن میں داخل ہوتا ہے جب ایک بار نچلی رینج سے نیچے عبور کرتا ہے۔ اس سے اگر ایچ ایچ ایم اے رینج کے اندر بار متضاد برتاؤ کرتے ہیں تو پوزیشنوں سے گریز ہوتا ہے اور صرف اس صورت میں پوزیشن میں داخل ہوتا ہے جب مارکیٹ اس کی سمت پر اعتماد کرتی ہے۔ اس کے بعد ، جعلی آؤٹ اب بھی ممکن ہیں ، لیکن بہت کم کثرت سے۔ باقاعدہ ایچ ایچ ایم اے کے مقابلے میں اس حکمت عملی کا بیک ٹیسٹ کرنے کے بعد (اور مختلف ترتیبات کے ساتھ تجربہ کرنے کے بعد) ، یہ ورژن بہت زیادہ مضبوط اور منافع بخش معلوم ہوتا ہے!

دستبرداری براہ کرم یاد رکھیں کہ ماضی کی کارکردگی مستقبل کے نتائج کا اشارہ نہیں ہوسکتی ہے۔ مختلف عوامل کی وجہ سے ، بشمول مارکیٹ کے بدلتے ہوئے حالات ، حکمت عملی اب اتنی اچھی کارکردگی کا مظاہرہ نہیں کرسکتی ہے جتنی کہ تاریخی بیک ٹسٹنگ میں ہے۔ یہ پوسٹ اور اسکرپٹ کوئی مالی مشورہ فراہم نہیں کرتے.

بیک ٹسٹ

img


/*backtest
start: 2021-05-08 00:00:00
end: 2022-05-07 23:59:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// Credit is due where credit is due:
// Hull Moving Average: developed by Alan Hull
// EHMA: coded by Twitter @borserman
// I've built on their work in an attempt to create a strategy more robust to fake moves
// @0xLetoII

//@version=4
//strategy(
//  title="EHMA Range Strategy",
//  process_orders_on_close=true,
//  explicit_plot_zorder=true,
//  overlay=true, 
//  initial_capital=1500, 
//  default_qty_type=strategy.percent_of_equity, 
//  commission_type=strategy.commission.percent, 
//  commission_value=0.085,
//  default_qty_value=100
//  )
  

// Position Type
pos_type = input(defval = "Both", title="Position Type", options=["Both", "Long", "Short"])

// Inputs
Period = input(defval=180, title="Length")
RangeWidth = input(defval=0.02, step=0.01, title="Range Width")
sqrtPeriod = sqrt(Period)

// Function for the Borserman EMA
borserman_ema(x, y) =>
    alpha = 2 / (y + 1)
    sum = 0.0
    sum := alpha * x + (1 - alpha) * nz(sum[1])

// Calculate the Exponential Hull Moving Average
EHMA = borserman_ema(2 * borserman_ema(close, Period / 2) - borserman_ema(close, Period), sqrtPeriod)

// Create upper & lower bounds around the EHMA for broader entries & exits
upper = EHMA + (EHMA * RangeWidth)
lower = EHMA - (EHMA * RangeWidth)

// Plots
EHMAcolor = (close > EHMA ? color.green : color.red)
plot(EHMA, color=EHMAcolor, linewidth=2)
plot(lower, color=color.orange, linewidth=2)
plot(upper, color=color.blue, linewidth=2)


// Strategy
long = close > upper
exit_long = close < lower
short = close < lower
exit_short = close > upper


// Calculate start/end date and time condition
//startDate  = input(timestamp("2017-01-01T00:00:00"))
//finishDate = input(timestamp("2029-01-01T00:00:00"))
 
time_cond  = true


// Entries & Exits
if pos_type == "Both"
    strategy.entry("Long", strategy.long, comment="Long", when=long and time_cond)
    strategy.close("Long", comment="Exit Long", when=exit_long and time_cond)
    strategy.entry("Short", strategy.short, comment="Short", when=short and time_cond)
    strategy.close("Short", comment="Exit Short", when=exit_short and time_cond)
if pos_type == "Long"
    strategy.entry("Long", strategy.long, comment="Long", when=long and time_cond)
    strategy.close("Long", comment="Exit Long", when=exit_long and time_cond)
if pos_type == "Short"
    strategy.entry("Short", strategy.short, comment="Short", when=short and time_cond)
    strategy.close("Short", comment="Exit Short", when=exit_short and time_cond)
    

متعلقہ

مزید