
यह रणनीति एक ट्रेंड ट्रैकिंग और रिवर्स ट्रेडिंग सिस्टम है जो मिश्रित औसत रेखाओं पर आधारित है। यह विभिन्न चक्रों की चलती औसत को जोड़कर और औसत रेखाओं के प्रति प्रतिक्रिया के साथ व्यापार के अवसरों की पहचान करता है। रणनीति का मूल मूल्य और औसत रेखा के बीच संबंधों को देखकर व्यापार के समय का न्याय करना है और जब कीमतें किसी विशेष गिरावट पर प्रतिक्रिया करती हैं।
रणनीति दो अलग-अलग अवधि (डिफ़ॉल्ट 20 और 30) के भारित या गणितीय औसत के माध्यम से एक मिश्रित औसत बनाने के लिए कई चलती औसत प्रकारों (ईएमए, टीईएमए, डीईएमए, डब्ल्यूएमए, एसएमए) के संयोजन का उपयोग करती है। जब कीमतें औसत रेखा के ऊपर होती हैं तो उन्हें एक उछाल माना जाता है, और जब वे औसत रेखा के नीचे होती हैं तो उन्हें एक गिरावट माना जाता है। रणनीति एक प्रवृत्ति की स्थापना के बाद कीमतों को औसत रेखा के पास वापस लाने के लिए इंतजार करती है।
यह एक रणनीति है जिसमें ट्रेंड ट्रैकिंग और रिवर्स ट्रेडिंग की अवधारणा को मिलाया गया है, जो ट्रेडिंग के अवसरों को पकड़ने के लिए मिश्रित औसत रेखा और मूल्य प्रतिक्रिया तंत्र के माध्यम से है। रणनीति का मुख्य लाभ इसकी लचीलापन और झूठे संकेतों को फ़िल्टर करने की क्षमता में है, लेकिन साथ ही साथ विभिन्न बाजार स्थितियों में पैरामीटर अनुकूलन के मुद्दों पर ध्यान देने की आवश्यकता है। उचित जोखिम नियंत्रण और निरंतर अनुकूलन सुधार के माध्यम से, रणनीति को वास्तविक व्यापार में स्थिर रिटर्न की उम्मीद है।
/*backtest
start: 2024-10-01 00:00:00
end: 2025-02-18 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Ultrajante MA Reaction Strategy", overlay=true, initial_capital=10000,
default_qty_type=strategy.percent_of_equity, default_qty_value=10)
// ===== Custom Functions for DEMA and TEMA =====
dema(src, length) =>
ema1 = ta.ema(src, length)
ema2 = ta.ema(ema1, length)
2 * ema1 - ema2
tema(src, length) =>
ema1 = ta.ema(src, length)
ema2 = ta.ema(ema1, length)
ema3 = ta.ema(ema2, length)
3 * ema1 - 3 * ema2 + ema3
// ===== Configuration Parameters =====
// MA Type Selection
maType = input.string(title="MA Type", defval="EMA", options=["SMA", "EMA", "WMA", "DEMA", "TEMA"])
// Parameters for composite periods
periodA = input.int(title="Period A", defval=20, minval=1)
periodB = input.int(title="Period B", defval=30, minval=1)
compMethod = input.string(title="Composite Method", defval="Average", options=["Average", "Weighted"])
// Reaction percentage (e.g., 0.5 means 0.5%)
reactionPerc = input.float(title="Reaction %", defval=0.5, step=0.1)
// ===== Composite Period Calculation =====
compPeriod = compMethod == "Average" ? math.round((periodA + periodB) / 2) : math.round((periodA * 0.6 + periodB * 0.4))
// ===== Moving Average Calculation based on selected type =====
ma = switch maType
"SMA" => ta.sma(close, compPeriod)
"EMA" => ta.ema(close, compPeriod)
"WMA" => ta.wma(close, compPeriod)
"DEMA" => dema(close, compPeriod)
"TEMA" => tema(close, compPeriod)
=> ta.ema(close, compPeriod) // Default value
plot(ma, color=color.blue, title="MA")
// ===== Trend Definition =====
trendUp = close > ma
trendDown = close < ma
// ===== Reaction Threshold Calculation =====
// In uptrend: expect the price to retrace to or below a value close to the MA
upThreshold = ma * (1 - reactionPerc / 100)
// In downtrend: expect the price to retrace to or above a value close to the MA
downThreshold = ma * (1 + reactionPerc / 100)
// ===== Quick Reaction Detection =====
// For uptrend: reaction is detected if the low is less than or equal to the threshold and the close recovers and stays above the MA
upReaction = trendUp and (low <= upThreshold) and (close > ma)
// For downtrend: reaction is detected if the high is greater than or equal to the threshold and the close stays below the MA
downReaction = trendDown and (high >= downThreshold) and (close < ma)
// ===== Trade Execution =====
if upReaction
// Close short position if exists and open long position
strategy.close("Short", comment="Close Short due to Bullish Reaction")
strategy.entry("Long", strategy.long, comment="Long Entry due to Bullish Reaction in Uptrend")
if downReaction
// Close long position if exists and open short position
strategy.close("Long", comment="Close Long due to Bearish Reaction")
strategy.entry("Short", strategy.short, comment="Short Entry due to Bearish Reaction in Downtrend")
// ===== Visualization of Reactions on the Chart =====
plotshape(upReaction, title="Bullish Reaction", style=shape.arrowup, location=location.belowbar, color=color.green, size=size.small, text="Long")
plotshape(downReaction, title="Bearish Reaction", style=shape.arrowdown, location=location.abovebar, color=color.red, size=size.small, text="Short")