//@version=5
indicator('KIND Algo Setup [Aura]', 'Super Algo + Market Sentiment V1.7', true)
// Hardcoded values for hidden parameters
candle_stability_index_param = 0.5 // Fixed value for Candle Stability Index
rsi_index_param = 70 // Fixed value for RSI Index
candle_delta_length_param = 6 // Fixed value for Candle Delta Length
disable_repeating_signals_param = input.bool(true, 'Disable Repeating Signals',
group='Technical', tooltip='Removes repeating signals. Useful for removing clusters
of signals and general clarity')
//------------------------------------------------------------
// Inputs
//------------------------------------------------------------
tip = "Those Bottoms will be Shown in which Krypton EMA is in Oversold Zone (Below
-50)
\nAnd\n
Those Tops will be Shown in which Krypton EMA is in Overbought Zone (Above
+50)"
//------------------------------------------------------------
hist = input.bool(true, "Show Historical Top Bottom")
relEx = input.bool(false, "Show Only Relevant Exits")
Krypron = input.bool(false, "Krypton Fear And Greed Filter", tip)
slt1 = input.string('▲ Bottom', 'Signal Label Text')
slt2 = input.string('▼ TOP', 'Signal Label Text')
rsiLengthInput = input.int(20, minval=1, title="RSI Length", group="RSI Settings")
rsiSourceInput = input.source(close, "Source", group="RSI Settings")
src = input.string('High/Low', 'Source', ['High/Low', 'Open/Close'])
phlb = input.int(10, 'Period For Highest/Lowest Bar', 2)
resCol = input.color(color.red, 'Resistance Color')
supCol = input.color(color.lime, 'Support Color')
factor = input.float(4.0, "SuperTrend Factor", minval = 0.01, step = 0.01)
atrPeriod = input.int(10, "SuperTrend Period", minval = 1)
macd_length_fast = input.int(defval=12, minval=1, title="MACD Fast Length")
macd_length_slow = input.int(defval=26, minval=1, title="MACD Slow Length")
macd_length_signal = input.int(defval=9, minval=1, title="MACD Signal Length")
ema_length = input.int(defval=13, minval=1, title="EMA Length")
//atr for book profit
atr_length = input.int(20, title="ATR Length")
atr_multiplier = input.float(1, title="ATR Multiplier for Book Profit")
atr_value = ta.atr(atr_length)
//------------------------------------------------------------
// Calculations
//------------------------------------------------------------
// Function
ma(source, length, type) =>
switch type
"SMA" => ta.sma(source, length)
"Bollinger Bands" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
"SMMA (RMA)" => ta.rma(source, length)
"WMA" => ta.wma(source, length)
"VWMA" => ta.vwma(source, length)
// RSI
up = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)
down = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
[supertrend, direction] = ta.supertrend(factor, atrPeriod)
supertrend := barstate.isfirst ? na : supertrend
source = close
macd_ma_fast = ta.ema(source, macd_length_fast)
macd_ma_slow = ta.ema(source, macd_length_slow)
macd = macd_ma_fast - macd_ma_slow
macd_signal = ta.ema(macd, macd_length_signal)
macd_histogram = macd - macd_signal
ema = ta.ema(source, ema_length)
elder_bulls = (ema[0] > ema[1]) and (macd_histogram[0] > macd_histogram[1])
elder_bears = (ema[0] < ema[1]) and (macd_histogram[0] < macd_histogram[1])
elder_color = elder_bulls ? color.green
: elder_bears ? color.rgb(255, 0, 0)
: color.blue
BullRev = ta.crossover(rsi, 30)
BearRev = ta.crossunder(rsi, 70)
vwap = timeframe.isintraday ? ta.vwap(hlc3) : na
newDay = timeframe.change('D')
pvwap = ta.valuewhen(newDay, vwap[1], 0)
ema9 = ma(close, 9, "EMA")
ema20 = ma(close, 20, "EMA")
ema50 = ma(close, 50, "EMA")
ema200 = ma(close, 200, "EMA")
length = 20
maType = "SMA"
BBsrc = close
mult = 2.0
offset = 0
basis = ma(BBsrc, length, maType)
dev = mult * ta.stdev(BBsrc, length)
upper = basis + dev
lower = basis - dev
pdh = request.security(syminfo.tickerid, "D", high[1], barmerge.gaps_off,
barmerge.lookahead_on)
pdl = request.security(syminfo.tickerid, "D", low[1], barmerge.gaps_off,
barmerge.lookahead_on)
rc = open > close
gc = open < close
bh = math.max(open, close)
bl = math.min(open, close)
bm = (open+close)/2
mx = math.max(high, high[1])
mn = math.min(low, low[1])
var sup = low
var res = high
HSrc = src == 'High/Low' ? high : bh
LSrc = src == 'High/Low' ? low : bl
ph = ta.pivothigh(HSrc, phlb - 1,0)
pl = ta.pivotlow(LSrc, phlb - 1,0)
if not na(pl)
sup := pl
if not na(ph)
res := ph
rsi2 = ta.rsi(close, 14)
g_kr = "Krypton Settings"
a = input(10, 'Percent K Length', group = g_kr)
b = input(3, 'Percent D Length', group = g_kr)
ob = input(45, 'Overbought', group = g_kr)
os = input(-45, 'Oversold', group = g_kr)
// Range Calculation
ll = ta.lowest(low, a)
hh = ta.highest(high, a)
diff = hh - ll
rdiff = close - (hh + ll) / 2
avgrel = ta.ema(ta.ema(rdiff, b), b)
avgdiff = ta.ema(ta.ema(diff, b), b)
// SMI calculations
SMI = avgdiff != 0 ? avgrel / (avgdiff / 2) * 100 : 0
SMIsignal = ta.ema(SMI, b)
emasignal = ta.ema(SMI, 4)
level_40 = ob
level_40smi = SMIsignal > level_40 ? SMIsignal : level_40
level_m40 = os
level_m40smi = SMIsignal < level_m40 ? SMIsignal : level_m40
KryB = Krypron ? emasignal <= level_m40 : true
KryS = Krypron ? emasignal >= level_40 : true
stable = math.abs(open-close) / ta.tr > 0.5
isB = gc and rc[1]
and bh > bh[1]
and rsi2 < 50
and stable
and bh < close[5]
and KryB
isS = rc and gc[1]
and bl < bl[1]
and rsi2 > 50
and stable
and bl > close[5]
and KryS
var pos = 0
if isB
pos := 1
if isS
pos := -1
shpUp = ta.crossover(close,upper)
shpDn = ta.crossover(close,lower)
bsl = relEx ? pos[1] > 0 and low < sup[1] : false
ssl = relEx ? pos[1] < 0 and high > res[1] : false
exb = relEx ? pos[1] > 0 and shpUp : shpUp
exs = relEx ? pos[1] < 0 and shpDn : shpDn
if bsl or ssl or exb or exs
pos := 0
//------------------------------------------------------------
// Outputs
//------------------------------------------------------------
plotshape(BullRev
, 'Bull Reversal'
, shape.labelup
, location.belowbar
, color.green
, 0
, 'R'
, color.white
, size = size.small
, display = display.none)
plotshape(BearRev
, 'Bear Reversal'
, shape.labeldown
, location.abovebar
, color.red
, 0
, 'R'
, color.white
, size = size.small
, display = display.none)
plot(res
, "Plot"
, res == res[1] ? resCol : na
, 1
, plot.style_line)
plot(sup
, "Plot"
, sup == sup[1] ? supCol : na
, 1
, plot.style_line)
plot(vwap
, 'VWAP'
, color.blue
, 2)
plot(pvwap
, 'Prev Day VWAP'
, color.teal
, 2
, display = display.none)
plot(supertrend
, "SuperTrend"
, direction < 0 ? color.green : color.red
, 2
, display = display.none)
barcolor(elder_color)
plot(ema9, "EMA 9", #21a3f3, display = display.none)
plot(ema20, "EMA 20", color.green, display = display.none)
plot(ema50, "EMA 50", color.rgb(188, 8, 182, 11), display = display.none)
plot(ema200, "EMA 200", #ff0000, 2)
plot(upper, color=color.red, offset = offset, display = display.none)
plot(lower, color=color.red, offset = offset, display = display.none)
plotshape(exb
, 'Shapes'
, shape.xcross
, location.abovebar
, color.red
, 0
, 'Exit'
, size = size.tiny)
plotshape(exs
, 'Shapes'
, shape.xcross
, location.belowbar
, color.red
, 0
, 'Exit'
, size = size.tiny)
plotshape(bsl
, 'Buy SL'
, shape.xcross
, location.belowbar
, color.red
, 0
, 'SL'
, size = size.tiny
, editable = false)
plotshape(ssl
, 'Sell SL'
, shape.xcross
, location.abovebar
, color.red
, 0
, 'SL'
, size = size.tiny
, editable = false)
plot(pdh
, "Previous Day High"
, #ff0000
, 2
, display = display.none)
plot(pdl
, "Previous Day Low"
, #13d71a
, 2
, display = display.none)
var Blb = array.new_label()
var Slb = array.new_label()
if isB
Blb.push(label.new(bar_index
, low
, slt1
, xloc.bar_index
, color = color.rgb(1,154,6)
, textcolor = color.white
, style = label.style_label_up
, size = size.normal))
if isS
Slb.push(label.new(bar_index
, high
, slt2
, xloc.bar_index
, color = color.rgb(187,5,5)
, textcolor = color.white
, style = label.style_label_down
, size = size.normal))
if not hist
if Blb.size() > 5
label.delete(Blb.shift())
if Slb.size() > 5
label.delete(Slb.shift())
// Alerts
alertcondition(isB, "BUY Alert", "BUY Alert", alert.freq_once_per_bar_close)
alertcondition(isS, "SELL Alert", "SELL Alert", alert.freq_once_per_bar_close)
alertcondition(isB, "CALL BUY", "CALL BUY", alert.freq_once_per_bar_close)
alertcondition(isS, "PUT BUY", "PUT BUY", alert.freq_once_per_bar_close)
trade(y, txt) =>
var line ln = na
var label lb = na
show = isB or isS
ext = ta.barssince(show) < 5
state = 0
state := isB ? 1 : isS ? -1 : state[1]
_sty = isB ? label.style_label_down : label.style_label_up
css = isB ? color.blue : color.red
if show
ln.delete()
lb.delete()
ln := line.new(bar_index, y , bar_index + 5, y ,
color = css , style = line.style_dotted , width = 2)
lb := label.new(bar_index, y, txt , color = css, textcolor = color.white,
style = _sty, size = size.small)
if ext
ln.set_x2(bar_index + 5)
if (state == 1 and close > y)
or (state == -1 and close < y)
lb.set_color(color.green)
En0 = isB ? low[1] : high[1]
Risk = isB ? close - En0 : En0 - close
k = isB ? 1 : -1
var Tg1 = 0.
var Tg2 = 0.
var Tg3 = 0.
if isB or isS
Tg1 := En0 + k * 2.618 * Risk
Tg2 := En0 + k * 3.618 * Risk
Tg3 := En0 + k * 5.236 * Risk
trade(Tg1 , "Target 1")
trade(Tg2 , "Target 2")
trade(Tg3 , "Target 3")
var last_signal = ''
var float buy_entry_price = na
var float sell_entry_price = na
var bool buy_label_plotted = false
var bool sell_label_plotted = false
GREEN = #388e3c
RED = #b22833
TRANSPARENT = color.rgb(0, 0, 0, 100)
label_size = input.string('normal', 'Label Size', options=['huge', 'large',
'normal', 'small', 'tiny'], group='Cosmetic')
label_style = input.string('text bubble', 'Label Style', ['text bubble',
'triangle', 'arrow'], group='Cosmetic')
buy_label_color = input(GREEN, 'BUY Label Color', inline='Highlight',
group='Cosmetic')
sell_label_color = input(RED, 'SELL Label Color', inline='Highlight',
group='Cosmetic')
label_text_color = input(color.white, 'Label Text Color', inline='Highlight',
group='Cosmetic')
if isB and (disable_repeating_signals_param ? (last_signal != 'buy' ? true : na) :
true)
buy_entry_price := close
buy_label_plotted := false // Reset label plotted flag when a new buy signal
occurs
if label_style == 'text bubble'
label.new(isB ? bar_index : na, low, '▲ Bottom', color=buy_label_color,
style=label.style_label_up, textcolor=label_text_color, size=label_size)
else if label_style == 'triangle'
label.new(isB ? bar_index : na, low, '▲ Bottom', yloc=yloc.belowbar,
color=buy_label_color, style=label.style_triangleup, textcolor=TRANSPARENT,
size=label_size)
else if label_style == 'arrow'
label.new(isB ? bar_index : na, low, '▲ Bottom', yloc=yloc.belowbar,
color=buy_label_color, style=label.style_arrowup, textcolor=TRANSPARENT,
size=label_size)
last_signal := 'buy'
if isS and (disable_repeating_signals_param ? (last_signal != 'sell' ? true : na) :
true)
sell_entry_price := close
sell_label_plotted := false // Reset label plotted flag when a new sell signal
occurs
if label_style == 'text bubble'
label.new(isS ? bar_index : na, high, '▼ TOP', color=sell_label_color,
style=label.style_label_down, textcolor=label_text_color, size=label_size)
else if label_style == 'triangle'
label.new(isS ? bar_index : na, high, '▼ TOP', yloc=yloc.abovebar,
color=sell_label_color, style=label.style_triangledown, textcolor=TRANSPARENT,
size=label_size)
else if label_style == 'arrow'
label.new(isS ? bar_index : na, high, '▼ TOP', yloc=yloc.abovebar,
color=sell_label_color, style=label.style_arrowdown, textcolor=TRANSPARENT,
size=label_size)
last_signal := 'sell'
// Book profit labels based on ATR, only plot once
if not na(buy_entry_price) and not buy_label_plotted
buy_profit_target = buy_entry_price + atr_multiplier * atr_value
if close >= buy_profit_target
label.new(bar_index, high, "Book Profit", color=color.blue,
style=label.style_label_down, textcolor=color.white, size=size.small)
buy_label_plotted := true // Mark label as plotted
if not na(sell_entry_price) and not sell_label_plotted
sell_profit_target = sell_entry_price - atr_multiplier * atr_value
if close <= sell_profit_target
label.new(bar_index, low, "Book Profit", color=color.blue,
style=label.style_label_up, textcolor=color.white, size=size.small)
sell_label_plotted := true // Mark label as plotted
//------------------------------------------------------------
//------------------------------------------------------------
//------------------------------------------------------------
// === Trend Continuation Candles ===
showContinuation = input.bool(true, "Show Continuation Candles", group="Trend
Continuation")
continuationColor = input.color(color.black, "Continuation Candle Color",
group="Trend Continuation")
// Determine trend continuation conditions
uptrendContinues = close > open and close[1] > open[1] and close > close[1]
downtrendContinues = close < open and close[1] < open[1] and close < close[1]
// Plot continuation candles
plotcandle(showContinuation and uptrendContinues ? open : na,
showContinuation and uptrendContinues ? high : na,
showContinuation and uptrendContinues ? low : na,
showContinuation and uptrendContinues ? close : na,
title="Uptrend Continuation",
color=continuationColor,
wickcolor=continuationColor,
editable=false)
plotcandle(showContinuation and downtrendContinues ? open : na,
showContinuation and downtrendContinues ? high : na,
showContinuation and downtrendContinues ? low : na,
showContinuation and downtrendContinues ? close : na,
title="Downtrend Continuation",
color=continuationColor,
wickcolor=continuationColor,
editable=false)
//---------------------------------------------------------------------------------
-------------------------------------------
//Never Search this script_bcz this is
insane-----------------------------------------------------------------------------
----
//---------------------------------------------------------------------------------
-------------------------------------------
// Function to format numbers with k, M, etc.
formatVolume(vol) =>
vol == na ? na :
vol >= 1000000000 ? str.tostring(math.round(vol / 1000000000, 1)) + "B" :
vol >= 1000000 ? str.tostring(math.round(vol / 1000000, 1)) + "M" :
vol >= 1000 ? str.tostring(math.round(vol / 1000, 1)) + "k" :
str.tostring(vol)
getVolume(tf) =>
priceDiff = close - open
buyVol = request.security(syminfo.tickerid, tf, priceDiff > 0 ? volume : 0)
sellVol = request.security(syminfo.tickerid, tf, priceDiff < 0 ? volume : 0)
netVol = buyVol - sellVol
diff = buyVol + sellVol != 0 ? (netVol / (buyVol + sellVol)) * 100 : na
sentiment = diff > 0 ? "Bullish" : diff < 0 ? "Bearish" : "Neutral"
[buyVol, sellVol, netVol, diff, sentiment]
// Timeframes
[bv5, sv5, nv5, df5, st5] = getVolume("5")
[bv15, sv15, nv15, df15, st15] = getVolume("15")
[bv30, sv30, nv30, df30, st30] = getVolume("30")
[bv60, sv60, nv60, df60, st60] = getVolume("60")
[bv240, sv240, nv240, df240, st240] = getVolume("240")
[bvD, svD, nvD, dfD, stD] = getVolume("D")
// Totals
totalBuy = bv5 + bv15 + bv30 + bv60 + bv240 + bvD
totalSell = sv5 + sv15 + sv30 + sv60 + sv240 + svD
totalNet = totalBuy - totalSell
totalDiff = totalBuy + totalSell != 0 ? (totalNet / (totalBuy + totalSell)) * 100 :
na
overallSent = totalDiff > 0 ? "Bullish" : totalDiff < 0 ? "Bearish" : "Neutral"
// Table
var table t = table.new(position.top_right, 6, 8, border_width=1)
// Function to show rows with sentiment backgrounds
showRow(row, label, bv, sv, nv, df, sent) =>
// Set background colors based on sentiment
bgColor = sent == "Bullish" ? color.new(color.green, 80) :
sent == "Bearish" ? color.new(color.red, 80) :
color.new(color.gray, 80)
table.cell(t, 0, row, label, bgcolor=bgColor)
table.cell(t, 1, row, formatVolume(bv), bgcolor=bgColor,
text_color=color.green)
table.cell(t, 2, row, formatVolume(sv), bgcolor=bgColor, text_color=color.red)
table.cell(t, 3, row, formatVolume(nv), bgcolor=bgColor) // Now properly
formatted
table.cell(t, 4, row, str.tostring(df, "#.00") + "%", bgcolor=bgColor)
table.cell(t, 5, row, sent, bgcolor=bgColor)
// Update table
table.clear(t, 0, 0)
// Header
headerBg = color.new(#263238, 0)
table.cell(t, 0, 0, "TF", bgcolor=headerBg, text_color=color.white)
table.cell(t, 1, 0, "Buy", bgcolor=headerBg, text_color=color.white)
table.cell(t, 2, 0, "Sell", bgcolor=headerBg, text_color=color.white)
table.cell(t, 3, 0, "Net", bgcolor=headerBg, text_color=color.white)
table.cell(t, 4, 0, "Diff%", bgcolor=headerBg, text_color=color.white)
table.cell(t, 5, 0, "Sentiment", bgcolor=headerBg, text_color=color.white)
// Data rows
showRow(1, "5min", bv5, sv5, nv5, df5, st5)
showRow(2, "15min", bv15, sv15, nv15, df15, st15)
showRow(3, "30min", bv30, sv30, nv30, df30, st30)
showRow(4, "1h", bv60, sv60, nv60, df60, st60)
showRow(5, "4h", bv240, sv240, nv240, df240, st240)
showRow(6, "1d", bvD, svD, nvD, dfD, stD)
// Overall row with sentiment background
overallBg = overallSent == "Bullish" ? color.new(color.green, 70) :
overallSent == "Bearish" ? color.new(color.red, 70) :
color.new(color.gray, 70)
table.cell(t, 0, 7, "Overall", bgcolor=headerBg, text_color=color.white)
table.cell(t, 1, 7, formatVolume(totalBuy), bgcolor=overallBg,
text_color=color.white)
table.cell(t, 2, 7, formatVolume(totalSell), bgcolor=overallBg,
text_color=color.white)
table.cell(t, 3, 7, formatVolume(totalNet), bgcolor=overallBg,
text_color=color.white)
table.cell(t, 4, 7, str.tostring(totalDiff, "#.00") + "%", bgcolor=overallBg,
text_color=color.white)
table.cell(t, 5, 7, overallSent, bgcolor=overallBg, text_color=color.white)
// =============================================
// Part 3: Zero Lag Trend Signals (Tight to Candles)
// =============================================
length_zlt = input.int(70, "Length", group="Zero Lag Trend Signals")
mult_zlt = input.float(1.2, "Band Multiplier", group="Zero Lag Trend Signals")
green_zlt = input.color(#002aff, "Bullish Color", group="Zero Lag Trend Signals")
red_zlt = input.color(#002aff, "Bearish Color", group="Zero Lag Trend Signals")
src_zlt = close
lag_zlt = math.floor((length_zlt - 1) / 2)
zlema = ta.ema(src_zlt + (src_zlt - src_zlt[lag_zlt]), length_zlt)
volatility = ta.highest(ta.atr(length_zlt), length_zlt*3) * mult_zlt
var trend = 0
if ta.crossover(close, zlema+volatility)
trend := 1
if ta.crossunder(close, zlema-volatility)
trend := -1
// Calculate precise positioning
arrowOffset = -2 // Moves arrows left, closer to candle body
arrowYPosBull = low * 0.999 // Slightly below candle low for buys
arrowYPosBear = high * 1.001 // Slightly above candle high for sells
// Plot arrows tightly attached to candles
plotshape(ta.crossunder(trend, 0) ? arrowYPosBear : na,
"Bearish Trend",
shape.labeldown,
location.absolute,
red_zlt,
text = "▼",
textcolor = color.white,
size = size.tiny,
offset = arrowOffset)
plotshape(ta.crossover(trend, 0) ? arrowYPosBull : na,
"Bullish Trend",
shape.labelup,
location.absolute,
green_zlt,
text = "▲",
textcolor = color.white,
size = size.tiny,
offset = arrowOffset)
// === Branding Table ===
var table brandingTable = table.new(position.top_center, 1, 1, border_width=1,
frame_color=color.black, bgcolor=color.white)
table.cell(brandingTable, 0, 0, "Telegram & Youtube[Setting's] Join :
@TrendPulseNXT", bgcolor=color.white, text_color=color.black, text_size=size.small)