ডুয়াল-ডাইরেকশন প্রাইস ব্রেকথ্রু মুভিং এভারেজ টাইমিং ট্রেডিং স্ট্র্যাটেজি

লেখক:চাওঝাং, তারিখ: ২০২৩-১২-১৫ 16:28:12
ট্যাগঃ

img

সারসংক্ষেপ

ডুয়াল ডাইরেকশন প্রাইস ব্রেকথ্রু মুভিং এভারেজ টাইমিং ট্রেডিং কৌশল একটি পরিমাণগত ট্রেডিং কৌশল যা ট্রেডিং সিগন্যাল নির্ধারণের জন্য মুভিং এভারেজের দামের ব্রেকথ্রু ব্যবহার করে। এটি নির্দিষ্ট সময়ের চলমান গড়ের সাথে দামের তুলনা করে এবং যখন দাম চলমান গড়ের মধ্য দিয়ে ভেঙে যায় তখন ট্রেডিং সিগন্যাল তৈরি করে।

কৌশলগত যুক্তি

এই কৌশলটির মূল যুক্তি হল:

  1. EMA ফাংশন ব্যবহার করে নির্দিষ্ট সময়ের (যেমন 200 দিন) চলমান গড় (EMA) গণনা করুন।

  2. মূল্য EMA এর মাধ্যমে ভেঙে যায় কিনা তা নির্ধারণ করতে EMA এর সাথে বন্ধ মূল্যের তুলনা করুন। বিশেষত, যখন বন্ধ মূল্য EMA এর উপরে থাকে, তখন দাম EMA এর মাধ্যমে ভেঙে যায়; যখন বন্ধ মূল্য EMA এর নীচে থাকে, তখন দাম EMA এর মাধ্যমে ভেঙে যায়।

  3. লং এবং শর্ট সিগন্যাল নির্ধারণ করুন। যখন দাম EMA এর মাধ্যমে ভেঙে যায়, তখন লং সিগন্যাল তৈরি করুন; যখন দাম EMA এর মাধ্যমে ভেঙে যায়, তখন শর্ট সিগন্যাল তৈরি করুন।

  4. যখন সিগন্যালটি ট্রিগার করা হয়, নির্দিষ্ট শতাংশ (যেমন 100%) দিয়ে অর্ডার দিন এবং স্টপ লস এবং লাভের দাম সেট করুন।

  5. যখন স্টপ লস বা লাভ নেওয়ার মূল্য স্পর্শ করা হয়, অবস্থান বন্ধ করুন।

  6. চলমান গড়ের মধ্য দিয়ে মূল্য ভাঙ্গার সময় থেকে লাভ করার জন্য প্রক্রিয়াটি পুনরাবৃত্তি করুন।

কৌশলটি সহজ এবং সহজেই বোঝা এবং বাস্তবায়ন করা যায়। এটি চলমান গড়ের মাধ্যমে ভাঙ্গার সংকেত দ্বারা স্বল্পমেয়াদী গতি ধরে রাখার লক্ষ্য রাখে। তবে এর কিছু বিলম্ব এবং হুইপস ঝুঁকিও রয়েছে।

সুবিধা

  • সহজ এবং পরিষ্কার যুক্তি, সহজেই বোঝা যায় এবং যাচাই করা যায়।
  • চলমান গড়ের বৈশিষ্ট্য ব্যবহার করে মসৃণ ট্র্যাকিং ক্ষমতা।
  • উচ্চ ট্রেডিং ফ্রিকোয়েন্সি, স্বল্পমেয়াদী ট্রেডিং জন্য উপযুক্ত।
  • দামের পরিবর্তনে দ্রুত প্রতিক্রিয়া, সঠিক সময় ধরা।

ঝুঁকি

  • নির্দিষ্ট স্তরের বিলম্বের কারণে, দামের প্রাথমিক অগ্রগতি মিস হতে পারে।
  • প্রায়ই ট্রেডিং যখন একাধিকবার whipsawed.
  • তীব্র বিপরীতমুখী ঘটনায় থামার ঝুঁকি।

