ইএইচএমএ রেঞ্জ কৌশল

লেখক:চাওঝাং, তারিখঃ ২০২২-০৫-০৯ ২৩ঃ৩১ঃ৫৯
ট্যাগঃইএইচএমএ

এই স্ক্রিপ্টটি এক্সপোনেনশিয়াল হুল মুভিং এভারেজের জন্য @ বোর্সারম্যানের স্ক্রিপ্টের একটি সংশোধিত সংস্করণ ইএইচএমএর সব কৃতিত্ব তার কাছেই যায়:)

EHMA ছাড়াও, এই স্ক্রিপ্টটি EHMA এর আশেপাশে একটি পরিসীমা নিয়ে কাজ করে (যা সংশোধন করা যেতে পারে), ভুয়া সংকেতগুলির বিরুদ্ধে শক্তিশালী হওয়ার প্রয়াসে। অনেক সময় একটি বার একটি চলমান গড়ের নীচে বন্ধ হবে, কেবলমাত্র পরবর্তী বারটি আবার বিপরীত করতে হবে, যা আপনার লাভকে গ্রাস করে। বিশেষত স্বল্প সময়ের ফ্রেমগুলিতে, তবে আরও দীর্ঘ সময়ের ফ্রেমগুলিতেও এটি কৌশলটি ব্যবহার করতে আকর্ষণীয় হতে পারে।

ইএইচএমএ এর আশেপাশের পরিসরের সাথে, কৌশলটি কেবলমাত্র একটি বার উপরের পরিসরের উপরে অতিক্রম করলে একটি দীর্ঘ / প্রস্থান-সংক্ষিপ্ত অবস্থানে প্রবেশ করে। বিপরীতভাবে, এটি কেবলমাত্র একটি বার নীচের পরিসরের নীচে অতিক্রম করলে একটি সংক্ষিপ্ত / প্রস্থান-দীর্ঘ অবস্থানে প্রবেশ করে। এটি ইএইচএমএ পরিসরের মধ্যে বারগুলি অস্থির আচরণ করে এবং কেবলমাত্র যদি বাজারটি এর দিকনির্দেশে আত্মবিশ্বাসী হয় তবে একটি অবস্থানে প্রবেশ করে। এটি বলেছে যে, জালিয়াতি এখনও সম্ভব, তবে অনেক কম ঘন ঘন। নিয়মিত ইএইচএমএ কৌশলটির তুলনায় এই কৌশলটি ব্যাকটেস্ট করার পরে (এবং বিভিন্ন সেটিংসের সাথে পরীক্ষা করার পরে), এই সংস্করণটি অনেক বেশি শক্তিশালী এবং লাভজনক বলে মনে হচ্ছে!

অস্বীকৃতি দয়া করে মনে রাখবেন যে অতীতের পারফরম্যান্স ভবিষ্যতের ফলাফলের ইঙ্গিত নাও হতে পারে। বিভিন্ন কারণের কারণে, বাজারের পরিবর্তিত পরিস্থিতি সহ, কৌশলটি আর ঐতিহাসিক ব্যাকটেস্টিংয়ের মতো ভাল কাজ করতে পারে না। এই পোস্ট এবং স্ক্রিপ্ট কোন আর্থিক পরামর্শ প্রদান করে না।

ব্যাকটেস্ট

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)
    

সম্পর্কিত

আরো