Page 1 of 1

Previous day time interval vs todays time interval

Posted: 28 Oct 2010
by arnie
Hi.

I'd like some help here, please.

I have the following formula:

Code: Select all

inputs:
todayStTime (830),
todayEnTime (900),
yesterdayStTime (1430),
yesterdayEnTime (1500);

variables:
dayCounter (0),
dayClose (0),
dayOpen (0),
//dayHigh (-999999),
//dayLow (+999999),
//prevDayHigh (0),
//prevDayLow (0),
//dayHigh (0),
//dayLow (0),
prevDayClose (0),
prevDayOpen (0),
prevClCounter (0),
prevTradeDay (false),
todayTradeDay (false);

// confirms the beginning of the day with true/false conditions
if date <> date[1] then begin
prevTradeDay = true;
todayTradeDay = false;
dayCounter = dayCounter + 1;
end;

// resets the new day to give the previous day open time interval
if prevTradeDay then begin
if time = yesterdayStTime then begin
prevTradeDay = false;
prevDayOpen = Open;
end;
end;

// resets the new day to give today's open time interval
if todayTradeDay = false then begin
if time >= todayStTime then begin
todayTradeDay = true;
dayOpen = Open;
end;
end;

// resets the new day to give the previous day close time interval
if prevTradeDay then begin
if time = yesterdayEnTime then begin
prevTradeDay = false;
prevDayClose = close;
end;
end;

// resets the new day to give today's close time interval
if todayTradeDay = false then begin
if time = todayEnTime then begin
todayTradeDay = true;
dayClose = close;
end;
end;


plot1(DayOpen);
//plot2(dayClose);
plot13(prevDayOpen);
//plot14(prevDayClose);
As it is, plots today's open and yesterday open prices based on the time interval selected, but If I also plot today's and yesterday's close prices, these will be zero, though, if I remove the statements regarding the open prices, the close prices will be correctly plotted.

What am I doing wrong?

See images attached (I hope the guys solve this colour problem with the images when we try to save them within MC)