capissimo

Forecasting - Locally Weighted Regression

827 просмотров
81
This is a continuation of the series on forecasting techniques.
Locally weighted linear regression is a non-parametric algorithm, that is, the model does not learn a fixed set of parameters as is done in ordinary linear regression . Rather parameters Θ (theta) are computed individually for each query point x. While computing Θ, a higher “preference” is given to the points in the training set lying in the vicinity of x than the points lying far away from x.
For a detailed discussion see https://www.geeksforgeeks.org/ml-locally...
and for the formula see https://fawda123.github.io/swmp_workshop...

Here you can see a shortcut application of this technique to time series with results unexpectedly favorable for price data labelling.

Good at detecting pullbacks. Can be incorporated into a trading system as a signal generator. Alerting is included.
Удалить из избранных скриптов Добавить в избранные скрипты

Комментарии

Excellent work, thanks for sharing, I made the changes that you suggest but it shows an error when adding them ,, line26: Could not find function or function reference scale.It does not recognize a function scale
Ответить
capissimo mercacoin
@mercacoin, see here
or add these lines:
scaleMinimax(X, p, min, max) =>
hi = highest(X, p), lo = lowest(X, p)
(max - min) * (X - lo)/(hi - lo) + min

scale(X, p) => scaleMinimax(X, p, lowest(close, p), highest(close, p))
Ответить
mercacoin capissimo
@capissimo, Perfect thank you very much, it works better, I'm going to try it:)
Ответить
does this repaint?
Ответить
capissimo greyghost7
@greyghost7, it uses the current value of the price, not the previous.
Ответить
UPD: here's the mod that allows to work with securities other than BTC. Replace the lines 19 thru 35 with the following:

locally_weighted(x, p, b, mx) =>
PI = 3.14159265359
l = 0.0
for i=0 to p-1
l := b + b*i + b*2*x + b*sin(2*PI*i) + b*cos(2*PI*i)
scale(linreg(l, p, 0), mx)

//*** Inputs
price = input(close, "Price Data")
p = input(5, "Lookback Window")
span = input(8, "Rising/Falling span", minval=2)
crvs = input(false, "Show curves?")
lbls = input(true, "Show Labels?")
mmx = input(2, "Scaler Lookback", minval=1)

//*** Main
BETA = .5
lwr = locally_weighted(price, p, BETA, mmx)
Ответить
capissimo capissimo
@capissimo, by the way, the best mmx value is 20
Ответить
Tested with BTCUSD.
Ответить
Домой Скринер акций Скринер форекс Скринер криптовалют Экономический календарь О проекте Особенности Цены Приведи друга Правила поведения Справочный центр Решения для сайтов и брокеров Виджеты Графики TradingView для сайтов Легкая версия графиков Блог и новости Твиттер
Профиль Настройка профиля Счёт и оплата Ваши друзья Монеты Мои запросы в поддержку Справочный центр Опубликовано идей Подписчики Подписки Личные сообщения Чат Выйти