如何优化pine脚本上的循环?

时间:2019-12-19 08:27:01

标签: pine-script

我想弄清楚给定来源的最拥挤之处。这是我的功能:

    get(source, frst, scnd) =>
        day = 1
        cnt = 0
        for m = 1 to frst
            count = 0
            s = source[m]
            for i = 1 to scnd
                suitable = close[i] / s > 0.98 and close[i] / s < 1.02
                if suitable
                    count := count + 1
                    if count > cnt
                        day := m
                        cnt := count
        source[day]

    plot(get(ema(close, 55), 100, 100), trackprice=true, offset=-99999, linewidth=4, color=color.maroon)

但是执行时间太长。如何优化循环?

0 个答案:

没有答案