diff --git a/links/high_and_low.pine.link b/links/high_and_low.pine.link index 8048da8a7..bdc66d5e9 100644 --- a/links/high_and_low.pine.link +++ b/links/high_and_low.pine.link @@ -61,15 +61,18 @@ custom_highest_and_date(len, maxbarsback) => if high[i] > high[index] index := i [high[index], time[index] / 1000] +// Searches nearest bar offset by timestamp fastSearchTimeIndex(x, maxbarsback) => // max_bars_back(time, maxbarsback) mid = 0 * time[maxbarsback] right = math.min(bar_index, maxbarsback) left = 0 - if time < x + if x/1000 <= first_bar_time + bar_index + else if time < x 0 else - for i = 0 to 9 by 1 + for i = 0 to 10 mid := math.ceil((left + right) / 2) if left == right break @@ -157,4 +160,4 @@ plot(ta.tr(true) * 100 / math.abs(low), title='Volatility.D') // first bar's timestamp in pine history var first_bar_time = time / 1000 -plot(first_bar_time, title='first_bar_time') \ No newline at end of file +plot(first_bar_time, title='first_bar_time')