সূচকগুলির সংমিশ্রণের উপর ভিত্তি করে কৌশল অনুসরণ করে দ্বৈত চলমান গড় প্রবণতার একটি অপ্টিমাইজেশন

লেখক:চাওঝাং, তারিখঃ 2024-02-01 15:13:13
ট্যাগঃ

img

সারসংক্ষেপ

এই কৌশলটি দ্রুত এবং ধীর গতির গড় রেখাগুলি গণনা করে এবং প্যারাবলিক এসএআর সূচককে একত্রিত করে ট্রেডিং সংকেত তৈরি করে। এটি প্রবণতা অনুসরণকারী কৌশলটির অন্তর্গত। যখন দ্রুত এমএ ধীর এমএ অতিক্রম করে, তখন দীর্ঘ অবস্থান খোলা হবে। যখন দ্রুত এমএ ধীর এমএ এর নীচে অতিক্রম করে, তখন শর্ট অবস্থান খোলা হবে। প্যারাবলিক এসএআর ভুয়া ব্রেকআউটগুলি ফিল্টার করতে ব্যবহৃত হয়।

কৌশল নীতি

  1. দ্রুত এবং ধীর চলমান গড় রেখা গণনা করুন। পরামিতি কাস্টমাইজ করা যাবে।
  2. বাজারের প্রবণতা নির্ধারণের জন্য দুটি এমএ লাইন তুলনা করুন। যখন দ্রুত এমএ ধীর এমএ অতিক্রম করে, এটি উত্থান প্রবণতা নির্দেশ করে। যখন দ্রুত এমএ ধীর এমএ এর নীচে অতিক্রম করে, এটি হ্রাস প্রবণতা নির্দেশ করে।
  3. আরও নিশ্চিতকরণ পরীক্ষা করে করা হয় যে বন্ধের দাম দ্রুত এমএ এর উপরে / নীচে রয়েছে কিনা। কেবলমাত্র যখন দ্রুত এমএ ধীর এমএ অতিক্রম করে এবং বন্ধের দাম দ্রুত এমএ এর উপরে থাকে, তখন দীর্ঘ সংকেত উত্পন্ন হয়। কেবলমাত্র যখন দ্রুত এমএ ধীর এমএ এর নীচে অতিক্রম করে এবং বন্ধের দাম দ্রুত এমএ এর নীচে থাকে, তখন সংক্ষিপ্ত সংকেত উত্পন্ন হয়।
  4. প্যারাবলিক এসএআর ভুয়া সংকেত ফিল্টার করতে ব্যবহৃত হয়। শুধুমাত্র যখন তিনটি মানদণ্ড পূরণ করা হয়, চূড়ান্ত সংকেত উৎপন্ন হয়।
  5. স্টপ লস সর্বাধিক সহনীয় ক্ষতির উপর ভিত্তি করে সেট করা হয়। এটিআর সূচকটি গতিশীল স্টপ লস মূল্য গণনা করতে ব্যবহৃত হয়।

সুবিধা

  1. এমএ লাইনগুলি বাজারের প্রবণতা নির্ধারণ করে এবং পরিসীমা সীমাবদ্ধ বাজারে অত্যধিক লেনদেন এড়ায়।
  2. ডাবল ফিল্টার ভুয়া পলায়নের ঝুঁকি উল্লেখযোগ্যভাবে কমিয়ে দেয়।
  3. স্টপ লস কৌশল কার্যকরভাবে প্রতি ট্রেড ক্ষতি সীমাবদ্ধ করে।

ঝুঁকি

  1. সূচক কৌশলগুলি মিথ্যা সংকেত তৈরি করে
  2. কারেন্সি এক্সপোজার ঝুঁকি বিবেচনা না করা
  3. বিপরীত দিকের প্রারম্ভিক প্রবণতা মিস করার সম্ভাবনা

কৌশলটি নিম্নলিখিত দিকগুলিতে অনুকূলিত করা যেতে পারেঃ

  1. নির্দিষ্ট পণ্যের জন্য এমএ পরামিতি অপ্টিমাইজ করুন
  2. সিগন্যাল ফিল্টারিংয়ের জন্য অন্যান্য সূচক বা মডেল যোগ করুন
  3. রিয়েল-টাইম হেজিং বা স্বয়ংক্রিয় মুদ্রা রূপান্তর বিবেচনা করুন

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

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

সিদ্ধান্ত

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


