I'm pretty new on the Ninja trader platform. This now two days that I try to convert the strategy "pivot reversal strategy" (wich is free and public on tradingview) to Ninja trader, but I fail every time to have the same result, almost all the commands are different.
I tried also with ChatGPT for 3 hours but always a lot of error, and when it compiled, not work with the same logic as the one on trading view.
I really think it's not a task so difficult but I'm just clueless on the Ninjscripte. If someone is ready to help me, I would be very grateful. The strategy is a simple switch from long and short when a pivot is crossed, this is the logic of the pivot from pinescripte that I fail to have the same command in ninjascripte, it work differently every time I tried.
Sorry for my english it's not my native language. I drop the code below:
//@version=5
strategy("Pivot Reversal Strategy", overlay=true)
leftBars = input(4)
rightBars = input(2)
swh = ta.pivothigh(leftBars, rightBars)
swl = ta.pivotlow(leftBars, rightBars)
swh_cond = not na(swh)
hprice = 0.0
hprice := swh_cond ? swh : hprice[1]
le = false
le := swh_cond ? true : (le[1] and high > hprice ? false : le[1])
if (le)
strategy.entry("PivRevLE", strategy.long, comment="PivRevLE", stop=hprice + syminfo.mintick)
swl_cond = not na(swl)
lprice = 0.0
lprice := swl_cond ? swl : lprice[1]
se = false
se := swl_cond ? true : (se[1] and low < lprice ? false : se[1])
if (se)
strategy.entry("PivRevSE", strategy.short, comment="PivRevSE", stop=lprice - syminfo.mintick)
Thanks in advance!!

Comment