Hi all,

I am new here, I have a code that I wrote in pine editor (trandingview) for a part of my trailing stop algo. I used build in fuction (nz) but I dont know how to use it here so Is there anyone can help me to convert this portion of code to C# ? 

AF2 = input(defval=1,title="Percent",minval=0.1)/100
SL2 = Trail1*AF2 // Stop Loss
Trail2 = 0.0
Trail2 := iff(Trail1>nz(Trail2[1],0) and Trail1[1]>nz(Trail2[1],0),max(nz(Trail2[1],0),Trail1-SL2),iff(Trail1<nz(Trail2[1],0) and Trail1[1]<nz(Trail2[1],0),min(nz(Trail2[1],0),Trail1+SL2),iff(Trail1>nz(Trail2[1],0),Trail1-SL2,Trail1+SL2)))