চলমান গড় ক্রসওভার কৌশল

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

img

সারসংক্ষেপ

চলমান গড় ক্রসওভার কৌশল একটি গতি কৌশল যা প্রবণতা দিক নির্ধারণ এবং ট্রেডিং সংকেত উত্পন্ন করার জন্য ডাবল চলমান গড়ের ক্রসওভার সংকেতগুলি ব্যবহার করে। এটি 2 টি সহজ চলমান গড় এবং 1 টি এক্সপোনেন্সিয়াল চলমান গড় ব্যবহার করে, তাদের ক্রসওভারের ভিত্তিতে দীর্ঘ এবং সংক্ষিপ্ত বিচার করে, একটি মধ্যমেয়াদী ট্রেডিং কৌশল অন্তর্গত।

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

কৌশলটি 3 টি চলমান গড় ব্যবহার করেঃ

  • ইএমএ১: দ্রুত রেখা হিসেবে কাজ করে এমন একটি স্বল্প সময়ের এক্সপোনেন্সিয়াল চলমান গড়।
  • এসএমএ১ঃ একটি দীর্ঘ সময়ের সহজ চলমান গড়, যা ধীর রেখা হিসাবে কাজ করে
  • এসএমএ২ঃ প্রবণতার দিকনির্দেশনা নির্ধারণকারী আরও দীর্ঘ সময়ের সহজ চলমান গড়

কৌশলটি EMA1, SMA1 এবং SMA2 এর মধ্যে সম্পর্কের ভিত্তিতে প্রবণতা মূল্যায়ন করেঃ

  • উর্ধ্বমুখী প্রবণতাঃ EMA1 > SMA1 > SMA2
  • ডাউনট্রেন্ডঃ EMA1 < SMA1 < SMA2

প্রবেশ সংকেত:

  • লং এন্ট্রিঃ যখন দ্রুত লাইন ধীর লাইনের উপরে অতিক্রম করে
  • সংক্ষিপ্ত প্রবেশঃ যখন দ্রুত লাইন ধীর লাইনের নীচে অতিক্রম করে

সরে যাওয়ার সিগন্যালঃ

  • দীর্ঘ বন্ধঃ যখন দ্রুত রেখা ধীর রেখার নীচে অতিক্রম করে
  • সংক্ষিপ্ত বন্ধঃ যখন দ্রুত লাইন ধীর লাইনের উপরে অতিক্রম করে

কৌশলটি একাধিক প্যারামিটার কনফিগারেশন প্রদান করে, প্রবেশ এবং প্রস্থান জন্য কাস্টমাইজযোগ্য চলমান গড় সঙ্গে।

সুবিধা বিশ্লেষণ

এই কৌশলটির সুবিধাঃ

  1. গতি ধরাঃ প্রবণতা পরিবর্তন, গতি কৌশল সনাক্ত করে
  2. নমনীয় কনফিগারেশনঃ একাধিক এমএ পছন্দ, নমনীয় পরামিতি সুরক্ষা প্রদান করে
  3. প্রবণতা ফিল্টারিংঃ প্রবণতা নির্ধারণের জন্য দীর্ঘমেয়াদী এমএ ব্যবহার করে, বিপরীত প্রবণতা ব্যবসায় এড়ায়
  4. ঝুঁকি ব্যবস্থাপনাঃ কনফিগারযোগ্য স্টপ লস এবং লাভ নিয়ন্ত্রণ একক বাণিজ্য ঝুঁকি

ঝুঁকি বিশ্লেষণ

এই কৌশলের ঝুঁকি:

  1. Whipsaws: ব্রেকআউটের আগে দীর্ঘস্থায়ী চ্যাপিং একাধিক মিথ্যা সংকেত সৃষ্টি করতে পারে
  2. এমএ পরামিতির প্রতি সংবেদনশীলঃ এমএ সময়ের ভুল সুরক্ষা অতিরিক্ত সংবেদনশীলতা বা অলসতার কারণ হতে পারে
  3. লেগিংঃ চলমান গড়ের অন্তর্নিহিত লেগিং প্রকৃতি, সেরা এন্ট্রি টাইমিং মিস করতে পারে
  4. মৌলিক সূচক নেইঃ বিশুদ্ধভাবে প্রযুক্তিগত সূচক দ্বারা চালিত, মৌলিক সূচক বিবেচনা করা হয় না

এমএ সময়কালের সমন্বয় করে হুইপসা ঝুঁকি হ্রাস করা যেতে পারে; প্যারামিটার সংবেদনশীলতা অপ্টিমাইজেশান দ্বারা সমাধান করা যেতে পারে; অন্যান্য শীর্ষস্থানীয় সূচকগুলি অন্তর্ভুক্ত করে বিলম্বের ঝুঁকি হ্রাস করা যেতে পারে।

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

