एमएसीडी संकेतक पर आधारित द्विदिशात्मक ट्रेडिंग रणनीति


निर्माण तिथि: 2023-12-07 17:11:52 अंत में संशोधित करें: 2023-12-07 17:11:52
कॉपी: 0 क्लिक्स: 829
1
ध्यान केंद्रित करना
1619
समर्थक

एमएसीडी संकेतक पर आधारित द्विदिशात्मक ट्रेडिंग रणनीति

अवलोकन

यह रणनीति MACD संकेतक पर आधारित एक द्वि-दिशात्मक ट्रेडिंग रणनीति को लागू करती है। यह MACD संकेतक पर गोल्ड फोर्क और डेड फोर्क के समय अलग-अलग अधिक और कम कर सकती है, और अन्य संकेतक निर्णयों के साथ मिलकर कुछ संकेतों को फ़िल्टर कर सकती है।

रणनीति सिद्धांत

यह रणनीति मुख्य रूप से MACD संकेतक का उपयोग करके द्वि-दिशात्मक व्यापार करती है। विशेष रूप से, यह तेजी से चलती औसत, धीमी गति से चलती औसत और MACD सिग्नल लाइन की गणना करती है। जब तेजी से चलती औसत पर धीमी गति से चलती औसत को पार करते हैं तो एक गोल्डफ़ॉर्क सिग्नल उत्पन्न होता है। जब तेजी से चलती औसत के नीचे धीमी गति से चलती औसत को पार करते हैं तो एक डेडफ़ॉर्क सिग्नल उत्पन्न होता है।

कुछ अमान्य संकेतों को फ़िल्टर करने के लिए, रणनीति ने फ़िल्टर के रूप में एक ± 30 रेंज भी सेट की है, जो केवल उस समय ट्रेडिंग सिग्नल को ट्रिगर करती है जब MACD स्तंभ रेखा इस सीमा से परे होती है। इसके अलावा, MACD स्तंभ रेखा की दिशा का निर्धारण समतल स्थिति में किया जाता है, केवल जब दो लगातार स्तंभों की दिशा बदल जाती है।

रणनीतिक लाभ

  • MACD सूचकांक को मुख्य ट्रेडिंग सिग्नल के रूप में उपयोग करना, जो द्वि-दिशात्मक शेयर बाजार की घटनाओं के लिए अधिक संवेदनशील है
  • फ़िल्टर जोड़े गए हैं ताकि कुछ अमान्य संकेतों को फ़िल्टर किया जा सके
  • दो लगातार स्तंभों की दिशा का निर्धारण करने के लिए एक समतल पोजीशन तर्क का उपयोग करना, कुछ हद तक झूठी तोड़फोड़ से बचा जा सकता है

रणनीतिक जोखिम

  • एमएसीडी सूचकांक अक्सर ट्रेडिंग सिग्नल उत्पन्न करने के लिए प्रवण होते हैं, जो अत्यधिक ट्रेडिंग आवृत्ति को जन्म दे सकते हैं
  • एकल सूचक रणनीति, सिग्नल में थोड़ी देरी से नुकसान हो सकता है
  • स्तंभ रेखा की दिशा का निर्धारण करने के लिए सम-अवसर तर्क पर्याप्त रूप से कठोर नहीं है, और सिग्नल के नुकसान का जोखिम हो सकता है

रणनीति अनुकूलन दिशा

  • अन्य संकेतकों के साथ संकेत की पुष्टि करने के लिए विचार किया जा सकता है, जैसे कि केडीजे सूचक, ब्रिन बैंड सूचक आदि
  • MACD को प्रतिस्थापित करने के लिए अन्य अधिक उन्नत मापदंडों पर शोध किया जा सकता है, जैसे कि KD
  • एकल घाटे को नियंत्रित करने के लिए स्टॉप लॉस और स्टॉप को सेट करने के लिए क्लियर लॉजिक को अनुकूलित किया जा सकता है

संक्षेप

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

]

