dayOpen (int zone, int day) : var
dayClose (int zone, int day) : var
dayHigh (int zone, int day) : var
dayLow (int zone, int day) : var
dayPivot (int zone, int day) : var
Returns the open, close, high, low, and pivot point calculated from stock exchange working hours (9:30 am until 16:00 pm) of a given working day and time zone. Can be used for seasonal trading, gap trading, or daily price action. The pivot point is defined as (High+Low+Close)/3.
||UTC for UTC time or ET for New York time, or a number giving the zone offset in hours to UTC. Daylight saving time is considered in non-UTC zones from 2000 to 2019.
||Working day offset, i.e. 0 = today (see remarks), 1 = yesterday, 2 = day before yesterday, and so on. Weekends are skipped, f.i. if today is Monday, 1 refers to last Friday.
dayClose(ET,1) returns yesterday's closing price of the current asset at the New York Stock Exchange.
- During the LookBack period all day price functions return 0.
- The BarPeriod matters for precision. F.i. with a bar period of 60 minutes, opening and closing prices can be inaccurate by one hour. For a time precision of 30 minutes use a BarPeriod of 30 or below.
- Requesting a time travel - for instance today's high, low, or close price when the market is still open - will cause a
"negative price offset" warning when the PEEK flag is not set.
- The working hours can be changed through the global variables StartMarket (default: 930) and EndMarket (default: 1600) in the hhmm format. If the hours don't matter, use alternatively the price functions from daily bars, or the HH / LL functions. Daily bars change at midnight UTC. By setting StartMarket and EndMarket accordingly, arbitrary time periods can be used. F.i. for getting the high-low range of the first hour of a trading day, set StartMarket at 930 and EndMarket at 1030.
EndMarket must be higher than StartMarket.
- Some trade systems are based on fixed "support and resistance" price levels named S1, S2, S3, R1, R2, R3. They can be calculated from dayPivot, dayHigh, and dayLow using the following formula:
S1 = 2*Pivot - High;
S2 = Pivot - (High - Low);
S3 = 2*Pivot - (2*High - Low);
R1 = 2*Pivot - Low;
R2 = Pivot + (High - Low);
R3 = 2*Pivot + (High - 2*Low);
- The source code of the day price functions can be found in Source\indicators.c.
// simple gap trading system,
// based on a publication by David Bean
BarPeriod = 10;
LookBack = 100*24*60/BarPeriod; // 100 days lookback
Stop = 100*PIP;
TakeProfit = 40*PIP;
vars Price = series(price());
var High = dayHigh(ET,1);
var Low = dayLow(ET,1);
var Close = dayClose(ET,1);
// enter a trade when the NYSE opens
if(High > 0 && Low > 0 && Close > 0
&& timeOffset(ET,0,9,30) == 0)
var Avg = SMA(Price,LookBack);
if(*Price > Close
&& *Price < High
&& *Price < Avg)
if(*Price < Close
&& *Price > Low
&& *Price > Avg)