# Horizontal line which starts at various time points

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").

**1**vote