/*backtest
start: 2024-01-01 00:00:00
end: 2024-01-31 00:00:00
period: 4h
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/
// © sosacur01

//@version=5
strategy(title="2 MA | Trend Following", overlay=true, pyramiding=1, commission_type=strategy.commission.percent, commission_value=0.2, initial_capital=10000)

//==========================================


//BACKTEST RANGE
useDateFilter = input.bool(true, title="Filter Date Range of Backtest",
     group="Backtest Time Period")
backtestStartDate = input(timestamp("1 jan 2000"), 
     title="Start Date", group="Backtest Time Period",
     tooltip="This start date is in the time zone of the exchange " + 
     "where the chart's instrument trades. It doesn't use the time " + 
     "zone of the chart or of your computer.")
backtestEndDate = input(timestamp("1 Jul 2100"),
     title="End Date", group="Backtest Time Period",
     tooltip="This end date is in the time zone of the exchange " + 
     "where the chart's instrument trades. It doesn't use the time " + 
     "zone of the chart or of your computer.")
inTradeWindow = true
if not inTradeWindow and inTradeWindow[1]
    strategy.cancel_all()
    strategy.close_all(comment="Date Range Exit")

//--------------------------------------

//LONG/SHORT POSITION ON/OFF INPUT
LongPositions   = input.bool(title='On/Off Long Postion', defval=true, group="Long & Short Position")
ShortPositions  = input.bool(title='On/Off Short Postion', defval=true, group="Long & Short Position")

//---------------------------------------

//SLOW MA INPUTS
averageType1   = input.string(defval="SMA", group="Slow MA Inputs", title="Slow MA Type", options=["SMA", "EMA", "WMA", "HMA", "RMA", "SWMA", "ALMA", "VWMA", "VWAP"])
averageLength1 = input.int(defval=160, group="Slow MA Inputs", title="Slow MA Length", minval=50)
averageSource1 = input(close, title="Slow MA Source", group="Slow MA Inputs")
           

//SLOW MA TYPE
MovAvgType1(averageType1, averageSource1, averageLength1) =>
	switch str.upper(averageType1)
        "SMA"  => ta.sma(averageSource1, averageLength1)
        "EMA"  => ta.ema(averageSource1, averageLength1)
        "WMA"  => ta.wma(averageSource1, averageLength1)
        "HMA"  => ta.hma(averageSource1, averageLength1)
        "RMA"  => ta.rma(averageSource1, averageLength1)
        "SWMA" => ta.swma(averageSource1)
        "ALMA" => ta.alma(averageSource1, averageLength1, 0.85, 6)
        "VWMA" => ta.vwma(averageSource1, averageLength1)
        "VWAP" => ta.vwap(averageSource1)
        => runtime.error("Moving average type '" + averageType1 + 
             "' not found!"), na


//----------------------------------

//FAST MA INPUTS
averageType2   = input.string(defval="SMA", group="Fast MA Inputs", title="Fast MA Type", options=["SMA","EMA","WMA","HMA","RMA","SWMA","ALMA","VWMA","VWAP"])
averageLength2 = input.int(defval=40, group="Fast MA Inputs", title="Fast MA Length", maxval=40)
averageSource2 = input(close, title="Fast MA Source", group="Fast MA Inputs")

//FAST MA TYPE
MovAvgType2(averageType2, averageSource2, averageLength2) =>
	switch str.upper(averageType2)
        "SMA"  => ta.sma(averageSource2, averageLength2)
        "EMA"  => ta.ema(averageSource2, averageLength2)
        "WMA"  => ta.wma(averageSource2, averageLength2)
        "HMA"  => ta.hma(averageSource2, averageLength2)
        "RMA"  => ta.rma(averageSource2, averageLength2)
        "SWMA" => ta.swma(averageSource2)
        "ALMA" => ta.alma(averageSource2, averageLength2, 0.85, 6)
        "VWMA" => ta.vwma(averageSource2, averageLength2)
        "VWAP" => ta.vwap(averageSource2)
        => runtime.error("Moving average type '" + averageType2 + 
             "' not found!"), na

//---------------------------------------------------

//MA VALUES
FASTMA = MovAvgType2(averageType2, averageSource2, averageLength2)
SLOWMA = MovAvgType1(averageType1, averageSource1, averageLength1)

//BUY/SELL TRIGGERS
bullish_trend = FASTMA > SLOWMA and close > FASTMA
bearish_trend = FASTMA < SLOWMA and close < FASTMA

//MAs PLOT
plot1 = plot(SLOWMA,color=color.gray, linewidth=1, title="Slow-MA")
plot2 = plot(FASTMA,color=color.yellow, linewidth=1, title="Fast-MA")
fill(plot1, plot2, color=SLOWMA>FASTMA ? color.new(color.red, 70) : color.new(color.green, 70), title="EMA Clouds")

//-----------------------------------------------------

//PARABOLIC SAR USER INPUT
usepsarFilter = input.bool(title='Use Parabolic Sar?', defval=true, group = "Parabolic SAR Inputs")
psar_display  = input.bool(title="Display Parabolic Sar?", defval=false, group="Parabolic SAR Inputs")
start         = input.float(title="Start", defval=0.02, group="Parabolic SAR Inputs", step=0.001)
increment     = input.float(title="Increment", defval=0.02, group="Parabolic SAR Inputs", step=0.001)
maximum       = input.float(title="Maximum", defval=0.2, group="Parabolic SAR Inputs", step=0.001)

//SAR VALUES
psar        = request.security(syminfo.tickerid, "D", ta.sar(start, increment, maximum))

//BULLISH & BEARISH PSAR CONDITIONS
bullish_psar = (usepsarFilter ? low > psar : bullish_trend )
bearsish_psar = (usepsarFilter ? high < psar : bearish_trend)

//SAR PLOT
psar_plot    = if low > psar
    color.rgb(198, 234, 199, 13)
else
    color.rgb(219, 134, 134, 48)
    
plot(psar_display ? psar : na, color=psar_plot, title="Par SAR")

//-------------------------------------

//ENTRIES AND EXITS
long_entry  = if inTradeWindow and bullish_trend  and bullish_psar and LongPositions
    true
long_exit   = if inTradeWindow and bearish_trend   
    true

short_entry = if inTradeWindow  and bearish_trend and bearsish_psar and ShortPositions
    true
short_exit  = if inTradeWindow  and bullish_trend 
    true

//--------------------------------------

//RISK MANAGEMENT - SL, MONEY AT RISK, POSITION SIZING
atrPeriod                = input.int(14, "ATR Length", group="Risk Management Inputs")
sl_atr_multiplier        = input.float(title="Long Position - Stop Loss - ATR Multiplier", defval=2, group="Risk Management Inputs", step=0.5)
sl_atr_multiplier_short  = input.float(title="Short Position - Stop Loss - ATR Multiplier", defval=2, group="Risk Management Inputs", step=0.5)
i_pctStop                = input.float(2, title="% of Equity at Risk", step=.5, group="Risk Management Inputs")/100

//ATR VALUE
_atr = ta.atr(atrPeriod)

//CALCULATE LAST ENTRY PRICE
lastEntryPrice = strategy.opentrades.entry_price(strategy.opentrades - 1)

//STOP LOSS - LONG POSITIONS 
var float sl = na

//CALCULTE SL WITH ATR AT ENTRY PRICE - LONG POSITION
if (strategy.position_size[1] != strategy.position_size)
    sl := lastEntryPrice - (_atr * sl_atr_multiplier)

//IN TRADE - LONG POSITIONS
inTrade = strategy.position_size > 0

//PLOT SL - LONG POSITIONS
plot(inTrade ? sl : na, color=color.blue, style=plot.style_circles, title="Long Position - Stop Loss")

//CALCULATE ORDER SIZE - LONG POSITIONS
positionSize = (strategy.equity * i_pctStop) / (_atr * sl_atr_multiplier)

//============================================================================================

//STOP LOSS - SHORT POSITIONS 
var float sl_short = na

//CALCULTE SL WITH ATR AT ENTRY PRICE - SHORT POSITIONS 
if (strategy.position_size[1] != strategy.position_size)
    sl_short := lastEntryPrice + (_atr * sl_atr_multiplier_short)

//IN TRADE SHORT POSITIONS
inTrade_short = strategy.position_size < 0

//PLOT SL - SHORT POSITIONS
plot(inTrade_short ? sl_short : na, color=color.red, style=plot.style_circles, title="Short Position - Stop Loss")

//CALCULATE ORDER - SHORT POSITIONS
positionSize_short = (strategy.equity * i_pctStop) / (_atr * sl_atr_multiplier_short) 


//===============================================

//LONG STRATEGY
strategy.entry("Long", strategy.long, comment="Long", when = long_entry, qty=positionSize)
if (strategy.position_size > 0)
    strategy.close("Long", when = (long_exit), comment="Close Long")
    strategy.exit("Long", stop = sl, comment="Exit Long")

//SHORT STRATEGY
strategy.entry("Short", strategy.short, comment="Short", when = short_entry, qty=positionSize_short)
if (strategy.position_size < 0) 
    strategy.close("Short", when = (short_exit), comment="Close Short")
    strategy.exit("Short", stop = sl_short, comment="Exit Short")

//ONE DIRECTION TRADING COMMAND (BELLOW ONLY ACTIVATE TO CORRECT BUGS)


আরো