I have a couple of indicators that I use in Tradingview that I would like to duplicate the best I can in NinjaTrader. Below is the code out of Tradingview for the first indicator that I'm working on. This particular indicator looks at the WMA of the ATR, mixed with a couple of additional parameters, and plots it over the price bars. I've started by working to address each line individually and converting it into C#. However, when I attempt to compile it right now, I'm getting two errors; CS1502 & CS1503. One appears to state that it's overloaded and the second cannot convert from double to NinjaTrader. NinjaScript.Iseries<double>. These errors are specific to this line of code here: double AvgTR = WMA(ATR1, 21)[0];
That being said, I've printed the full code that I've written in the attached PDF. If there is anyone that can help point me in the right direction, and perhaps provide some feedback, I would appreciate it.
study(title="Trend Trader Strategy", overlay = true)
Length = input(21, minval=1),
Multiplier = input(3, minval=0.000001)
avgTR = wma(atr(1), Length)
highestC = highest(Length)
lowestC = lowest(Length)
hiLimit = highestC[1]-(avgTR[1] * Multiplier)
loLimit = lowestC[1]+(avgTR[1] * Multiplier)
ret = 0.0
pos = 0.0
ret:= iff(close > hiLimit and close > loLimit, hiLimit,
iff(close < loLimit and close < hiLimit, loLimit, nz(ret[1], close)))
pos:= iff(close > ret, 1,
iff(close < ret, -1, nz(pos[1], 0)))
barcolor(pos == -1 ? color.red: pos == 1 ? color.green : color.blue )
plot(ret, color= color.blue , title="Trend Trader Strategy")
Comment