+1 888 340 6572

RSIVARIABLE

Article/Author: Omega Research Inc., 1995

Download: FUNCTION-RSIVARIABLE.ELA

File Includes: Function - RSIVARIABLE

EasyLanguage Code:
INPUTS : PRICE(NUMERICSERIES),LENGTH(NUMERICSERIES);

VARS : COUNTER(0),DOWNAMT(0),UPAMT(0),UPSUM(0),
DOWNSUM(0),UPAVG(0),DOWNAVG(0),MYRANGE(0);

IF CURRENTBAR = 1 THEN BEGIN
MYRANGE = LENGTH;
UPSUM = 0;
DOWNSUM = 0;
FOR COUNTER = 0 TO MYRANGE-1 BEGIN
UPAMT = PRICE[COUNTER] - PRICE[COUNTER+1];
IF (UPAMT >= 0) THEN DOWNAMT = 0
ELSE BEGIN
DOWNAMT = -UPAMT;
UPAMT = 0;
END;
UPSUM = UPSUM + UPAMT;
DOWNSUM = DOWNSUM + DOWNAMT;
END;
UPAVG = UPSUM / MYRANGE;
DOWNAVG = DOWNSUM / MYRANGE;
END
ELSE IF CURRENTBAR > 1 THEN BEGIN
UPAMT = PRICE[0] - PRICE[1];
IF UPAMT >= 0 THEN BEGIN
DOWNAMT = 0;
END
ELSE BEGIN
DOWNAMT = -UPAMT;
UPAMT = 0;
END;
UPAVG = (UPAVG[1] * (MYRANGE - 1) + UPAMT) / MYRANGE;
DOWNAVG = (DOWNAVG[1] * (MYRANGE - 1) + DOWNAMT) / MYRANGE;
END;
IF UPAVG+DOWNAVG <> 0 THEN
RSIVARIABLE = 100 * UPAVG / (UPAVG + DOWNAVG)
ELSE
RSIVARIABLE = 0;