RicardoSantos

Function Highest/Lowest

4202 просмотров
202
Function for highest() and lowest()
Информация о релизе: 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).
Удалить из избранных скриптов Добавить в избранные скрипты

Комментарии

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 Ответить
These two pieces of code are probably the most used functions in Pine outside the built-ins, so thanks for them, Ricardo.
+3 Ответить
@LucF, discovered it today.... but was looking for them all my life. True story
Ответить
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?
Ответить
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...
Ответить
@DannyBaker,
//@version=4
study("My Script")
lengthKC = 50

_lowest(_src, _length)=>
    _adjusted_length = _length < 1 ? 1 : _length
    _value = _src
    for _i = 0 to (_adjusted_length-1)
        _value := _src[_i] <= _value ? _src[_i] : _value
    _return = _value

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

plot(val0)
plot(val1)

this plots correctly for me
Ответить
DannyBaker RicardoSantos
@RicardoSantos, its weird i'm running 2 instances of that calc in a strategy and for some reason if i use the lowest function on the second instance the strat give different results. must be something i'm doing...
Ответить
Домой Скринер акций Скринер форекс Скринер криптовалют Экономический календарь О проекте Особенности Цены Приведи друга Правила поведения Справочный центр Решения для сайтов и брокеров Виджеты Графики TradingView для сайтов Легкая версия графиков Блог и новости Твиттер
Профиль Настройка профиля Счёт и оплата Приведи друга Мои запросы в поддержку Справочный центр Опубликовано идей Подписчики Подписки Личные сообщения Чат Выйти