दोहरी चलती औसत ट्रेडिंग रणनीति

लेखक:चाओझांग, दिनांक: 2023-12-01 14:36:33
टैगः

img

अवलोकन

दोहरी चलती औसत ट्रेडिंग रणनीति एक तेजी से ईएमए और धीमी ईएमए बनाने के लिए विभिन्न समय सीमाओं के घातीय चलती औसत (ईएमए) की गणना करके और उनके स्वर्ण क्रॉस और मृत्यु क्रॉस का निरीक्षण करके ट्रेडिंग संकेत उत्पन्न करती है। जब तेज ईएमए धीमी ईएमए के ऊपर पार करता है, तो यह लंबा हो जाता है, और जब तेज ईएमए धीमी ईएमए के नीचे पार करता है, तो यह छोटा हो जाता है। यह रणनीति चलती औसत के रुझान उलट बिंदुओं को पकड़ती है और एक आम तौर पर प्रवृत्ति के बाद उपयोग की जाने वाली रणनीति है।

रणनीति तर्क

दोहरी चलती औसत रणनीति के मुख्य संकेतक तेज ईएमए और धीमी ईएमए हैं। तेज ईएमए का डिफ़ॉल्ट पैरामीटर 12 दिन का है, जबकि धीमी ईएमए का डिफ़ॉल्ट पैरामीटर 26 दिन का है। घातीय चलती औसत के लिए सूत्र हैः

ईएमए (टी) = (सी (टी) - ईएमए (टी-1)) x एसएफ (एसएफ) + ईएमए (टी-1)

जहां C (t) आज का समापन मूल्य है, और SF समतल कारक है। सरल चलती औसत के विपरीत, ईएमए हाल के आंकड़ों को अधिक भार देता है और इस प्रकार मूल्य परिवर्तनों पर तेजी से प्रतिक्रिया करता है।

व्यापार के नियम इस प्रकार हैंः

  • नीचे से धीमी ईएमए के ऊपर तेजी से ईएमए के स्वर्ण क्रॉस पर लंबी स्थिति दर्ज करें।

  • ऊपर से धीमी ईएमए के नीचे तेजी से ईएमए के क्रॉसिंग के डेथ क्रॉस पर शॉर्ट पोजीशन दर्ज करें.

  • ईएमए के विचलन पर बाहर निकलने की स्थिति।

ईएमए के क्रॉसओवर पैटर्न को पकड़कर यह बाजार के रुझानों को प्रतिबिंबित कर सकता है और लाभप्रदता बढ़ा सकता है।

लाभ

एक परिपक्व तकनीकी सूचक रणनीति के रूप में दोहरी चलती औसत रणनीति की निम्नलिखित ताकतें हैंः

  1. इसका तर्क स्पष्ट और समझने और लागू करने में आसान है।

  2. यह बाजार की आपूर्ति और मांग पर अत्यधिक सटीक निर्णय देता है और इस प्रकार अपेक्षाकृत उच्च जीत दर है।

  3. यह प्रभावी रूप से बाजार शोर को फ़िल्टर करता है और मुख्य रुझानों को पकड़ता है।

  4. इसे विभिन्न साधनों और समय सीमाओं में लागू किया जा सकता है।

  5. इसे रणनीतिक संवर्धन के लिए अन्य संकेतकों के साथ जोड़ा जा सकता है।

  6. इसमें बड़ी पूंजी व्यापार के लिए उच्च पूंजी उपयोग दक्षता है।

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

इस रणनीति की कुछ सीमाएं भी हैंः

  1. यह बाजार की तीव्र चाल पर प्रतिक्रिया करने में विफल रहता है जैसे कि तेज भालू बाजार की बिक्री।

  2. यह साइडवेज रेंजबाउंड बाजारों में अक्सर झूठे संकेत और whipsaws उत्पन्न करने की प्रवृत्ति रखता है।

  3. इसके मापदंडों को विभिन्न बाजारों और समय सीमाओं में अनुकूलित करने की आवश्यकता है।

  4. यह प्रवृत्ति के उचित उलट स्तर निर्धारित नहीं कर सकता है।

इस रणनीति को और मजबूत बनाने के लिए ईएमए अवधि को समायोजित करके, अतिरिक्त फ़िल्टर आदि जोड़कर जोखिमों को कम किया जा सकता है।

बढ़ोतरी के अवसर

दोहरी चलती औसत रणनीति में निम्नलिखित पहलुओं से सुधार किया जा सकता हैः

  1. ट्रेंड की ताकत का आकलन करने और गलत ट्रेडों से बचने के लिए एमएसीडी संकेतक को शामिल करें।

  2. वास्तविक ब्रेकआउट संकेतों की पुष्टि करने के लिए ट्रेडिंग वॉल्यूम जोड़ें।

  3. अधिक सटीक प्रवेश और निकास नियमों के लिए बोलिंगर बैंड, कैंडलस्टिक पैटर्न के साथ संयोजन करें।

  4. बेहतर अनुकूलन क्षमता के लिए पैरामीटर को स्वचालित रूप से अनुकूलित करने के लिए LSTM जैसे मशीन लर्निंग दृष्टिकोणों का उपयोग करें।

