Stock Market - Share Market

TradingView पर “EMA + RSI ब्रेकआउट स्ट्रैटेजी आदि का पूरा” कस्टम पाइन स्क्रिप्ट (Pine Script)

TradingView पर पाइन स्क्रिप्ट जोड़ने के लिए:

  1. TradingView पर लॉगिन करें: https://www.tradingview.com पर जाएं और अपने खाते में लॉगिन करें।
  2. चार्ट खोलें: अपने इच्छित स्टॉक या एसेट का चार्ट खोलें।
  3. Pine Script Editor खोलें: चार्ट के नीचे स्थित “Pine Editor” टैब पर क्लिक करें।
  4. स्क्रिप्ट पेस्ट करें: नीचे दी गई पाइन स्क्रिप्ट को कॉपी करें और Pine Editor में पेस्ट करें।
  5. स्क्रिप्ट सेव करें: “Save” बटन पर क्लिक करें और स्क्रिप्ट को एक नाम दें।
  6. चार्ट पर लागू करें: “Add to Chart” बटन पर क्लिक करें।

पाइन स्क्रिप्ट:

//@version=5
indicator("EMA + RSI ब्रेकआउट स्ट्रैटेजी", overlay=true)

// EMA सेटअप
shortEma = ta.ema(close, 20)
longEma = ta.ema(close, 50)

// RSI सेटअप
rsiValue = ta.rsi(close, 14)

// ब्रेकआउट और RSI कंडीशन
bullishCondition = close > shortEma and close > longEma and rsiValue > 40 and rsiValue < 70 and close > ta.highest(close, 20)[1]
bearishCondition = close < shortEma and close < longEma and rsiValue < 60 and rsiValue > 30 and close < ta.lowest(close, 20)[1]

// सिग्नल प्लॉटिंग
plotshape(series=bullishCondition, location=location.belowbar, color=color.green, style=shape.labelup, title="बुलिश सिग्नल", text="BUY")
plotshape(series=bearishCondition, location=location.abovebar, color=color.red, style=shape.labeldown, title="बेयरिश सिग्नल", text="SELL")

// EMA और RSI प्लॉटिंग
plot(shortEma, color=color.green, title="EMA 20")
plot(longEma, color=color.red, title="EMA 50")
hline(70, "RSI 70", color=color.red)
hline(30, "RSI 30", color=color.green)
plot(rsiValue, color=color.blue, title="RSI")

कैसे काम करता है:

  • EMA 20 और EMA 50: ये मूविंग एवरेजेस ट्रेंड की दिशा को दर्शाते हैं।(TradingView)
  • RSI (14): यह ओवरबॉट (70 से ऊपर) और ओवरसोल्ड (30 से नीचे) कंडीशन को पहचानने में मदद करता है।(TradingView)
  • ब्रेकआउट कंडीशन: जब प्राइस पिछले 20 कैंडल्स के उच्चतम स्तर को तोड़ता है और RSI 40 से ऊपर होता है, तो यह एक बुलिश सिग्नल होता है।(TradingView)
  • एंट्री सिग्नल: चार्ट पर “BUY” और “SELL” लेबल के रूप में दिखाई देंगे।(TradingView)

महत्वपूर्ण नोट्स:

  • स्टॉप-लॉस और टारगेट: इस स्क्रिप्ट में स्टॉप-लॉस और टारगेट शामिल नहीं हैं। आप इन्हें अपने ट्रेडिंग नियमों के अनुसार जोड़ सकते हैं।(TradingView)
  • बैकटेस्टिंग: इस स्क्रिप्ट को लाइव ट्रेडिंग में उपयोग करने से पहले बैकटेस्ट करना महत्वपूर्ण है।

इस स्क्रिप्ट में स्टॉप-लॉस, टारगेट, या अन्य इंडिकेटर्स जैसे MACD या Supertrend जोड़ सकते है

नीचे पाइन स्क्रिप्ट है, जिसमें निम्नलिखित सभी फीचर्स जोड़े गए हैं:

✅ अपडेटेड फीचर्स:

  1. Stop-Loss और Target अलर्ट्स (लाइन के रूप में)
  2. MACD इंडिकेटर (ट्रेंड कन्फर्मेशन के लिए)
  3. Supertrend (Trend direction filter)
  4. Buy/Sell signals (EMA + RSI ब्रेकआउट के आधार पर)

📌 Pine Script (TradingView के लिए)

//@version=5
indicator("EMA + RSI + MACD + Supertrend Strategy with SL/TP", overlay=true)

// === INPUTS === //
emaShort = input.int(20, title="EMA Short")
emaLong = input.int(50, title="EMA Long")
rsiPeriod = input.int(14, title="RSI Period")
macdFast = input.int(12, title="MACD Fast Length")
macdSlow = input.int(26, title="MACD Slow Length")
macdSignal = input.int(9, title="MACD Signal Smoothing")
atrLength = input.int(10, title="ATR Period for Supertrend")
factor = input.float(3.0, title="Supertrend Multiplier")
riskReward = input.float(2.0, title="Risk Reward Ratio")

// === INDICATORS === //
ema1 = ta.ema(close, emaShort)
ema2 = ta.ema(close, emaLong)
rsi = ta.rsi(close, rsiPeriod)

[macdLine, signalLine, _] = ta.macd(close, macdFast, macdSlow, macdSignal)
macdBull = macdLine > signalLine

