PROTECTED SOURCE SCRIPT

DK 27 ALERT RELIANCE EQ Buy | Manual JSON Input Version

34
//version=6
indicator("27 ALERT RELIANCE EQ Buy | Manual JSON Input Version", overlay=true)

//────────────────────────────────────────────
// 📦 USER INPUTS
//────────────────────────────────────────────
quantity = input.string("1", "Quantity")
exchange = input.string("NSE", "Exchange")
symbol_name = input.string("RELIANCE", "Equity Symbol")
tradeMode = input.string("Intraday", "Trade Mode", options=["Intraday", "Delivery"])
dhan_secret = input.string("hWMIU", "Dhan Webhook Secret")

// Directly entered webhook JSON scripts 👇
json_buy = input.string('{"secret":"hWMIU","alertType":"multi_leg_order","order_legs":[{"transactionType":"B","orderType":"MKT","quantity":"1","exchange":"NSE","symbol":"RELIANCE","instrument":"EQ","productType":"I","sort_order":"1","price":"0"}]}', "BUY JSON Script")
json_sell = input.string('{"secret":"hWMIU","alertType":"multi_leg_order","order_legs":[{"transactionType":"S","orderType":"MKT","quantity":"1","exchange":"NSE","symbol":"RELIANCE","instrument":"EQ","productType":"I","sort_order":"1","price":"0"}]}', "SELL JSON Script")

productType = tradeMode == "Intraday" ? "I" : "D"

//────────────────────────────────────────────
// 📊 SIMPLE TREND LOGIC (Heikin Ashi + MACD)
//────────────────────────────────────────────
ha_close = (open + high + low + close) / 4.0
var float ha_open = na
ha_open := na(ha_open[1]) ? (open + close) / 2.0 : (ha_open[1] + ha_close[1]) / 2.0
isBull = ha_close > ha_open
isBear = ha_close < ha_open

[macdLine, signalLine, _] = ta.macd(close, 12, 26, 9)
macdBull = macdLine > signalLine
macdBear = macdLine < signalLine

//───────────────────────────────────────────
// 🚀 ENTRY / EXIT (One-Candle Confirmation)
//────────────────────────────────────────────
var bool inTrade = false
var string lastEvent = "Waiting..."

buyCondition = isBull and macdBull and not inTrade
sellCondition = isBear and macdBear and inTrade

if buyCondition
inTrade := true
lastEvent := "BUY"
label.new(bar_index, low, "🟢 BUY " + symbol_name, style=label.style_label_up, color=color.new(color.green, 0))
alert(json_buy, alert.freq_once_per_bar_close)

if sellCondition
inTrade := false
lastEvent := "SELL"
label.new(bar_index, high, "🔴 SELL " + symbol_name, style=label.style_label_down, color=color.new(color.red, 0))
alert(json_sell, alert.freq_once_per_bar_close)

//────────────────────────────────────────────
// 🧭 DASHBOARD
//────────────────────────────────────────────
var table dash = table.new(position.top_right, 2, 5, border_width=1)
if barstate.islast
table.cell(dash, 0, 0, "📊 RELIANCE EQ", bgcolor=color.new(color.black, 60), text_color=color.white)
table.cell(dash, 0, 1, "Symbol")
table.cell(dash, 1, 1, symbol_name)
table.cell(dash, 0, 2, "Position")
table.cell(dash, 1, 2, inTrade ? "LONG" : "FLAT")
table.cell(dash, 0, 3, "Trend")
table.cell(dash, 1, 3, isBull ? "BULLISH" : isBear ? "BEARISH" : "NEUTRAL")
table.cell(dash, 0, 4, "Last Event")
table.cell(dash, 1, 4, lastEvent)

כתב ויתור

המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.