Function Highest/Lowest

Function for highest() and lowest()
Release Notes: updated code for V4, code in cooperation with @LucF.
theres 2:
1. version that supports high length values.
2. error's with high length values, but maps initial range(bar_index=0 to length).
Remove from Favorite Scripts Add to Favorite Scripts


This is great.. as I've noticed in version 3.. highest() and lowest() do not like taking in variables for length.. often results in:

line 34: Cannot call `highest` with arguments (series, series); available overloads: highest(series, integer) => series; highest(integer) => series;
+9 Reply
These two pieces of code are probably the most used functions in Pine outside the built-ins, so thanks for them, Ricardo.
+4 Reply
@LucF, discovered it today.... but was looking for them all my life. True story
+1 Reply
thanks for sharing
A lowest()/highest() function without the ability to input a series is like a 3-legged horse. Thank you, Ricardo, for supplying the fourth leg!
Thanks @RicardoSantos and @LucF, you guys are unstoppable!
Hi Ricardo, for some reason your Lowest function is giving a different result to the pinescript one in this calculation.

val = linreg(hlc3 - avg(avg(highest(high, lengthKC), _lowest(low, lengthKC)), sma(close, lengthKC)), lengthKC,0)

Any ideas?
RicardoSantos DannyBaker
you will need to provide the code for the function..
DannyBaker RicardoSantos
@RicardoSantos, I'm using you lowest funcion its just named differantly. Here

_lowest(_src, _length)=>
_adjusted_length = _length < 1 ? 1 : _length
_value = _src
for _i = 0 to (_adjusted_length-1)
_value := _src <= _value ? _src : _value
_return = _value
DannyBaker DannyBaker
@DannyBaker, its weird because it is sometimes the same and sometimes not...
Home Stock Screener Forex Screener Crypto Screener Economic Calendar How It Works Chart Features Pricing Refer a friend House Rules Help Center Website & Broker Solutions Widgets Charting Solutions Lightweight Charting Library Blog & News Twitter
Profile Profile Settings Account and Billing Referred friends Coins My Support Tickets Help Center Ideas Published Followers Following Private Messages Chat Sign Out