atr = ta.atr(atrLength)
supertrendUp = (high + low) / 2 - (factor * atr)
supertrendDn = (high + low) / 2 + (factor * atr)
inUpTrend = close[1] > supertrendUp[1] ? (close > supertrendUp ? true : false) : false

// === ENTRY CONDITIONS === //
bullishBreakout = close > ema1 and close > ema2 and rsi > 40 and rsi < 70 and close > ta.highest(close, 20)[1] and macdBull and inUpTrend
bearishBreakdown = close < ema1 and close < ema2 and rsi < 60 and rsi > 30 and close < ta.lowest(close, 20)[1] and not macdBull and not inUpTrend

// === ENTRY PLOTTING === //
plotshape(bullishBreakout, location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(bearishBreakdown, location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")

// === SL & TARGET LEVELS === //
var float entryPrice = na
var float stopLoss = na
var float target = na

if bullishBreakout
    entryPrice := close
    stopLoss := close - atr
    target := close + (atr * riskReward)

if bearishBreakdown
    entryPrice := close
    stopLoss := close + atr
    target := close - (atr * riskReward)

// === PLOTTING SL/TP === //
plot(entryPrice, "Entry", color=color.gray, style=plot.style_linebr, linewidth=1)
plot(stopLoss, "Stop Loss", color=color.red, style=plot.style_linebr, linewidth=1)
plot(target, "Target", color=color.green, style=plot.style_linebr, linewidth=1)

// === EMA & Supertrend Visualization === //
plot(ema1, title="EMA 20", color=color.orange)
plot(ema2, title="EMA 50", color=color.red)

📊 स्क्रिप्ट के फायदे:


📌 आवश्यक निर्देश:

मैं इसका Auto Backtest Version भी बनाता हूँ, जिसमें जीतने/हारने वाले ट्रेड्स की संख्या भी दिखे।

नीचे एक Auto Backtest Script है जो आपकी ट्रेडिंग रणनीति पर आधारित है (EMA + RSI + MACD + Supertrend)। यह न केवल Buy/Sell संकेत देता है, बल्कि हर ट्रेड का Stop-Loss, Target और Profit/Loss स्थिति भी ऑटोमैटिकली ट्रैक करता है।


📊 Auto Backtesting Strategy (Pine Script v5)

//@version=5
strategy("EMA + RSI + MACD + Supertrend Strategy with Auto Backtest", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)

// === INPUTS === //
emaShort = input.int(20, title="EMA Short")
emaLong = input.int(50, title="EMA Long")
rsiPeriod = input.int(14, title="RSI Period")
macdFast = input.int(12, title="MACD Fast Length")
macdSlow = input.int(26, title="MACD Slow Length")
macdSignal = input.int(9, title="MACD Signal Smoothing")
atrLength = input.int(10, title="ATR Period for Supertrend")
factor = input.float(3.0, title="Supertrend Multiplier")
riskReward = input.float(2.0, title="Risk Reward Ratio")

// === INDICATORS === //
ema1 = ta.ema(close, emaShort)
ema2 = ta.ema(close, emaLong)
rsi = ta.rsi(close, rsiPeriod)
[macdLine, signalLine, _] = ta.macd(close, macdFast, macdSlow, macdSignal)
macdBull = macdLine > signalLine

atr = ta.atr(atrLength)
supertrendUp = (high + low) / 2 - (factor * atr)
supertrendDn = (high + low) / 2 + (factor * atr)
inUpTrend = close[1] > supertrendUp[1] ? (close > supertrendUp ? true : false) : false

// === ENTRY CONDITIONS === //
bullishBreakout = close > ema1 and close > ema2 and rsi > 40 and rsi < 70 and close > ta.highest(close, 20)[1] and macdBull and inUpTrend
bearishBreakdown = close < ema1 and close < ema2 and rsi < 60 and rsi > 30 and close < ta.lowest(close, 20)[1] and not macdBull and not inUpTrend

// === TRADE EXECUTION === //
if (bullishBreakout)
    sl = close - atr
    tp = close + atr * riskReward
    strategy.entry("BUY", strategy.long)
    strategy.exit("TP/SL Long", from_entry="BUY", stop=sl, limit=tp)

if (bearishBreakdown)
    sl = close + atr
    tp = close - atr * riskReward
    strategy.entry("SELL", strategy.short)
    strategy.exit("TP/SL Short", from_entry="SELL", stop=sl, limit=tp)

// === VISUALS === //
plotshape(bullishBreakout, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(bearishBreakdown, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")

plot(ema1, color=color.orange, title="EMA 20")
plot(ema2, color=color.red, title="EMA 50")

✅ स्क्रिप्ट क्या करती है:

  • Buy/Sell सिग्नल ऑटोमैटिक पहचानती है।
  • Entry पर Stop-Loss और Target सेट करती है (ATR आधारित)।
  • सभी ट्रेड का Backtest करती है: Win/Loss Ratio, Total Profit, Max Drawdown आदि।
  • यह Strategy Tester टैब में सभी रिजल्ट्स दिखाती है।

📋 उपयोग करने का तरीका:

  1. TradingView पर लॉगिन करें।
  2. किसी स्टॉक का चार्ट खोलें (जैसे: NIFTY, BANKNIFTY, BTC, etc)।
  3. Pine Editor में यह स्क्रिप्ट पेस्ट करें।
  4. Add to Chart क्लिक करें।
  5. Strategy Tester टैब खोलें – वहाँ आपको ट्रैड्स का पूरा रिजल्ट दिखेगा।

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button
error: Content is protected !!