I've been trying to convert the following Pinescript to Python without much success. I've been able to convert most of it but where I'm getting stuck is snippet surrounded by the "***" below. I've tried picking it apart line by line and I tried different permutations in Python and I can't get it to work fully. Has anyone attempted something similar? This is the original link https://www.tradingview.com/script/n8AGnIZd-Divergence-for-Many-Indicators-v4/ Pinescript Code positive_regular_positive_hidden_divergence(src, cond)=> divlen = 0 prsc = source == "Close" ? close : low // if indicators higher than last value and close price is higher than las close if dontconfirm or src > src[1] or close > close[1] startpoint = dontconfirm ? 0 : 1 // don't check last candle // we search last 15 PPs for x = 0 to maxpp - 1 len = bar_index - array.get(pl_positions, x) + prd // if we reach non valued array element or arrived 101. or previous bars then we don't search more if array.get(pl_positions, x) == 0 or len > maxbars break if len > 5 and ((cond == 1 and src[startpoint] > src[len] and prsc[startpoint] < nz(array.get(pl_vals, x))) or (cond == 2 and src[startpoint] < src[len] and prsc[startpoint] > nz(array.get(pl_vals, x)))) slope1 = (src[startpoint] - src[len]) / (len - startpoint) virtual_line1 = src[startpoint] - slope1 slope2 = (close[startpoint] - close[len]) / (len - startpoint) virtual_line2 = close[startpoint] - slope2 arrived = true ***for y = 1 + startpoint to len - 1 if src[y] < virtual_line1 or nz(close[y]) < virtual_line2 arrived := false break virtual_line1 := virtual_line1 - slope1 virtual_line2 := virtual_line2 - slope2 if arrived divlen := len break*** divlen Continue reading...