অপ্টিমাইজেশান পদ্ধতিগুলির মধ্যে প্যারামিটার টিউনিং, আরও কার্যকর সূচক ব্যবহার, ট্রেডিং ফ্রিকোয়েন্সি হ্রাস ইত্যাদি অন্তর্ভুক্ত রয়েছে। অভিযোজিত স্টপ এবং ফিল্টারিং শর্তগুলিও ঝুঁকি নিয়ন্ত্রণ করতে পারে।

অপ্টিমাইজেশান নির্দেশাবলী

  • আরও ভাল সমাধানের জন্য বিভিন্ন ধরণের এবং চলমান গড়ের পরামিতি পরীক্ষা করুন, যেমন EMA, SMA, LWMA।
  • হুইপসা ট্রেড এড়াতে ফিল্টারিং শর্ত যোগ করুন, যেমন ভলিউম, বোলিংজার ব্যান্ড, এটিআর ইত্যাদি।
  • ঝুঁকি কমানোর জন্য স্টপ লস এবং মুনাফা কৌশল অপ্টিমাইজ এবং পরীক্ষা করুন।
  • একটি শক্তিশালী ট্রেডিং সিস্টেমের জন্য ট্রেন্ড অনুসরণ, গড় বিপরীত এবং অন্যান্য কৌশল একত্রিত করুন।
  • আরও বিস্তৃত অভিযোজনযোগ্যতার জন্য প্যারামিটারাইজেশন যুক্ত করুন।

সিদ্ধান্ত

কৌশলটি স্বল্পমেয়াদী গতি ধরে রাখার জন্য চলমান গড়ের ট্র্যাকিংয়ের তুলনামূলকভাবে সহজ যুক্তি রয়েছে। সুবিধাগুলির মধ্যে প্রতিক্রিয়াশীলতা এবং ব্যবহারের সহজতা অন্তর্ভুক্ত রয়েছে; অসুবিধাগুলিতে বিলম্ব এবং ইনার্শিয়া অন্তর্ভুক্ত রয়েছে। সূচক নির্বাচন, স্টপ লস প্রক্রিয়া, ফিল্টারিং কৌশলগুলি আরও শক্ত এবং বিস্তৃত করার জন্য আরও অপ্টিমাইজেশন করা যেতে পারে।