निष्कर्ष

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


/*backtest
start: 2022-11-24 00:00:00
end: 2023-11-30 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/
// © antondmt

//@version=5
strategy("Returns & Drawdowns Table", "R & DD", true, calc_on_every_tick = false, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, process_orders_on_close = true)
i_eq_to_dd =            input.string("Compound Equity", "Mode", ["Simple Equity", "Compound Equity", "Drawdown"], group = "R & DD Table")
i_precision =           input.int(2, "Return Precision", group = "R & DD Table")
i_headers_col =         input.color(#D4D4D4, "Headers Color", group = "R & DD Table")
i_headers_text_col =    input.color(color.black, "Headers Text Color", group = "R & DD Table")
i_pos_col =             input.color(color.green, "Positive Color", group = "R & DD Table")
i_neg_col =             input.color(color.red, "Negative Color", group = "R & DD Table")
i_zero_col =            input.color(#DDDDDD, "Zero Color", group = "R & DD Table")
i_cell_text_col =       input.color(color.white, "Cell Text Color", group = "R & DD Table")

// TIME {
var month_times = array.new_int(0)                                                              // Array of all month times  
new_month = month(time) != month(time[1]) 
if(new_month or barstate.isfirst)
    array.push(month_times, time)

var year_times = array.new_int(0)                                                               
new_year = year(time) != year(time[1])  
if (new_year or barstate.isfirst)
    array.push(year_times, time)
//}

// SIMPLE EQUITY CALCULATIONS {
// Simple equity is strictly calculated from start to end of each month/year equity. There is no compound
var monthly_simp_pnls = array.new_float(0)                                                      // Array of all monthly profits and losses
var yearly_simp_pnls = array.new_float(0)                                                       

if(i_eq_to_dd == "Simple Equity")
    var initial_monthly_equity = strategy.equity                                                // Starting equity for each month
    cur_month_pnl = nz((strategy.equity - initial_monthly_equity) / initial_monthly_equity)     // Current month's equity change
    if(new_month or barstate.isfirst)
        initial_monthly_equity := strategy.equity
        array.push(monthly_simp_pnls, cur_month_pnl)
    else 
        array.set(monthly_simp_pnls, array.size(monthly_simp_pnls) - 1, cur_month_pnl)
    
    var initial_yearly_equity = strategy.equity
    cur_year_pnl = nz((strategy.equity - initial_yearly_equity) / initial_yearly_equity)
    if (new_year or barstate.isfirst)
        initial_yearly_equity := strategy.equity
        array.push(yearly_simp_pnls, cur_year_pnl)
    else 
        array.set(yearly_simp_pnls, array.size(yearly_simp_pnls) - 1, cur_year_pnl)
// }

// COMPOUND EQUITY CALCULATIONS {
// Compound equity is strictly calculated based on equity state from the beginning of time until the end of each month/year equity. It shows the exact equity movement through time
var monthly_comp_pnls = array.new_float(0)                                                      // Array of all monthly profits and losses
var yearly_comp_pnls = array.new_float(0)                                                       

if(i_eq_to_dd == "Compound Equity")
    var initial_equity = strategy.equity                                                
    cur_month_pnl = nz((strategy.equity - initial_equity) / initial_equity)                     // Current month's equity change
    if(new_month or barstate.isfirst)
        array.push(monthly_comp_pnls, cur_month_pnl)
    else 
        array.set(monthly_comp_pnls, array.size(monthly_comp_pnls) - 1, cur_month_pnl)
    
    cur_year_pnl = nz((strategy.equity - initial_equity) / initial_equity)
    if (new_year or barstate.isfirst)
        array.push(yearly_comp_pnls, cur_year_pnl)
    else 
        array.set(yearly_comp_pnls, array.size(yearly_comp_pnls) - 1, cur_year_pnl)
// }
    
// DRAWDOWN CALCULATIONS {
// Drawdowns are calculated from highest equity to lowest trough for the month/year
var monthly_dds = array.new_float(0)                                                            // Array of all monthly drawdowns
var yearly_dds = array.new_float(0)                                                             

if (i_eq_to_dd == "Drawdown")
    total_equity = strategy.equity - strategy.openprofit                        
    
    var cur_month_dd = 0.0  
    var m_ATH = total_equity                                                                    // Monthly All-Time-High (ATH). It is reset each month
    m_ATH := math.max(total_equity, nz(m_ATH[1]))
    m_drawdown = -math.abs(total_equity / m_ATH * 100 - 100) / 100                              // Drawdown at current bar
    if(m_drawdown < cur_month_dd)
        cur_month_dd := m_drawdown
    if(new_month or barstate.isfirst)
        cur_month_dd := 0.0
        m_ATH := strategy.equity - strategy.openprofit
        array.push(monthly_dds, 0)
    else 
        array.set(monthly_dds, array.size(monthly_dds) - 1, cur_month_dd)
    
    var cur_year_dd = 0.0
    var y_ATH = total_equity
    y_ATH := math.max(total_equity, nz(y_ATH[1]))
    y_drawdown = -math.abs(total_equity / y_ATH * 100 - 100) / 100
    if(y_drawdown < cur_year_dd)
        cur_year_dd := y_drawdown
    if (new_year or barstate.isfirst)
        cur_year_dd := 0.0
        y_ATH := strategy.equity - strategy.openprofit
        array.push(yearly_dds, 0)
    else 
        array.set(yearly_dds, array.size(yearly_dds) - 1, cur_year_dd) 
// }

// TABLE LOGIC { 
var main_table = table(na)
table.clear(main_table, 0, 0, 13, new_year ? array.size(year_times) - 1 : array.size(year_times))
main_table := table.new(position.bottom_right, columns = 14, rows = array.size(year_times) + 1, border_width = 1)

t_set_headers() =>                                                                              // Sets time headers of the table
    // Set month headers
    table.cell(main_table, 0,  0, "",     text_color = i_headers_text_col, bgcolor = i_headers_col)
    table.cell(main_table, 1,  0, "Jan",  text_color = i_headers_text_col, bgcolor = i_headers_col)
    table.cell(main_table, 2,  0, "Feb",  text_color = i_headers_text_col, bgcolor = i_headers_col)
    table.cell(main_table, 3,  0, "Mar",  text_color = i_headers_text_col, bgcolor = i_headers_col)
    table.cell(main_table, 4,  0, "Apr",  text_color = i_headers_text_col, bgcolor = i_headers_col)
    table.cell(main_table, 5,  0, "May",  text_color = i_headers_text_col, bgcolor = i_headers_col)
    table.cell(main_table, 6,  0, "Jun",  text_color = i_headers_text_col, bgcolor = i_headers_col)
    table.cell(main_table, 7,  0, "Jul",  text_color = i_headers_text_col, bgcolor = i_headers_col)
    table.cell(main_table, 8,  0, "Aug",  text_color = i_headers_text_col, bgcolor = i_headers_col)
    table.cell(main_table, 9,  0, "Sep",  text_color = i_headers_text_col, bgcolor = i_headers_col)
    table.cell(main_table, 10, 0, "Oct",  text_color = i_headers_text_col, bgcolor = i_headers_col)
    table.cell(main_table, 11, 0, "Nov",  text_color = i_headers_text_col, bgcolor = i_headers_col)
    table.cell(main_table, 12, 0, "Dec",  text_color = i_headers_text_col, bgcolor = i_headers_col)
    table.cell(main_table, 13, 0, str.tostring(i_eq_to_dd), text_color = i_headers_text_col, bgcolor = i_headers_col)

    // Set year headers
    for i = 0 to array.size(year_times) - 1
        table.cell(main_table, 0,  i + 1, str.tostring(year(array.get(year_times, i))), text_color = i_headers_text_col, bgcolor = i_headers_col)

t_set_months() =>                                                                               // Sets inner monthly data of the table
    display_array = switch i_eq_to_dd 
        "Simple Equity" => monthly_simp_pnls 
        "Compound Equity" => monthly_comp_pnls
        => monthly_dds
    for i = 0 to array.size(month_times) - 1
        m_row = year(array.get(month_times, i)) - year(array.get(year_times, 0)) + 1
        m_col = month(array.get(month_times, i)) 
        m_color = array.get(display_array, i) == 0 ? color.new(i_zero_col, transp = 30) : array.get(display_array, i) > 0 ? color.new(i_pos_col, transp = 30) : color.new(i_neg_col, transp = 30)
        table.cell(main_table, m_col, m_row, str.tostring(math.round(array.get(display_array, i) * 100, i_precision)), bgcolor = m_color, text_color = i_cell_text_col)
        
t_set_years() =>                                                                                // Sets inner yearly data of the table
    display_array = switch i_eq_to_dd 
        "Simple Equity" => yearly_simp_pnls 
        "Compound Equity" => yearly_comp_pnls
        => yearly_dds
    for i = 0 to array.size(year_times) - 1
        y_color = array.get(display_array, i) == 0 ? color.new(i_zero_col, transp = 30) : array.get(display_array, i) > 0 ? color.new(i_pos_col, transp = 20) : color.new(i_neg_col, transp = 20)
        table.cell(main_table, 13, i + 1, str.tostring(math.round(array.get(display_array, i) * 100, i_precision)), bgcolor = y_color, text_color = i_cell_text_col)

t_set_headers() 
t_set_months()
t_set_years()
// }

// PLACE YOUR STRATEGY CODE HERE {
// This is a sample code of a working strategy to show the table in action
fastLength = input(12)
slowlength = input(26)
MACDLength = input(9)
MACD = ta.ema(close, fastLength) - ta.ema(close, slowlength)
aMACD = ta.ema(MACD, MACDLength)
delta = MACD - aMACD
if (ta.crossover(delta, 0))
	strategy.entry("MacdLE", strategy.long, comment = "MacdLE")
if (ta.crossunder(delta, 0))
	strategy.entry("MacdSE", strategy.short, comment = "MacdSE")
// }

अधिक