दोहरी चलती औसत क्रॉसओवर रणनीति

लेखक:चाओझांग, दिनांकः 2024-01-12 14:59:18
टैगः

img

अवलोकन

डबल मूविंग एवरेज क्रॉसओवर रणनीति एक ठेठ ट्रेंड फॉलोअप रणनीति है। यह अलग-अलग अवधि के साथ दो ईएमए लाइनों का उपयोग करती है और लंबी अवधि के ईएमए के पार होने पर लंबी अवधि की ईएमए जाती है और विपरीत क्रॉसिंग होने पर ट्रेंड रिवर्स को पकड़ने के लिए छोटी होती है।

सिद्धांत

इस रणनीति के मुख्य संकेतक दो ईएमए लाइनें हैं, एक 30-अवधि और दूसरी 60-अवधि है। दो ईएमए लाइनों की गणना कोड में कस्टम कार्यों द्वारा की जाती हैः

emaLen1 = emaFuncOne(close, lenMA1)
emaLen2 = emaFuncTwo(close, lenMA2)  

ट्रेडिंग सिग्नल दो ईएमए लाइनों के पार होने से उत्पन्न होते हैंः

currentState = if emaLen2 > emaLen1
    0
else 
    1

previousState = if emaLastLen2 > emaLastLen1 
    0
else
    1

convergence = if currentState != previousState
    1  
else
    0

जब छोटी अवधि ईएमए लंबी अवधि ईएमए पार करती है, तो वर्तमान स्थिति पिछले स्थिति के बराबर नहीं होती है, एक क्रॉसओवर संकेत ट्रिगर होता है, लंबा हो जाता है। जब छोटी अवधि ईएमए लंबी अवधि ईएमए से नीचे पार हो जाती है, तो वर्तमान स्थिति पिछली स्थिति के बराबर नहीं होती है, एक क्रॉसओवर संकेत ट्रिगर होता है, शॉर्ट हो जाता है।

लाभ विश्लेषण

इस रणनीति के लाभ इस प्रकार हैंः

  1. तर्क सरल और सहज है, समझने और लागू करने में आसान है
  2. ईएमए के साथ मूल्य उतार-चढ़ाव को सुचारू करता है और बाजार शोर को फ़िल्टर करता है
  3. स्वचालित रूप से रुझानों का पालन करता है, छूटने वाले ट्रेडों से बचता है

जोखिम विश्लेषण

इस रणनीति के साथ कुछ जोखिम भी हैंः

  1. क्रॉसओवर सिग्नल में देरी हो सकती है और समय पर रिवर्स को पकड़ने में विफल हो सकते हैं
  2. वाइप्सॉ सिग्नल अक्सर रेंजिंग मार्केट के दौरान हो सकते हैं
  3. खराब पैरामीटर ट्यूनिंग अतिसंवेदनशीलता या देरी का कारण बन सकती है

अनुकूलन ईएमए अवधि को समायोजित करके या फ़िल्टर जोड़कर किया जा सकता है।

अनुकूलन दिशाएँ

इस रणनीति को निम्नलिखित पहलुओं से अनुकूलित किया जा सकता हैः

  1. विभिन्न ईएमए अवधि संयोजनों का परीक्षण करें
  2. झूठे संकेतों को कम करने के लिए वॉल्यूम या अस्थिरता फ़िल्टर जोड़ें
  3. रुझानों की पुष्टि करने के लिए एमएसीडी जैसे अन्य संकेतकों को शामिल करें
  4. स्टॉप लॉस और लाभ लेने के साथ धन प्रबंधन को अनुकूलित करें

निष्कर्ष

डबल मूविंग एवरेज क्रॉसओवर रणनीति एक सरल और व्यावहारिक ट्रेंड फॉलो सिस्टम है। यह सीधा आगे है, लागू करना आसान है और स्वचालित रूप से रुझानों को ट्रैक कर सकता है। लेकिन कुछ जोखिम जैसे लेगिंग और झूठे सिग्नल मौजूद हैं। पैरामीटर ट्यूनिंग और फिल्टर जोड़ने के साथ, इसे और बेहतर बनाया जा सकता है ताकि यह मौलिक एल्गोरिथम ट्रेडिंग रणनीतियों में से एक बन सके।


