Choppiness index code

Can anyone help me code choppiness index?
On searching on internet i got it’s formula as
100 * LOG10( SUM(ATR(1), n) / ( MaxHi(n) - MinLo(n) ) ) / LOG10(n)
using above formula on excel i am getting correct choppiness index value

so in tradescript for 14 period i coded it as
100 * LOG10( SUM(TR(1), 14) / ( Max(high,14) - Min(low,14) ) ) / LOG10(14)

but it’s not giving correct value.
can anyone please tell me, where i am doing wrong

Thanks