সম্ভাব্য অপ্টিমাইজেশানঃ

  1. সিগন্যালের গুণমান উন্নত করতে আরএসআই, বোলিংজার ব্যান্ডের মতো অন্যান্য প্রযুক্তিগত ফিল্টার যুক্ত করুন
  2. সর্বোত্তম পরামিতি খুঁজে পেতে এমএ সময়কাল অপ্টিমাইজ করুন
  3. প্রবণতা এবং সংকেত নির্ভরযোগ্যতা বিচার করতে মেশিন লার্নিং মডেল অন্তর্ভুক্ত করুন
  4. কম ভলিউম শর্তে মিথ্যা ব্রেকআউট এড়াতে ট্রেডিং ভলিউম বিবেচনা করুন
  5. অর্থনৈতিক চক্রের বিরুদ্ধে ট্রেডিং এড়ানোর জন্য মৌলিক কারণগুলি অন্তর্ভুক্ত করুন

সিদ্ধান্ত

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


/*backtest
start: 2023-09-26 00:00:00
end: 2023-10-26 00:00:00
period: 1h
basePeriod: 15m
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/
// © Decam9

//@version=5
strategy(title = "Moving Average Crossover", shorttitle = "MA Crossover Strategy", overlay=true,
     initial_capital = 100000,default_qty_type = strategy.percent_of_equity, default_qty_value = 10)

//Moving Average Inputs
EMA1 = input.int(title="Fast EMA", group = "Moving Averages:", 
     inline = "EMAs", defval=5, minval = 1)
isDynamicEMA = input.bool(title = "Dynamic Exponential Moving Average?", defval = true,
     inline = "EMAs", group = "Moving Averages:", tooltip = "Changes the source of the MA based on trend")

SMA1 = input.int(title = "Slow SMA", group = "Moving Averages:",
     inline = "SMAs", defval = 10, minval = 1)
isDynamicSMA = input.bool(title = "Dynamic Simple Moving Average?", defval = false,
     inline = "SMAs", group = "Moving Averages:", tooltip = "Changes the source of the MA based on trend")

SMA2 = input.int(title="Trend Determining SMA", group = "Moving Averages:",
     inline = "MAs", defval=13, minval = 1)

//Moving Averages
Trend = ta.sma(close, SMA2)
Fast = ta.ema(isDynamicEMA ? (close > Trend ? low : high) : close, EMA1)
Slow = ta.sma(isDynamicSMA ? (close > Trend ? low : high) : close, SMA1)

//Allowed Entries
islong = input.bool(title = "Long", group = "Allowed Entries:",
     inline = "Entries",defval = true)
isshort = input.bool(title = "Short", group = "Allowed Entries:",
     inline = "Entries", defval= true)

//Entry Long Conditions
buycond = input.string(title="Buy when", group = "Entry Conditions:", 
     inline = "Conditions",defval="Fast-Slow Crossing", 
     options=["Fast-Slow Crossing", "Fast-Trend Crossing","Slow-Trend Crossing"])
     
intrendbuy = input.bool(title = "In trend", defval = true, group = "Entry Conditions:",
     inline = "Conditions", tooltip = "In trend if price is above SMA 2")

//Entry Short Conditions
sellcond = input.string(title="Sell when", group = "Entry Conditions:", 
     inline = "Conditions2",defval="Fast-Slow Crossing", 
     options=["Fast-Slow Crossing", "Fast-Trend Crossing","Slow-Trend Crossing"])
     
intrendsell = input.bool(title = "In trend",defval = true, group = "Entry Conditions:",
     inline = "Conditions2", tooltip = "In trend if price is below SMA 2?")

//Exit Long Conditions
closebuy = input.string(title="Close long when", group = "Exit Conditions:", 
     defval="Fast-Slow Crossing", options=["Fast-Slow Crossing", "Fast-Trend Crossing","Slow-Trend Crossing"])

//Exit Short Conditions
closeshort = input.string(title="Close short when", group = "Exit Conditions:", 
     defval="Fast-Slow Crossing", options=["Fast-Slow Crossing", "Fast-Trend Crossing","Slow-Trend Crossing"])
     

//Filters
filterlong =input.bool(title = "Long Entries", inline = 'linefilt', group = 'Apply Filters to', 
     defval = true)
filtershort =input.bool(title = "Short Entries", inline = 'linefilt', group = 'Apply Filters to', 
     defval = true)
filterend =input.bool(title = "Exits", inline = 'linefilt', group = 'Apply Filters to', 
     defval = true)
usevol =input.bool(title = "", inline = 'linefiltvol', group = 'Relative Volume Filter:', 
     defval = false)
rvol = input.int(title = "Volume >", inline = 'linefiltvol', group = 'Relative Volume Filter:', 
     defval = 1)
len_vol = input.int(title = "Avg. Volume Over Period", inline = 'linefiltvol', group = 'Relative Volume Filter:', 
     defval = 30, minval = 1,
     tooltip="The current volume must be greater than N times the M-period average volume.")
useatr =input.bool(title = "", inline = 'linefiltatr', group = 'Volatility Filter:', 
     defval = false)
len_atr1 = input.int(title = "ATR", inline = 'linefiltatr', group = 'Volatility Filter:', 
     defval = 5, minval = 1)
len_atr2 = input.int(title = "> ATR", inline = 'linefiltatr', group = 'Volatility Filter:', 
     defval = 30, minval = 1,
     tooltip="The N-period ATR must be greater than the M-period ATR.")
usersi =input.bool(title = "", inline = 'linersi', group = 'Overbought/Oversold Filter:', 
     defval = false)
rsitrhs1 = input.int(title = "", inline = 'linersi', group = 'Overbought/Oversold Filter:', 
     defval = 0, minval=0, maxval=100)
rsitrhs2 = input.int(title = "< RSI (14) <", inline = 'linersi', group = 'Overbought/Oversold Filter:', 
     defval = 100, minval=0, maxval=100,
     tooltip="RSI(14) must be in the range between N and M.")
issl =  input.bool(title = "SL", inline = 'linesl1', group = 'Stop Loss / Take Profit:', 
     defval = false)
slpercent =  input.float(title = ", %", inline = 'linesl1', group = 'Stop Loss / Take Profit:', 
     defval = 10, minval=0.0)
istrailing =  input.bool(title = "Trailing", inline = 'linesl1', group = 'Stop Loss / Take Profit:', 
     defval = false)
istp =  input.bool(title = "TP", inline = 'linetp1', group = 'Stop Loss / Take Profit:', 
     defval = false)
tppercent =  input.float(title = ", %", inline = 'linetp1', group = 'Stop Loss / Take Profit:', 
     defval = 20)
     
//Conditions for Crossing
fscrossup = ta.crossover(Fast,Slow)
fscrossdw = ta.crossunder(Fast,Slow)
ftcrossup = ta.crossover(Fast,Trend)
ftcrossdw = ta.crossunder(Fast,Trend)
stcrossup = ta.crossover(Slow,Trend)
stcrossdw = ta.crossunder(Slow,Trend)

//Defining in trend
uptrend = Fast >= Slow and Slow >= Trend
downtrend = Fast <= Slow and Slow <= Trend
justCrossed = ta.cross(Fast,Slow) or ta.cross(Slow,Trend)


//Entry Signals
crosslong = if intrendbuy
    (buycond =="Fast-Slow Crossing" and uptrend ? fscrossup:(buycond =="Fast-Trend Crossing" and uptrend ? ftcrossup:(buycond == "Slow-Trend Crossing" and uptrend ? stcrossup : na))) 
else
    (buycond =="Fast-Slow Crossing"?fscrossup:(buycond=="Fast-Trend Crossing"?ftcrossup:stcrossup))

crossshort = if intrendsell
    (sellcond =="Fast-Slow Crossing" and downtrend ? fscrossdw:(sellcond =="Fast-Trend Crossing" and downtrend ? ftcrossdw:(sellcond == "Slow-Trend Crossing" and downtrend ? stcrossdw : na))) 
else
    (sellcond =="Fast-Slow Crossing"?fscrossdw:(buycond=="Fast-Trend Crossing"?ftcrossdw:stcrossdw))
crossexitlong = (closebuy =="Fast-Slow Crossing"?fscrossdw:(closebuy=="Fast-Trend Crossing"?ftcrossdw:stcrossdw))
crossexitshort = (closeshort =="Fast-Slow Crossing"?fscrossup:(closeshort=="Fast-Trend Crossing"?ftcrossup:stcrossup))


// Filters
rsifilter = usersi?(ta.rsi(close,14) > rsitrhs1 and ta.rsi(close,14) < rsitrhs2):true
volatilityfilter = useatr?(ta.atr(len_atr1) > ta.atr(len_atr2)):true
volumefilter = usevol?(volume > rvol*ta.sma(volume,len_vol)):true
totalfilter = volatilityfilter and volumefilter and rsifilter

//Filtered signals
golong  = crosslong  and islong  and (filterlong?totalfilter:true) 
goshort = crossshort and isshort and (filtershort?totalfilter:true)
endlong  = crossexitlong and (filterend?totalfilter:true)
endshort = crossexitshort and (filterend?totalfilter:true)

// Entry price and TP
startprice = ta.valuewhen(condition=golong or goshort, source=close, occurrence=0)
pm = golong?1:goshort?-1:1/math.sign(strategy.position_size)
takeprofit = startprice*(1+pm*tppercent*0.01)
// fixed stop loss
stoploss = startprice * (1-pm*slpercent*0.01)
// trailing stop loss
if istrailing and strategy.position_size>0
    stoploss := math.max(close*(1 - slpercent*0.01),stoploss[1])
else if istrailing and strategy.position_size<0
    stoploss := math.min(close*(1 + slpercent*0.01),stoploss[1])
    
if golong and islong
    strategy.entry("long",   strategy.long )
if goshort and isshort
    strategy.entry("short",  strategy.short)
if endlong
    strategy.close("long")
if endshort
    strategy.close("short")

// Exit via SL or TP
strategy.exit(id="sl/tp long", from_entry="long", stop=issl?stoploss:na, 
              limit=istp?takeprofit:na)
strategy.exit(id="sl/tp short",from_entry="short",stop=issl?stoploss:na, 
              limit=istp?takeprofit:na)



আরো