/*backtest
start: 2024-01-10 00:00:00
end: 2024-01-11 00:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
strategy("ParkerMAStrat", overlay=true)

lenMA1=input(title="Length 1", defval=30)
lenMA2=input(title="Length 2",  defval=60)

x = 0

checkLines(current, last) =>

    if current > last
        x = 1
    else
        x = 0
    x
    

//plot ema based on len1
emaFuncOne(src, time_period) =>

    alpha = 2 / (time_period + 1)
    // we have defined the alpha function above
    ema = 0.0
    // this is the initial declaration of ema, since we dont know the first ema we will declare it to 0.0 [as a decimal]
    ema := alpha * src + (1 - alpha) * nz(ema[1])
    // this returns the computed ema at the current time
    // notice the use of : (colon) symbol before =, it symbolises, that we are changing the value of ema,
    // since the ema was previously declared to 0
    // this is called mutable variale declaration in pine script
    ema
    // return ema from the function

emaLen1 = emaFuncOne(close, lenMA1)

    
plot(emaLen1, color=green, transp=0, linewidth=2)
// now we plot the _10_period_ema

//plot ema based on len2
emaFuncTwo(src, time_period) =>

    alpha = 2 / (time_period + 1)
    // we have defined the alpha function above
    ema = 0.0
    // this is the initial declaration of ema, since we dont know the first ema we will declare it to 0.0 [as a decimal]
    ema := alpha * src + (1 - alpha) * nz(ema[1])
    // this returns the computed ema at the current time
    // notice the use of : (colon) symbol before =, it symbolises, that we are changing the value of ema,
    // since the ema was previously declared to 0
    // this is called mutable variale declaration in pine script
    ema
    // return ema from the function

//plot ema based on len2
emaFuncOneLast(src, time_period) =>

    alpha = 2 / (time_period + 1)
    // we have defined the alpha function above
    ema = 0.0
    // this is the initial declaration of ema, since we dont know the first ema we will declare it to 0.0 [as a decimal]
    ema := alpha * src + (1 - alpha) * nz(ema[0])
    // this returns the computed ema at the current time
    // notice the use of : (colon) symbol before =, it symbolises, that we are changing the value of ema,
    // since the ema was previously declared to 0
    // this is called mutable variale declaration in pine script
    ema
    // return ema from the function

//plot ema based on len2
emaFuncTwoLast(src, time_period) =>

    alpha = 2 / (time_period + 1)
    // we have defined the alpha function above
    ema = 0.0
    // this is the initial declaration of ema, since we dont know the first ema we will declare it to 0.0 [as a decimal]
    ema := alpha * src + (1 - alpha) * nz(ema[0])
    // this returns the computed ema at the current time
    // notice the use of : (colon) symbol before =, it symbolises, that we are changing the value of ema,
    // since the ema was previously declared to 0
    // this is called mutable variale declaration in pine script
    ema
    // return ema from the function



emaLastLen1 = emaFuncOneLast(close, lenMA1)
emaLastLen2 = emaFuncTwoLast(close, lenMA2)
emaLen2 = emaFuncTwo(close, lenMA2)

    
plot(emaLen2, color=red, transp=30, linewidth=2)
// now we plot the _10_period_ema

//now we compare the two and when green crosses red we buy/sell (line1 vs line2)

previousState = if emaLastLen2 > emaLastLen1
    0
else
    1

currentState = if emaLen2 > emaLen1
    0
else
    1

convergence = if currentState != previousState
    1
else
    0

    
lineCheck = if convergence == 1 
    checkLines(currentState, previousState)
    
if lineCheck == 1
    strategy.entry("Long", strategy.long)
else
    strategy.entry("Short", strategy.short)


अधिक