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
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