/*backtest
start: 2022-12-08 00:00:00
end: 2023-12-14 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/

// Credits to the original Script - Range Filter DonovanWall https://www.tradingview.com/script/lut7sBgG-Range-Filter-DW/
// This version is the old version of the Range Filter with less settings to tinker with

//@version=5
strategy(title='Range Filter - B&S Signals', shorttitle='RF - B&S Signals', initial_capital=1000, currency=currency.GBP, default_qty_value=100, default_qty_type=strategy.percent_of_equity, commission_type=strategy.commission.percent, commission_value=0.075, overlay=true)


i_startTime = input(defval=timestamp('01 Jan 2020 12:00 +0000'), title='Backtest Start')
i_endTime = input(defval=timestamp('01 Jan 2024 12:00 +0000'), title='Backtest End')

inDateRange     = true
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Functions
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
longLossPerc = input.float(title='Long Stop Loss (%)', minval=0.0, step=0.1, defval=1) * 0.01
shortLossPerc = input.float(title='Short Stop Loss (%)', minval=0.0, step=0.1, defval=1) * 0.01

longTakePerc = input.float(title='Long Take(%)', minval=0.0, step=0.1, defval=1) * 0.01
shortTakePerc = input.float(title='Short Take (%)', minval=0.0, step=0.1, defval=1) * 0.01

emaLength = input.int(200, title="EMA Length")

    // Determine stop loss price

//Range Size Function
rng_size(x, qty, n) =>
//    AC       = Cond_EMA(abs(x - x[1]), 1, n)
    wper = n * 2 - 1
    avrng = ta.ema(math.abs(x - x[1]), n)
    AC = ta.ema(avrng, wper) * qty
    rng_size = AC
    rng_size

//Range Filter Function
rng_filt(x, rng_, n) =>
    r = rng_
    var rfilt = array.new_float(2, x)
    array.set(rfilt, 1, array.get(rfilt, 0))
    if x - r > array.get(rfilt, 1)
        array.set(rfilt, 0, x - r)
    if x + r < array.get(rfilt, 1)
        array.set(rfilt, 0, x + r)
    rng_filt1 = array.get(rfilt, 0)

    hi_band = rng_filt1 + r
    lo_band = rng_filt1 - r
    rng_filt = rng_filt1
    [hi_band, lo_band, rng_filt]

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Inputs
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------

//Range Source
rng_src = input(defval=close, title='Swing Source')

//Range Period
rng_per = input.int(defval=20, minval=1, title='Swing Period')

//Range Size Inputs
rng_qty = input.float(defval=3.5, minval=0.0000001, title='Swing Multiplier')

//Bar Colors
use_barcolor = input(defval=false, title='Bar Colors On/Off')

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Definitions
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------

//Range Filter Values
[h_band, l_band, filt] = rng_filt(rng_src, rng_size(rng_src, rng_qty, rng_per), rng_per)

//Direction Conditions
var fdir = 0.0
fdir := filt > filt[1] ? 1 : filt < filt[1] ? -1 : fdir
upward = fdir == 1 ? 1 : 0
downward = fdir == -1 ? 1 : 0

//Trading Condition
longCond = rng_src > filt and rng_src > rng_src[1] and upward > 0 or rng_src > filt and rng_src < rng_src[1] and upward > 0
shortCond = rng_src < filt and rng_src < rng_src[1] and downward > 0 or rng_src < filt and rng_src > rng_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

//Colors
filt_color = upward ? #05ff9b : downward ? #ff0583 : #cccccc
bar_color = upward and rng_src > filt ? rng_src > rng_src[1] ? #05ff9b : #00b36b : downward and rng_src < filt ? rng_src < rng_src[1] ? #ff0583 : #b8005d : #cccccc


ema = ta.ema(close,emaLength)

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Outputs
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
longStopPrice = strategy.position_avg_price * (1 - longLossPerc)
shortStopPrice = strategy.position_avg_price * (1 + shortLossPerc)

longTakePrice = strategy.position_avg_price * (1 + longTakePerc)
shortTakePrice = strategy.position_avg_price * (1 - shortTakePerc)

//Filter Plot
filt_plot = plot(filt, color=filt_color, linewidth=3, title='Filter', transp=67)

//Band Plots
h_band_plot = plot(h_band, color=color.new(#05ff9b, 100), title='High Band')
l_band_plot = plot(l_band, color=color.new(#ff0583, 100), title='Low Band')

//Band Fills
fill(h_band_plot, filt_plot, color=color.new(#00b36b, 92), title='High Band Fill')
fill(l_band_plot, filt_plot, color=color.new(#b8005d, 92), title='Low Band Fill')

//Bar Color
barcolor(use_barcolor ? bar_color : na)

if  inDateRange and close>ema
    strategy.entry("Long", strategy.long, when=longCondition)
    
if   inDateRange and close<ema
    strategy.entry("Short", strategy.short, when=shortCondition)


plot(ema)




//Plot Buy and Sell Labels
plotshape(longCondition, title='Buy Signal', text='BUY', textcolor=color.white, style=shape.labelup, size=size.normal, location=location.belowbar, color=color.new(color.green, 0))
plotshape(shortCondition, title='Sell Signal', text='SELL', textcolor=color.white, style=shape.labeldown, size=size.normal, location=location.abovebar, color=color.new(color.red, 0))

//Alerts
alertcondition(longCondition, title='Buy Alert', message='BUY')
alertcondition(shortCondition, title='Sell Alert', message='SELL')

if strategy.position_size > 0
    strategy.exit(id='Long', stop=longStopPrice, limit=longTakePrice)

if strategy.position_size < 0
    strategy.exit(id='Short', stop=shortStopPrice, limit=shortTakePrice)




আরো