You are on page 1of 3

//@version=5

//Pressure Indicator
indicator("Pressure - Buying and Selling")

//Pressure Length
length = input(8, "Pressure Length", group = "Pressure Settings")

//Pressure
cond1 = high - close[1] ? high - close[1] : 0
cond2 = close[1] - low ? close[1] - low : 0

numerator = math.sum(cond1, length) + math.sum(cond2, length)


denominator = (numerator + math.sum(cond2, length)) + math.sum(high - close,
length)

pressure = (numerator / denominator) * 100

//Plot the Pressure Line


plot(pressure, "Pressure Line", color = color.new(color.white, 0), linewidth = 2)

//Moving Averages
ma(pressure, length, type) =>
switch type
"SMA" => ta.sma (pressure, length)
"EMA" => ta.ema (pressure, length)
"VWMA" => ta.vwma (pressure, length)
"ALMA" => ta.alma (pressure, length, 0.85, 6)

ma_Type1 = input.string("EMA", title = "MA Type 1", group = "MA Settings", options
= ["SMA", "EMA", "VWMA", "ALMA"])
ma_Type2 = input.string("SMA" , title = "MA Type 2", group = "MA Settings",
options = ["SMA", "EMA", "VWMA", "ALMA"])
ma_Type3 = input.string("VWMA" , title = "MA Type 3", group = "MA Settings",
options = ["SMA", "EMA", "VWMA", "ALMA"])
ma_Length = input (27 , title = "MA Length", group = "MA Settings"
)

pressure_Ma1 = ma(pressure, ma_Length, ma_Type1)


pressure_Ma2 = ma(pressure, ma_Length, ma_Type2)
pressure_Ma3 = ma(pressure, ma_Length, ma_Type3)

//Plot the Moving Averages


