study that draws a horizontal line which starts at various time points

on an intra-day chart, how would I construct a study that draws a horizontal line whose level is the price at pre-determined times? For example, draw a horizontal line that starts at 9:00 AM, flat lines until 12:30 PM and then starts again at 12:30 PM ? The specific times 9:00 AM and 12:30 PM should be parameters of the study. Thank you

• I'm not sure if I have the most elegant solution possible, but hopefully you can understand from this and modify it for your needs To start, you will want to make use of the Hour(@) and Minute(@) functions to get the current time. You will multiply the Hour(@) by 60 and add it to the minute to get the current day's time integer. In a custom study, you will create four parameters for the example you propose, such as "hour1," "minute1," "hour2," and "minute2."

Then you might code the formula as follows:
a1:= Hour(@)*60 + Minute(@);
b1:= hour2 *60 + minute2;
c1:= hour1*60 + minute1;
d1:= (Close(@),D)[-1];
e1:= a1 xabove b1;
price:= IF(a1 >=b1, g1, f2);
f1:= a1 xabove c1;
f2:= IF(a1 >= c1, h1, d1) ;
g1:= Close(@) When e1;
h1:= Close(@) When f1;
price

I used variables because that usually makes my studies easier to follow, but in this case, it might have been easier to just write it as a large "nested if" statement. Basically, it checks to see if the current time is equal to or greater than the latest time parameter. If it is, then it returns "g1" which is the price of the instrument when that condition became true, and if not, checks for the earlier time parameter. Finally, if it is earlier in the day than either time parameter, I told it to give me the previous day's close ("d1").     