I need to convert the pinescript code I specified below to c#, I want to get the same results as the tredingview gives.
// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) [login to view URL]
// © LuxAlgo
//@version=5
indicator("Nadaraya-Watson Envelope [LuxAlgo]", "LuxAlgo - Nadaraya-Watson Envelope", overlay = true, max_lines_count = 500, max_labels_count = 500, max_bars_back=500)
//------------------------------------------------------------------------------
//Settings
//-----------------------------------------------------------------------------{
h = [login to view URL](8.,'Bandwidth', minval = 0)
mult = [login to view URL](3., minval = 0)
src = input(close, 'Source')
repaint = input(true, 'Repainting Smoothing', tooltip = 'Repainting is an effect where the indicators historical output is subject to change over time. Disabling repainting will cause the indicator to output the endpoints of the calculations')
//Style
upCss = [login to view URL]([login to view URL], 'Colors', inline = 'inline1', group = 'Style')
dnCss = [login to view URL]([login to view URL], '', inline = 'inline1', group = 'Style')
//-----------------------------------------------------------------------------}
//Functions
//-----------------------------------------------------------------------------{
//Gaussian window
gauss(x, h) => [login to view URL](-([login to view URL](x, 2)/(h * h * 2)))
//-----------------------------------------------------------------------------}
//Append lines
//-----------------------------------------------------------------------------{
n = bar_index
var ln = array.new_line(0)
if [login to view URL] and repaint
for i = 0 to 499
[login to view URL](ln,[login to view URL](na,na,na,na))
//-----------------------------------------------------------------------------}
//End point method
//-----------------------------------------------------------------------------{
var coefs = array.new_float(0)
var den = 0.
if [login to view URL] and not repaint
for i = 0 to 499
w = gauss(i, h)
[login to view URL](w)
den := [login to view URL]()
out = 0.
if not repaint
for i = 0 to 499
out += src[i] * [login to view URL](i)
out /= den
mae = [login to view URL]([login to view URL](src - out), 499) * mult
upper = out + mae
lower = out - mae
//-----------------------------------------------------------------------------}
//Compute and display NWE
//-----------------------------------------------------------------------------{
float y2 = na
float y1 = na
nwe = [login to view URL]<float>(0)
if [login to view URL] and repaint
sae = 0.
//Compute and set NWE point
for i = 0 to [login to view URL](499,n - 1)
sum = 0.
sumw = 0.
//Compute weighted mean
for j = 0 to [login to view URL](499,n - 1)
w = gauss(i - j, h)
sum += src[j] * w
sumw += w
y2 := sum / sumw
sae += [login to view URL](src[i] - y2)
[login to view URL](y2)
// Her bar için bir label ekleyin
[login to view URL](bar_index, high, text="Value: " + [login to view URL](mae), color=[login to view URL])
sae := sae / [login to view URL](499,n - 1) * mult
for i = 0 to [login to view URL](499,n - 1)
if i%2
[login to view URL](n-i+1, y1 + sae, n-i, [login to view URL](i) + sae, color = upCss)
[login to view URL](n-i+1, y1 - sae, n-i, [login to view URL](i) - sae, color = dnCss)
if src[i] > [login to view URL](i) + sae and src[i+1] < [login to view URL](i) + sae
[login to view URL](n-i, src[i], '▼', color = color(na), style = label.style_label_down, textcolor = dnCss, textalign = text.align_center)
if src[i] < [login to view URL](i) - sae and src[i+1] > [login to view URL](i) - sae
[login to view URL](n-i, src[i], '▲', color = color(na), style = label.style_label_up, textcolor = upCss, textalign = text.align_center)
y1 := [login to view URL](i)
//-----------------------------------------------------------------------------}
//Dashboard
//-----------------------------------------------------------------------------{
var tb = [login to view URL](position.top_right, 1, 1
, bgcolor = #1e222d
, border_color = #373a46
, border_width = 1
, frame_color = #373a46
, frame_width = 1)
if repaint
[login to view URL](0, 0, 'Repainting Mode Enabled', text_color = [login to view URL], text_size = [login to view URL])
//-----------------------------------------------------------------------------}
//Plot
//-----------------------------------------------------------------------------}
plot(repaint ? na : out + mae, 'Upper', upCss)
plot(repaint ? na : out - mae, 'Lower', dnCss)
//Crossing Arrows
plotshape([login to view URL](close, out - mae) ? low : na, "Crossunder", [login to view URL], [login to view URL], color(na), 0 , text = '▲', textcolor = upCss, size = [login to view URL])
plotshape([login to view URL](close, out + mae) ? high : na, "Crossover", [login to view URL], [login to view URL], color(na), 0 , text = '▼', textcolor = dnCss, size = [login to view URL])
//-----------------------------------------------------------------------------}