
रणनीति एक ट्रेंड ट्रैकिंग ट्रेडिंग सिस्टम है जो क्रॉस-साइक्लोनिक विश्लेषण पर आधारित है, जो बाजार की प्रवृत्ति और गतिशीलता की पहचान करने के लिए ईएमए औसत और आरएसआई संकेतकों के साथ परिधि और दिन-रेखा स्तरों को जोड़ती है। रणनीति ट्रेडिंग अवसरों को पहचानती है और एटीआर-आधारित गतिशील स्टॉपलॉस का उपयोग करके जोखिम का प्रबंधन करती है। प्रणाली एक फंड मैनेजमेंट मॉडल को अपनाती है, जिसमें प्रत्येक ट्रेड के लिए खाते में 100% धन का उपयोग किया जाता है और 0.1% ट्रेडिंग प्रसंस्करण शुल्क पर विचार किया जाता है।
रणनीति का मूल तर्क निम्नलिखित प्रमुख तत्वों पर आधारित है:
यह एक पूरी तरह से संरचित, स्पष्ट रूप से तार्किक प्रवृत्ति ट्रैकिंग रणनीति है। यह रणनीति कई समय सीमा विश्लेषण और गतिशील संकेतक फ़िल्टरिंग के माध्यम से प्रमुख रुझानों को बेहतर ढंग से पकड़ने में सक्षम है। हालांकि कुछ अंतर्निहित जोखिम हैं, लेकिन पैरामीटर अनुकूलन और पूरक संकेतक जोड़ने के माध्यम से रणनीति में सुधार के लिए अभी भी बहुत जगह है। यह सलाह दी जाती है कि वास्तविक व्यापार से पहले पर्याप्त फीडबैक किया जाए और विशिष्ट बाजार की स्थिति के अनुसार पैरामीटर सेटिंग्स को समायोजित किया जाए।
/*backtest
start: 2024-02-21 00:00:00
end: 2025-02-18 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"BTC_USDT"}]
*/
// @version=6
strategy("Bitcoin Regime Filter Strategy", // Strategy name
overlay=true, // The strategy will be drawn directly on the price chart
initial_capital=10000, // Initial capital of 10000 USD
currency=currency.USDT, // Defines the currency used, USDT
default_qty_type=strategy.percent_of_equity, // Position size will be calculated as a percentage of equity
default_qty_value=100, // The strategy uses 100% of available capital for each trade
commission_type=strategy.commission.percent, // The strategy uses commission as a percentage
commission_value=0.1) // Transaction fee is 0.1%
// User input
res = input.timeframe(title = "Timeframe", defval = "W") // Higher timeframe for reference
len = input.int(title = "EMA Length", defval = 20) // EMA length input
marketTF = input.timeframe(title = "Market Timeframe", defval = "D") // Current analysis timeframe (D)
useRSI = input.bool(title = "Use RSI Momentum Filter", defval = false) // Option to use RSI filter
rsiMom = input.int(title = "RSI Momentum Threshold", defval = 70) // RSI momentum threshold (default 70)
// Custom function to output data
f_sec(_market, _res, _exp) => request.security(_market, _res, _exp[barstate.isrealtime ? 1 : 0])[barstate.isrealtime ? 0: 1]
// The f_sec function has three input parameters: _market, _res, _exp
// request.security = a Pine Script function to fetch market data, accessing OHLC data
// _exp[barstate.isrealtime ? 1 : 0] checks if the current bar is real-time, and retrieves the previous bar (1) or the current bar (0)
// [barstate.isrealtime ? 0 : 1] returns the value of request.security, with a real-time check on the bar
// Define time filter
dateFilter(int st, int et) => time >= st and time <= et
// The dateFilter function has two input parameters: st (start time) and et (end time)
// It checks if the current bar's time is between st and et
// Fetch EMA value
ema = ta.ema(close, len) // Calculate EMA with close prices and input length
htfEmaValue = f_sec(syminfo.tickerid, res, ema) // EMA value for high time frame, using f_sec function
// Fetch ATR value
atrValue = ta.atr(5)
// Check if price is above or below EMA
marketPrice = f_sec(syminfo.tickerid, marketTF, close)
regimeFilter = marketPrice > (htfEmaValue + (atrValue * 0.25)) // Compare current price with EMA in higher timeframe (with ATR dependency)
// Calculate RSI value
rsiValue = ta.rsi(close, 7)
// Bullish momentum filter
bullish = regimeFilter and (rsiValue > rsiMom or not useRSI)
// Set caution alert
caution = bullish and (ta.highest(high, 7) - low) > (atrValue * 1.5)
// Set momentum background color
bgCol = color.red
if bullish[1]
bgCol := color.green
if caution[1]
bgCol := color.orange
// Plot background color
plotshape(1, color = bgCol, style = shape.square, location = location.bottom, size = size.auto, title = "Momentum Strength")
plot(htfEmaValue, color = close > htfEmaValue ? color.green : color.red, linewidth = 2)
// Initialize trailing stop variable
var float trailStop = na
// Entry logic
if bullish and strategy.position_size == 0 and not caution
strategy.entry(id = "Buy", direction = strategy.long)
trailStop := na
// Trailing stop logic
temp_trailStop = ta.highest(low, 7) - (caution[1] ? atrValue * 0.2 : atrValue)
if strategy.position_size > 0
if temp_trailStop > trailStop or na(trailStop)
trailStop := temp_trailStop
// Exit logic
if (close < trailStop or close < htfEmaValue)
strategy.close("Buy", comment = "Sell")
// Plot stop loss line
plot(strategy.position_size[1] > 0 ? trailStop : na, style = plot.style_linebr, color = color.red, title = "Stoploss")