रणनीति स्रोत कोड
/*backtest
start: 2022-11-30 00:00:00
end: 2023-12-06 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3

//Created by user ChrisMoody updated 4-10-2014
//Regular MACD Indicator with Histogram that plots 4 Colors Based on Direction Above and Below the Zero Line
//Update allows Check Box Options, Show MacD & Signal Line, Show Change In color of MacD Line based on cross of Signal Line.
//Show Dots at Cross of MacD and Signal Line, Histogram can show 4 colors or 1, Turn on and off Histogram.
//Special Thanks to that incredible person in Tech Support whoem I won't say you r name so you don't get bombarded with emails
//Note the feature Tech Support showed me on how to set the default timeframe of the indicator to the chart Timeframe, but also allow you to choose a different timeframe.
//By the way I fully disclose that I completely STOLE the Dots at the MAcd Cross from "TheLark"

strategy("MACD Strategy", overlay=false)
// study(title="CM_MacD_Ult_MTF", shorttitle="CM_Ult_MacD_MTF")
source = close
useCurrentRes = input(true, title="Use Current Chart Resolution?")
resCustom = input(title="Use Different Timeframe? Uncheck Box Above", defval="60")
smd = input(true, title="Show MacD & Signal Line? Also Turn Off Dots Below")
sd = input(true, title="Show Dots When MacD Crosses Signal Line?")
sh = input(true, title="Show Histogram?")
macd_colorChange = input(true,title="Change MacD Line Color-Signal Line Cross?")
hist_colorChange = input(true,title="MacD Histogram 4 Colors?")

res = useCurrentRes ? timeframe.period : resCustom

fastLength = input(12, minval=1), slowLength=input(26,minval=1)
signalLength=input(9,minval=1)

fastMA = ema(source, fastLength)
slowMA = ema(source, slowLength)

macd = fastMA - slowMA
signal = sma(macd, signalLength)
hist = macd - signal

outMacD = request.security(syminfo.tickerid, res, macd)
outSignal = request.security(syminfo.tickerid, res, signal)
outHist = request.security(syminfo.tickerid, res, hist)

histA_IsUp = outHist > outHist[1] and outHist > 0
histA_IsDown = outHist < outHist[1] and outHist > 0
histB_IsDown = outHist < outHist[1] and outHist <= 0
histB_IsUp = outHist > outHist[1] and outHist <= 0

//MacD Color Definitions
macd_IsAbove = outMacD >= outSignal
macd_IsBelow = outMacD < outSignal



// strategy.entry("Long", strategy.long, 1, when = shouldPlaceLong) 
       
// strategy.close("Long", shouldExitLong)
    

// strategy.entry("Short", strategy.short, 1, when = shouldPlaceShort) 
       
// strategy.close("Short", shouldExitShort)
    
    
isWithinZeroMacd = outHist < 30 and outHist > -30 

delta = hist
// shouldExitShort = false//crossover(delta, 0)    
// shouldExitLong = false//crossunder(delta, 0)

// if(crossover(delta, 0))// and not isWithinZeroMacd)
//     strategy.entry("Long", strategy.long, comment="Long")

// if (crossunder(delta, 0))// and not isWithinZeroMacd)
//     strategy.entry("Short", strategy.short, comment="Short")
    
shouldPlaceLong = crossover(delta, 0)
    
strategy.entry("Long", strategy.long, 1, when = shouldPlaceLong) 

shouldExitLong = not histA_IsUp and histA_IsDown

shouldExitShort = not histA_IsUp and not histA_IsDown and not histB_IsDown and histB_IsUp

shouldPlaceShort = crossunder(delta, 0)
strategy.entry("Short", strategy.short, 1, when = shouldPlaceShort) 
       
// plot_color = gray
plot_color = if(hist_colorChange)
	if(histA_IsUp)
	    aqua
	else
		if(histA_IsDown)
			//need to sell
// 			if(not isWithinZeroMacd)
// 			shouldExitLong = true
			    //   strategy.entry("Short", strategy.short, comment="Short")
			
			blue
		else
			if(histB_IsDown)
				red 
			else
				if(histB_IsUp)
					//need to buy
				// 	if(not isWithinZeroMacd)
				// 	shouldExitShort = true
					   // strategy.entry("Long", strategy.long, comment="Long")
					    
					    
					maroon
				else
					yellow
else
	gray


// plot_color = hist_colorChange ? histA_IsUp ? aqua : histA_IsDown ? blue : histB_IsDown ? red : histB_IsUp ? maroon :yellow :gray
macd_color = macd_colorChange ? macd_IsAbove ? lime : red : red
signal_color = macd_colorChange ? macd_IsAbove ? orange : orange : lime

circleYPosition = outSignal

plot(smd and outMacD ? outMacD : na, title="MACD", color=macd_color, linewidth=4)
plot(smd and outSignal ? outSignal : na, title="Signal Line", color=signal_color, style=line ,linewidth=2)
plot(sh and outHist ? outHist : na, title="Histogram", color=plot_color, style=histogram, linewidth=4)
plot(sd and cross(outMacD, outSignal) ? circleYPosition : na, title="Cross", style=circles, linewidth=4, color=macd_color)

// plot( isWithinZeroMacd ? outHist : na, title="CheckSmallHistBars", style=circles, linewidth=4, color=black)

hline(0, '0 Line',  linewidth=2, color=white)




strategy.close("Short", shouldExitShort)
strategy.close("Long", shouldExitLong)

// fastLength = input(12)
// slowlength = input(26)
// MACDLength = input(9)

// MACD = ema(close, fastLength) - ema(close, slowlength)
// aMACD = ema(MACD, MACDLength)
// delta = MACD - aMACD


// if (crossover(delta, 0))
   // strategy.entry("MacdLE", strategy.long, comment="MacdLE")

//if last two macd bars are higher than current, close long position

// if (crossunder(delta, 0))
   // strategy.entry("MacdSE", strategy.short, comment="MacdSE")

//if last two macd bars are higher than current, close long position

// plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)