Converting script and looking for suggestions....

How would I write these (Pinescript) lines to work using AFL:

xATR = atr(ATRPeriod)
nLoss = ATRMultip * xATR
xATRTrailingStop = na
xATRTrailingStop = :=
iff(close > nz(xATRTrailingStop[1], 0) and close[1] > nz(xATRTrailingStop[1], 0), max(nz(xATRTrailingStop[1]), close - nLoss),
iff(close < nz(xATRTrailingStop[1], 0) and close[1] < nz(xATRTrailingStop[1], 0), min(nz(xATRTrailingStop[1]), close + nLoss),
iff(close > nz(xATRTrailingStop[1], 0), close - nLoss, close + nLoss)))

I have another section of coding with the exact same format. I have converted everything else in the script so far, but can't seem to figure this one out. Im sure it is simple but I am just not seeing it. Thanks for any help or suggestion

When posting the formula, please make sure that you use Code Tags (using </> code button) as explained here: How to use this site.

Using code button

Code tags are required so formulas can be properly displayed and copied without errors.

I am trying to convert a strategy that I have been using in Tradingview and I am having some issues with with finding a suitable conversion from PineScript for certain characters or functions such as;

It works best if you describe in plain english what you want to achieve instead of attempting to translate some random code from some random web site.

This is not PineScript or TradingView support forum. We don't know all 3rd party products that are floating out there. Having said that, the language looks like copycat of Tradestation Easy Language with minor changes. IFF looks like direct equivalent of IIF function http://www.amibroker.com/f?iif. xATRTrailingStop[1] is a "previous bar" value of the indicator, but the formula that you copied from somewhere (NO source given, we don't allow copyrighted code to be copy pasted without permission) is self-referencing. Self-referencing code needs special treatment:
Duplicate - Self-referencing, was: Programming previous value of a "value" and Doubt when using self referencing

Also the code snippet that you posted looks like attempt to code ATR based trailing stop. ATR based trailing stop (Chaneliers exit) in AmiBroker is SINGLE LINE see manual: http://www.amibroker.com/guide/h_backtest.html and http://www.amibroker.com/guide/afl/applystop.html

/* single-line implementation of Chandelier exit */

ApplyStop(stopTypeTrailing, stopModePoint, 3*ATR(14), True, True );

For re-implementing stops using loop see Knowledge Base: http://www.amibroker.com/kb/2007/03/24/how-to-plot-a-trailing-stop-in-the-price-chart/

Thank you Tomasz...I think the info you provided will be a big help. I appreciate it.