hi Ivan if you can convert this code below to pro real time please
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ClayeWeight
//@version=5
indicator(“Market Structure RSI”)
rsiLength = input.int(20, “RSI Length”, minval = 1, group=”Market Structure RSI”)
OBlvl = input.int(80, “Overbought Level”, minval = 1, maxval=100, group=”Market Structure RSI”)
OSlvl = input.int(20, “Oversold Level”, minval = 1, maxval=100, group=”Market Structure RSI”)
strCloseType = input.string(“High/Low”, “Close Type”, [“Close”, “High/Low”], tooltip=”Choose whether the structure is deemed broken with either a Close or the Candle High/Low”, group=”Market Structure RSI”)
closeTypeBull = strCloseType == “Close” ? close[1] : high[1]
closeTypeBear = strCloseType == “Close” ? close[1] : low[1]
maBool = input.bool(true, “Show Moving Average”, group=”Moving Average”)
maSelection = input.string(“EMA”, “MA Type”, [“EMA”, “SMA”, “WMA”], group=”Moving Average”)
maLength = input.int(8, “MA Length”, minval = 1, group=”Moving Average”)
// Get Pivots
pH = high[3] < high[2] and high[2] > high[1]
pL = low[3] > low[2] and low[2] < low[1]
var highPrice = array.new_float()
var lowPrice = array.new_float()
var count = array.new_int()
if pH
highPrice.push(high[2])
if pL
lowPrice.push(low[2])
add_to_total(dir, priceArray, countArray, closeType, add) =>
if array.size(priceArray) > 0
for l = array.size(priceArray)-1 to 0
if (dir == 1 and closeType > array.get(priceArray, l)) or (dir == 0 and closeType < array.get(priceArray, l))
array.remove(priceArray, l)
array.push(countArray, add)
else
break
add_to_total(1, highPrice, count, closeTypeBull, 1)
add_to_total(0, lowPrice, count, closeTypeBear, -1)
// Get Total
total = array.sum(count)
rsiTotal = ta.rsi(total, rsiLength)
float rsmMATotal = switch maSelection
“EMA” => ta.ema(rsiTotal, maLength)
“SMA” => ta.sma(rsiTotal, maLength)
“WMA” => ta.wma(rsiTotal, maLength)
// Plot RSI
rsiPlot = plot(rsiTotal, color=na, linewidth = 2, title= “RSI Line”, editable = false)
plot(maBool ? rsmMATotal : na, color=#0075ff, title= “RSI Moving Average”, linewidth = 2)
// Plot Signals
structureOB = ta.crossunder(rsiTotal, OBlvl)
structureOS = ta.crossover(rsiTotal, OSlvl)
plotshape(structureOB ? OBlvl : na, size = size.tiny, style = shape.circle, location = location.absolute, color = color.red, title = “Bearish Signal”)
plotshape(structureOS ? OSlvl : na, size = size.tiny, style = shape.circle, location = location.absolute, color = color.green, title = “Bullish Signal”)
// Plot High and Low lines
hline(OBlvl, title = “Overbought Level”)
hline(OSlvl, title = “Oversold Level”)
// Gradient Fill
midPlot = plot(50, color=rsiTotal>50?color.lime:color.red) //, color = na, editable = false, display = display.none)
fill(rsiPlot, midPlot, 150, 50, top_color = color.new(color.lime, 0), bottom_color = color.new(color.lime, 100), title = “Overbought Gradient Fill”)
fill(rsiPlot, midPlot, 50, -50, top_color = color.new(color.red, 100), bottom_color = color.new(color.red, 0), title = “Oversold Gradient Fill”)
// Alerts
alertcondition(structureOB, “Bearish Signal”, “Structure RSI is crossing under the Overbought level”)
alertcondition(structureOS, “Bullish Signal”, “Structure RSI is crossing over the Oversold level”)