I'd like some help here, please.
I have the following formula:
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);
I want to plot yesterday's open and close prices based on the time interval selected in the input and also, today's open and close prices also, based on the time interval selected in the input.
As it is, plots today's open and yesterday open prices, but If I also plot today's and yesterday's close prices, these will be zero, though, if I remove the statements regarding the opening prices, the close prices will be correctly plotted.
What am I doing wrong?
Please see attached images.
Thank you.