+1 888 340 6572

# Miscellaneous > LinReg2Periods

Article/Author: Origin: Omega-list. Author: Earl Adamy, 1995

File Includes:

Indicator - LinReg2Periods
Function - LastCalcdate
Function - LinearRegSlope
Function - LinearregValue
Function - stddev

Category: Indicator > Miscellaneous

Description:

This indicator draws linear regression lines for two past periods. It is useful for regression comparing.

Usage:

MaxBarsBack must be long enough for pivot extreme to be reversed. Transfer to: X:\omega\inds\lrprice, where X - drive where Omega installed.

Inputs:

Periods - Number of bars to calculate

EasyLanguage Code:
INPUTS  : PERIODS(20);
VARS    : LRVALUEEND(0),
LRSLOPEEND(0),
LRSTDDEVEND(0),
LRVALUEBEG(0),
PLOTBARSBACK(0),
LRCHANWIDTH(0);

LRVALUEEND = LINEARREGVALUE(CLOSE, PERIODS, 0);
LRSLOPEEND = LINEARREGSLOPE(CLOSE, PERIODS);
LRSTDDEVEND = STDDEV(CLOSE, PERIODS);
{
PRINT(FILE("X:\OMEGA\I_LRPRC.LOG"),DATE, BARNUMBER, " CLOSE ", CLOSE, "
LRVAL ", LRVALUEEND, " LRSLP ", LRSLOPEEND, " LRSTD ", LRSTDDEVEND);
}
IF DATE = LASTCALCDATE THEN BEGIN
{PLOT END OF LAST LR PERIOD)}
PLOTBARSBACK = 0;
LRCHANWIDTH = (2 * LRSTDDEVEND[PLOTBARSBACK]);
PLOT1[PLOTBARSBACK](LRVALUEEND[PLOTBARSBACK],"LRP SHORT");
PLOT2[PLOTBARSBACK]((LRVALUEEND + LRCHANWIDTH)[PLOTBARSBACK],"LRP SUPPER");
PLOT3[PLOTBARSBACK]((LRVALUEEND - LRCHANWIDTH)[PLOTBARSBACK],"LRP SLOWER");
{PLOT BEGIN OF LAST LR PERIOD)}
LRVALUEBEG = LRVALUEEND[PLOTBARSBACK] + ((PERIODS-1) *
(LRSLOPEEND[PLOTBARSBACK] * -1));
PLOTBARSBACK = PERIODS - 1;
PLOT1[PLOTBARSBACK](LRVALUEBEG, "LRP SHORT");
PLOT2[PLOTBARSBACK]((LRVALUEBEG + LRCHANWIDTH), "LRP S UPPER");
PLOT3[PLOTBARSBACK]((LRVALUEBEG - LRCHANWIDTH), "LRP S LOWER");
{PLOT END OF PREV LR PERIOD)}
PLOT4[PERIODS](LRVALUEEND[PERIODS],"LRP S PREV");
{PLOT BEGIN OF LAST LR PERIOD)}
LRVALUEBEG = LRVALUEEND[PERIODS] + ((PERIODS-1) *
(LRSLOPEEND[PERIODS] * -1));
PLOTBARSBACK = (PERIODS * 2) - 1;
PLOT4[PLOTBARSBACK](LRVALUEBEG, "LRP S PREV");
END;