거래 로봇을 무료로 다운로드 하는 법을 시청해보세요
당사를 Telegram에서 찾아주십시오!
당사 팬 페이지에 가입하십시오
스크립트가 흥미로우신가요?
그렇다면 링크 to it -
하셔서 다른 이들이 평가할 수 있도록 해보세요
스크립트가 마음에 드시나요? MetaTrader 5 터미널에서 시도해보십시오
지표

Linear regression slope - MetaTrader 5용 지표

게시자:
Vladimir
조회수:
26259
평가:
(43)
게시됨:
2010.07.05 14:14
업데이트됨:
2016.11.22 07:32
MQL5 프리랜스 이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동

Linear regression fits the following equation of a straight line to price data:

y[x] = y0 + b*x

where:

  • x is a bar number (x=1..n);
  • y[x] is the corresponding price (open, close, median etc);
  • b is a proportionality coefficient
  • y0 is a bias.

The linear regression slope, given by this indicator, is equal to a normalized version of the coefficient b.

The formula for b is:

b = (n*Sxy - Sx*Sy)/(n*Sxx - Sx*Sx)

where:

  • Sx = Sum(x, x = 1..n)= n*(n + 1)/2;
  • Sy = Sum(y[x], x = 1..n);
  • Sxx = Sum(x*x, x = 1..n) = n*(n+1)*(2*n+1)/6;
  • Sxy = Sum(x*y[x], x = 1..n);
  • n is the period of LRS (input parameter Per).

The denominator of b can be simplified to:

n*Sxx - Sx*Sx = n*n*(n-1)*(n+1)/12

Finally, the whole equation for b can be simplified to

b = 6*(2*Sxy/(n + 1) - Sy)/n/(n - 1)

The coefficient b is not normalized. It has to be normalized if we want LRS to have a roughly the same range for different currency pairs. It is convenient to normalize b by dividing it by either a simple moving average (SMA) or a linear weighted moving average (LWMA), which are given by:

SMA = Sy/n
LWMA = 2*Sxy/n/(n + 1)

The corresponding versions of LRS are given by

LRS_SMA = b/SMA = 6*(2*Sxy/Sy/(n + 1) - 1)/(n + 1)

LRS_LWMA = b/LWMA = 6*(1 - (n + 1)*Sy/Sxy/2)/(n + 1)

These two versions of normalization are almost indistinguishable. So, the SMA normalization was chosen for the indicator. Also, because of very small values of the LRS, the indicator values are calculated and plotted in parts per 100 thousand to fit roughly into the range of -100 to +100.

Linear regression slope

A simple RKD Expert Advisor  based on a specified custom RKD indicator A simple RKD Expert Advisor based on a specified custom RKD indicator

This is a simple Expert Advisor, that uses a specified custom RKD indicator.

Export historical data Export historical data

The script purpose is to export historical rates data to format, convenient for analysis in external programs.

AR extrapolation of price AR extrapolation of price

This indicator uses an autoregresive model to extrapolate prices

Fourier extrapolation of price Fourier extrapolation of price

This indicator fits a trigonometric model to prices and extrapolates it in the future.