Highest/Lowest functions with series/integer
Probably, you have already met the problem, when you tried to use
lowest() functions in TradingView PineScript using the dynamic/calculated variable, like:
my_value = highest(close, smth )
So, you will get the error:
Cannot call `highest` with arguments (series, series); available overloads: highest(series, integer) => series; highest(integer) => series;
Cannot call `lowest` with arguments (series, series); available overloads: lowest(series, integer) => series; lowest(integer) => series;
So, you want a solution to that.
Yes, as always (this is generic rule), the platform developers almost always ignore user request, even for simple things. (So, don’t hope that topics, opened even years ago, will be fixed ever in the platform). Instead, you should find a custom solution. So, I had to create a custom solution for that, and finally did:
study("smth name", overlay=true, max_bars_back=300) // <---- here should be the maximum expected value of bars-back index .... highest_(values, length) => h_val = na if length >= 1 for i = 0 to length-1 if ( na(h_val) or (not na(values[i]) and values[i] > h_val ) ) h_val := values[i] h_val lowest_(values, length) => l_val = na if length >= 1 for i = 0 to length-1 if ( na(l_val) or (not na(values[i]) and values[i] < l_val ) ) l_val := values[i] l_val
So, you can use this functions from now.
Let us know in comments, if that was useful for you.