OPEN-SOURCE SCRIPT
27 ALERT INFY EQ | Manual JSON Only

//version=6
indicator("27 ALERT INFY EQ | Manual JSON Only", overlay=true)
//────────────────────────────────────────────
// 🔧 USER INPUTS
//────────────────────────────────────────────
symbol_name = input.string("INFY", "Equity Symbol (for labels only)")
tradeMode = input.string("Intraday", "Trade Mode (for dashboard)", options=["Intraday","Delivery"])
// Paste your exact Dhan payloads below (must be single-line strings)
json_buy = input.string('{"secret":"hWMIU","alertType":"multi_leg_order","order_legs":[{"transactionType":"B","orderType":"MKT","quantity":"1","exchange":"NSE","symbol":"INFY","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":"INFY","instrument":"EQ","productType":"I","sort_order":"1","price":"0"}]}', "SELL JSON Script")
//────────────────────────────────────────────
// 📊 SIGNAL 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, 6, border_width=1)
if barstate.isfirst
table.cell(dash, 0, 0, "📊 " + symbol_name + " EQ", bgcolor=color.new(color.black, 60), text_color=color.white)
table.cell(dash, 0, 1, "Symbol")
table.cell(dash, 0, 2, "Position")
table.cell(dash, 0, 3, "Trend")
table.cell(dash, 0, 4, "Mode")
table.cell(dash, 0, 5, "Alert Type")
trendTxt = isBull ? "BULLISH" : isBear ? "BEARISH" : "NEUTRAL"
if barstate.islast
table.cell(dash, 1, 1, symbol_name)
table.cell(dash, 1, 2, inTrade ? "LONG" : "FLAT")
table.cell(dash, 1, 3, trendTxt)
table.cell(dash, 1, 4, tradeMode)
table.cell(dash, 1, 5, "MANUAL JSON")
indicator("27 ALERT INFY EQ | Manual JSON Only", overlay=true)
//────────────────────────────────────────────
// 🔧 USER INPUTS
//────────────────────────────────────────────
symbol_name = input.string("INFY", "Equity Symbol (for labels only)")
tradeMode = input.string("Intraday", "Trade Mode (for dashboard)", options=["Intraday","Delivery"])
// Paste your exact Dhan payloads below (must be single-line strings)
json_buy = input.string('{"secret":"hWMIU","alertType":"multi_leg_order","order_legs":[{"transactionType":"B","orderType":"MKT","quantity":"1","exchange":"NSE","symbol":"INFY","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":"INFY","instrument":"EQ","productType":"I","sort_order":"1","price":"0"}]}', "SELL JSON Script")
//────────────────────────────────────────────
// 📊 SIGNAL 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, 6, border_width=1)
if barstate.isfirst
table.cell(dash, 0, 0, "📊 " + symbol_name + " EQ", bgcolor=color.new(color.black, 60), text_color=color.white)
table.cell(dash, 0, 1, "Symbol")
table.cell(dash, 0, 2, "Position")
table.cell(dash, 0, 3, "Trend")
table.cell(dash, 0, 4, "Mode")
table.cell(dash, 0, 5, "Alert Type")
trendTxt = isBull ? "BULLISH" : isBear ? "BEARISH" : "NEUTRAL"
if barstate.islast
table.cell(dash, 1, 1, symbol_name)
table.cell(dash, 1, 2, inTrade ? "LONG" : "FLAT")
table.cell(dash, 1, 3, trendTxt)
table.cell(dash, 1, 4, tradeMode)
table.cell(dash, 1, 5, "MANUAL JSON")
开源脚本
本着TradingView的真正精神,此脚本的创建者将其开源,以便交易者可以查看和验证其功能。向作者致敬!虽然您可以免费使用它,但请记住,重新发布代码必须遵守我们的网站规则。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。
开源脚本
本着TradingView的真正精神,此脚本的创建者将其开源,以便交易者可以查看和验证其功能。向作者致敬!虽然您可以免费使用它,但请记住,重新发布代码必须遵守我们的网站规则。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。