एमएसीडी संकेतक ब्रेकआउट ट्रेडिंग रणनीति

लेखक:चाओझांग, दिनांकः 2023-09-12 15:32:12
टैगः

यह रणनीति प्रवेश और निकास निर्णयों के लिए एमएसीडी क्रॉसओवर संकेतों का व्यापार करती है। एमएसीडी तेजी से और धीमी ईएमए से बना है, और शून्य से अधिक एमएसीडी लाइन का क्रॉसओवर व्यापार संकेत उत्पन्न करता है। यह एक विशिष्ट प्रवृत्ति-अनुसरण मात्रात्मक रणनीति है।

रणनीति तर्क:

  1. त्वरित ईएमए और धीमी ईएमए की गणना करें, उनका अंतर एमएसीडी रेखा बनाता है।

  2. सिग्नल लाइन प्राप्त करने के लिए एक अन्य ईएमए का उपयोग करके एमएसीडी लाइन को चिकना करें।

  3. सिग्नल के ऊपर MACD क्रॉसिंग पर लॉन्ग, और नीचे क्रॉसिंग पर शॉर्ट करें।

  4. प्रतिशत स्टॉप लॉस सेट करें और जोखिम प्रबंधन के लिए लाभ लें।

लाभः

  1. अधिक स्पष्ट प्रवृत्ति पहचान के लिए एकल ईएमए पर एमएसीडी में सुधार होता है।

  2. ब्रेकआउट ट्रेडिंग समय पर महत्वपूर्ण मोड़ को पकड़ती है।

  3. स्टॉप लॉस/टेक प्रॉफिट तंत्र व्यापार जोखिम को नियंत्रित करने में मदद करते हैं।

जोखिमः

  1. एमएसीडी शून्य रेखा के पास अधिक झूठे ब्रेकआउट।

  2. विभिन्न व्यापारिक साधनों के लिए पैरामीटर समायोजन की आवश्यकता होती है।

  3. रुझान ट्रेडिंग घटना जोखिम के लिए प्रवण है, जिसके लिए स्टॉप की आवश्यकता होती है।

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


/*backtest
start: 2023-01-01 00:00:00
end: 2023-09-11 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3 
strategy("uray MACD", overlay=false, pyramiding = 0, calc_on_every_tick=true, precision=2, currency="USD", default_qty_value=10, default_qty_type=strategy.cash,initial_capital=100,commission_type=strategy.commission.percent,commission_value=0.1) 

// === INPUT BACKTEST RANGE ===
FromMonth = input(defval = 6, title = "From Month", minval = 1, maxval = 12)
FromDay   = input(defval = 1, title = "From Day", minval = 1, maxval = 31)
FromYear  = input(defval = 2018, title = "From Year", minval = 2017)
ToMonth   = input(defval = 6, title = "To Month", minval = 1, maxval = 12)
ToDay     = input(defval = 1, title = "To Day", minval = 1, maxval = 31)
ToYear    = input(defval = 2020, title = "To Year", minval = 2017)

// === FUNCTION EXAMPLE ===
start     = timestamp(FromYear, FromMonth, FromDay, 00, 00)  // backtest start window
finish    = timestamp(ToYear, ToMonth, ToDay, 23, 59)        // backtest finish window
inTimeframe()  => true


isPosLong    = strategy.position_size > 0
isPosShort   = strategy.position_size < 0
isNoMarginPos= strategy.position_size == 0

fastLength    = input(12, minval = 1, title = "MACD fast")
slowlength    = input(26, minval = 1, title = "MACD slow")
MACDLength    = input( 9, minval = 1, title = "MACD length")
stopLoss      = input( 10, minval = 1, title = "Stop Loss (price %)", type=float)
takeProfit    = input( 50, minval = 1, title = "Take Profit (price %)", type=float)
src           = close   // Source of Calculations (Close of Bar)

MACD  = ta.ema(src, fastLength) - ta.ema(src, slowlength)
aMACD = ta.ema(MACD, MACDLength)
delta = MACD - aMACD
stopLossValue      = close*(stopLoss/100)/syminfo.mintick
takeProfitValue    = close*(takeProfit/100)/syminfo.mintick
switchLongTrigger  = ta.crossover(delta, 0)
switchShortTrigger = ta.crossunder(delta, 0)
closeLongTrigger   = ta.crossunder(delta, 0)
closeShortTrigger  = ta.crossover(delta, 0)
entryLongTrigger   = ta.crossover(delta, 0)
entryShortTrigger  = ta.crossunder(delta, 0)

// if inTimeframe()
//     if isNoMarginPos
//         if entryLongTrigger
//             strategy.entry("Long", strategy.long,  comment="Entry Long")
//             strategy.exit("Stop (long SL/TP)", loss=stopLossValue, profit=takeProfitValue)   
//         if entryShortTrigger
//             strategy.entry("Short", strategy.short, comment="Entry Short")  
//             strategy.exit("Stop (short SL/TP)", loss=stopLossValue, profit=takeProfitValue)   
//     if isPosShort
//         if switchLongTrigger
//             strategy.close_all()    
//             strategy.entry("Long", strategy.long, comment="switch Long")
//             strategy.exit("Stop (long SL/TP)", loss=stopLossValue, profit=takeProfitValue)   
//         if closeLongTrigger
//             strategy.close_all()    
//     if isPosLong 
//         if switchShortTrigger
//             strategy.close_all()   
//             strategy.entry("Short", strategy.short, comment="switch Short")
//             strategy.exit("Stop (short SL/TP)", loss=stopLossValue, profit=takeProfitValue) 
//         if closeShortTrigger
//             strategy.close_all()   

if inTimeframe()
    strategy.entry("Long", strategy.long,  comment="Entry Long", when=entryLongTrigger)
    strategy.close("Long", when=entryShortTrigger)
    strategy.entry("Short", strategy.short,  comment="Entry Short", when=entryShortTrigger)
    strategy.close("Short", when=entryLongTrigger)
    strategy.exit("Stop (short SL/TP)", loss=stopLossValue, profit=takeProfitValue, when=entryShortTrigger) 
    strategy.exit("Stop (long SL/TP)", loss=stopLossValue, profit=takeProfitValue, when=entryLongTrigger) 




अधिक