You are on page 1of 2

/@version=5

strategy("Nifty and Bank Nifty Signals", shorttitle="NB Signals", overlay=true)

// Define your calculations for Nifty and Bank Nifty liquidity, premium, and delta
// Replace these with your specific formulas or calculations
niftyLiquidity = input(0, title="Nifty Liquidity")
niftyPremium = input(0, title="Nifty Premium")
niftyDelta = input(0, title="Nifty Delta")

bankNiftyLiquidity = input(0, title="Bank Nifty Liquidity")


bankNiftyPremium = input(0, title="Bank Nifty Premium")
bankNiftyDelta = input(0, title="Bank Nifty Delta")

// Calculate a composite Signal for Nifty and Bank Nifty


niftySignal = niftyLiquidity + niftyPremium + niftyDelta
bankNiftySignal = bankNiftyLiquidity + bankNiftyPremium + bankNiftyDelta

// Define buy and sell thresholds for Nifty and Bank Nifty
niftyBuyThreshold = input(1, title="Nifty Buy Threshold")
niftySellThreshold = input(-1, title="Nifty Sell Threshold")

bankNiftyBuyThreshold = input(1, title="Bank Nifty Buy Threshold")


bankNiftySellThreshold = input(-1, title="Bank Nifty Buy Threshold")

// Indicator code
T1 = time(timeframe.period, "0915-0916")
T2 = time(timeframe.period, "0915-1530")
Y = bar_index
Z1 = valuewhen(T1, bar_index, 0)
L = Y-Z1 + 1

SSPV = 0.00
SSNV = 0.00
pdw=0.00
ndw=0.00
total_w=0.00
for i = 1 to L-1
total_w:=high[i]-low[i]
positive = close[i]-low[i]
negative = high[i]- close[i]
pdw := (positive/total_w)*100
ndw := (negative/total_w)*100

SSPV := (volume[i]*pdw)/100 + SSPV

SSNV := (volume[i]*ndw)/100 + SSNV

total_v = SSPV +SSNV


Pos = (SSPV / total_v) *100
Neg = (SSNV / total_v) *100

bgc = SSPV>SSNV ? color.green: SSPV<SSNV ? color.red: color.white


barcolor (bgc)
var table sDisplay = table.new(position.top_right, 1, 5, bgcolor = color.aqua,
frame_width = 2, frame_color = color.black)

if barstate.islast
table.cell(sDisplay, 0, 0, "Today's Volume : " + tostring(total_v), text_color
= color.white, text_size=size.large, bgcolor=color.aqua)
table.cell(sDisplay, 0, 1, "Buyers Volume: " +tostring(round(SSPV)) ,
text_color = color.white, text_size=size.large, bgcolor=color.green)
table.cell(sDisplay, 0, 2, "Sellers Volume: " +tostring(round(SSNV)) ,
text_color = color.white, text_size=size.large, bgcolor=color.red)
table.cell(sDisplay, 0, 3, "Buyers Strength: " +tostring(round(Pos)) + "%" ,
text_color = color.white, text_size=size.large, bgcolor=color.green)
table.cell(sDisplay, 0, 4, "Sellers Strength: " +tostring(round(Neg)) + "%" ,
text_color = color.white, text_size=size.large, bgcolor=color.red)

// Plot buy and sell signals on the chart for Nifty and Bank Nifty
niftyBuySignal = niftySignal > niftyBuyThreshold
niftySellSignal = niftySignal < niftySellThreshold

bankNiftyBuySignal = bankNiftySignal > bankNiftyBuyThreshold


bankNiftySellSignal = bankNiftySignal < bankNiftySellThreshold

plotshape(niftyBuySignal, style=shape.triangleup, location=location.belowbar,


color=color.green, title="Nifty Buy Signal")
plotshape(niftySellSignal, style=shape.triangledown, location=location.abovebar,
color=color.red, title="Nifty Sell Signal")

plotshape(bankNiftyBuySignal, style=shape.triangleup, location=location.belowbar,


color=color.blue, title="Bank Nifty Buy Signal")
plotshape(bankNiftySellSignal, style=shape.triangledown,
location=location.abovebar, color=color.orange, title="Bank Nifty Sell Signal")

You might also like