plot(pressure_Ma1, "Pressure Moving Average 1", color = color.new(color.blue , 0),
display = display.none)
plot(pressure_Ma2, "Pressure Moving Average 2", color = color.new(#ff622e , 0),
display = display.none)
plot(pressure_Ma3, "Pressure Moving Average 3", color = color.new(#a8ff2e , 0),
display = display.none)

//MA Bands
multiplier = input.float(0.1, "MA Bands Multiplier", step = 0.01, group = "MA Bands
Settings")

ma_Band_Up = pressure_Ma1 + (pressure_Ma1 * multiplier)


ma_Band_Dn = pressure_Ma1 - (pressure_Ma1 * multiplier)
//Plot Bands
up_Band = plot(ma_Band_Up, "MA Up Band" , color = color.new(color.gray, 50),
display = display.none)
down_Band = plot(ma_Band_Dn, "MA Down Band", color = color.new(color.gray, 50),
display = display.none)

//Fill Bands
fill(up_Band, down_Band, title = "MA Bands Tunnel", color = color.new(color.gray,
92), display = display.none)

//Standard Deviation Bands


dev_Multiplier = input.float(4.7, "Standard Deviation Multiplier", step = 0.1,
group = "Standard Deviation Bands Settings")
std_Deviation = ta.stdev(pressure_Ma1, ma_Length)

dev_Ma_Band_Up = pressure_Ma1 + (std_Deviation * dev_Multiplier)


dev_Ma_Band_Dn = pressure_Ma1 - (std_Deviation * dev_Multiplier)

//Plot Standard Deviation Bands


dev_Up_Band = plot(dev_Ma_Band_Up, "Standard Deviation Up Band" , color =
color.new(color.blue, 80))
dev_Down_Band = plot(dev_Ma_Band_Dn, "Standard Deviation Down Band", color =
color.new(color.blue, 80))

//Fill Standard Deviation Bands


fill(dev_Up_Band, dev_Down_Band, title = "Standard Deviation Bands Tunnel", color =
color.new(color.blue, 90))

//Levels
h0 = input(35, group = "Levels Settings")
h1 = input(40, group = "Levels Settings")
h2 = input(60, group = "Levels Settings")
h3 = input(65, group = "Levels Settings")
h4 = input(50, group = "Levels Settings")

//Plot Levels
top = plot(h3, "Top" , color = color.new(#089981 , 0 ))
over_Bought = plot(h2, "Overbought" , color = color.new(color.gray , 0 ))
over_Sold = plot(h1, "Oversold" , color = color.new(color.gray , 0 ))
bottom = plot(h0, "Bottom" , color = color.new(#089981 , 0 ))
middle = plot(h4, "Middle Line", color = color.new(color.yellow, 50))

//Pressure Line Crossing Overbought and Oversold Levels


crossing_Up_Oversold = ta.crossover (pressure, h1)
crossing_Down_Overbought = ta.crossunder(pressure, h2)

//Fills for Pressure Line Crossing Overbought and Oversold Levels - Top and Bottom
Fills are Crossing Signals
fill(top , over_Bought, color = crossing_Down_Overbought ? color.new(color.red ,
0) : na, title = "Crossing Down Overbought")
fill(bottom, over_Sold , color = crossing_Up_Oversold ? color.new(color.lime,
0) : na, title = "Crossing Up Oversold" )

//Levels for Buying and Selling Pressure


l1 = input(41, "Buying Pressure Level 1" , group = "Buying Pressure Levels
Settings" )
l2 = input(42, "Buying Pressure Level 2" , group = "Buying Pressure Levels
Settings" )
l3 = input(43, "Buying Pressure Level 3" , group = "Buying Pressure Levels
Settings" )
l4 = input(44, "Buying Pressure Level 4" , group = "Buying Pressure Levels
Settings" )
l5 = input(59, "Selling Pressure Level 1", group = "Selling Pressure Levels
Settings")
l6 = input(58, "Selling Pressure Level 2", group = "Selling Pressure Levels
Settings")
l7 = input(57, "Selling Pressure Level 3", group = "Selling Pressure Levels
Settings")
l8 = input(56, "Selling Pressure Level 4", group = "Selling Pressure Levels
Settings")

//Buying and Selling Pressure 1


buy_Pressure = ta.crossover (pressure, l1) or ta.crossover (pressure, l2) or
ta.crossover (pressure, l3) or ta.crossover (pressure, l4)
sell_Pressure = ta.crossunder(pressure, l5) or ta.crossunder(pressure, l6) or
ta.crossunder(pressure, l7) or ta.crossunder(pressure, l8)

//Buying and Selling Pressure 2


buy_Pressure2 = ta.crossover (pressure, pressure[4]) and pressure < 48
sell_Pressure2 = ta.crossunder(pressure, pressure[4]) and pressure > 52

//Buying and Selling Pressure 3 (Pressure Line crossing Standard Deviation Bands)
buy_Pressure3 = ta.crossover (pressure, dev_Ma_Band_Dn)
sell_Pressure3 = ta.crossunder(pressure, dev_Ma_Band_Up)

//Plot Buying and Selling Pressure 1 Dots


plot(pressure - 2, "Buying Pressure 1" , style = plot.style_circles, color =
buy_Pressure ? color.lime : na, linewidth = 2)
plot(pressure + 2, "Selling Pressure 1", style = plot.style_circles, color =
sell_Pressure ? #ff0000 : na, linewidth = 2)

//Plot Buying and Selling Pressure 2 Dots


plot(pressure - 2, "Buying Pressure 2" , style = plot.style_circles, color =
buy_Pressure2 ? color.lime : na, linewidth = 1)
plot(pressure + 2, "Selling Pressure 2", style = plot.style_circles, color =
sell_Pressure2 ? #ff0000 : na, linewidth = 1)

//Buying and Selling Pressure 3 (Pressure Line crossing Standard Deviation Bands)
Dots
plot(pressure - 6, "Buying Pressure 3" , style = plot.style_circles, color =
buy_Pressure3 ? #007dff : na, linewidth = 3)
plot(pressure + 6, "Selling Pressure 3", style = plot.style_circles, color =
sell_Pressure3 ? #ff8200 : na, linewidth = 3)

//Plot Buying and Selling Pressure 1 and 2 Together Dots


plot(pressure - 4, "Buying Pressure 1 and 2" , style = plot.style_circles, color =
buy_Pressure and buy_Pressure2 ? color.lime : na, linewidth = 4)
plot(pressure + 4, "Selling Pressure 1 and 2", style = plot.style_circles, color =
sell_Pressure and sell_Pressure2 ? #ff0000 : na, linewidth = 4)

You might also like