Previous day time interval vs todays time interval

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
User avatar
arnie
Posts: 1589
Joined: 11 Feb 2009
Location: Portugal
Has thanked: 478 times
Been thanked: 509 times

Previous day time interval vs todays time interval

Postby arnie » 28 Oct 2010

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)
Attachments
close prices only.png
close prices only.png (43.7 KiB) Viewed 322 times
open prices only.png
open prices only.png (43.43 KiB) Viewed 314 times
open and close prices.png
open and close prices.png (34.34 KiB) Viewed 304 times

Return to “User Contributed Studies and Indicator Library”