+1 888 340 6572

LowestUniversal

Article/Author: Emmanuel Lavelanet 1996.

Download: FUNCTION-LOWESTUNIVERSAL.ELA

File Includes: Function - LowestUniversal

EasyLanguage Code:
INPUTS: TYPE(NUMERIC), PRICE(NUMERICSERIES),SDATE(NUMERICSIMPLE),STIME(NUMERICSIMPLE);


VARS: LOWESTPOFDAY(PRICE), LOWESTPOFWEEK(PRICE), LOWESTPOFYEAR(PRICE), LOWESTPFROMPICK(PRICE),
LOWESTPSOFAR(PRICE);

IF CURRENTBAR = 1 OR DATE < SDATE OR TYPE < 1 OR TYPE > 5 THEN LOWESTUNIVERSAL = PRICE;

IF TYPE = 1 THEN BEGIN
IF DATE > DATE[1] THEN LOWESTPOFDAY = PRICE ELSE
LOWESTPOFDAY = IFF(BARNUMBER > 1 AND
PRICE < LOWESTPOFDAY , PRICE, LOWESTPOFDAY );
LOWESTUNIVERSAL = LOWESTPOFDAY;
IF DATE = LASTCALCDATE AND TIME = LASTCALCTIME THEN
PRINT("LOWEST ",PRICE," OF DAY");
END;

IF TYPE = 2 THEN BEGIN
IF DAYOFWEEK(DATE) < DAYOFWEEK(DATE[1]) THEN
LOWESTPOFWEEK = PRICE
ELSE LOWESTPOFWEEK = IFF(PRICE <= LOWESTPOFWEEK , PRICE, LOWESTPOFWEEK );
LOWESTUNIVERSAL = LOWESTPOFWEEK;
IF DATE = LASTCALCDATE AND TIME = LASTCALCTIME THEN
PRINT("LOWEST ",PRICE," OF WEEK");
END;


IF TYPE = 3 THEN BEGIN
IF YEAR(DATE) > YEAR(DATE[1]) OR CURRENTBAR = 1 THEN LOWESTPOFYEAR = PRICE ELSE
LOWESTPOFYEAR = IFF(PRICE < LOWESTPOFYEAR , PRICE, LOWESTPOFYEAR );
LOWESTUNIVERSAL = LOWESTPOFYEAR;
IF DATE = LASTCALCDATE AND TIME = LASTCALCTIME THEN
PRINT("LOWEST ",PRICE," OF YEAR");
END;

IF TYPE = 4 THEN BEGIN
IF DATE <= SDATE AND (TIME <= STIME OR STIME = 0) THEN BEGIN
LOWESTUNIVERSAL = PRICE;
VALUE1 = BARNUMBER;
END;

IF BARNUMBER >=VALUE1 AND
PRICE < LOWESTUNIVERSAL[1] THEN
LOWESTUNIVERSAL = PRICE;

IF DATE = LASTCALCDATE AND TIME = LASTCALCTIME THEN
PRINT("LOWEST ",PRICE," FROM SELECTED DATE AND TIME");
END;

IF TYPE = 5 THEN BEGIN
IF BARNUMBER = 1 THEN LOWESTPSOFAR = PRICE ELSE
LOWESTPSOFAR = IFF(BARNUMBER > 0 AND
PRICE < LOWESTPSOFAR ,PRICE,LOWESTPSOFAR );
LOWESTUNIVERSAL = LOWESTPSOFAR;
IF DATE = LASTCALCDATE AND TIME = LASTCALCTIME THEN
PRINT("LOWEST ",PRICE," SO FAR");
END;