Hi Robert

I have a code on ToS that is able to show daily range,what i did is to split this range to 1/2 and 1/4 in this way I have 100% 75% 50% 25% of the daily range.So far so good smiling smiley,my problem is I that I want to be able to measure this range from pre market lets say from 8am to 4pm.In this chart [prnt.sc] u will see what I mean,daily range is measured just on regular mkt hours not from premkt

This is the code I’m using now:

```plot yesterdayHigh = High(period = AggregationPeriod.DAY)[1];
yesterdayHigh.SetDefaultColor(CreateColor(224,224,224));

plot yesterdayLow= Low(period = AggregationPeriod.DAY)[1];
yesterdayLow.SetDefaultColor(CreateColor(224,224,224));

plot hod = High(period = AggregationPeriod.DAY);
hod.SetDefaultColor(CreateColor(245,127,23));

plot lod = Low(period = AggregationPeriod.DAY);
lod.SetDefaultColor(CreateColor(245,127,23));

def range = hod - lod;

plot hod764 = (range * 0.75) + lod;
hod764.SetDefaultColor(CreateColor(251,192,45));

plot lod236 = (range * 0.25) + lod;
lod236.SetDefaultColor(CreateColor(251,192,45));

plot mid50 = (range * 0.5) + lod;
mid50.SetDefaultColor(CreateColor(255,235,59));
```

I would appreciate any hint

Copy and paste the code below. Note that “Show extended hours” must be checked under the chart settings panel in order for this to work properly.

```# +--------------------------------------------------+
# | Example: Daily range including pre-market hours. |
# |                   robert payne                   |
# |              funwiththinkscript.com              |
# +--------------------------------------------------+

input TimeToStart = 0800;
input TimeToStop = 1600;

def nMinutes = GetAggregationPeriod() / 60000;
def startTime = SecondsFromTime(TimeToStart) >= 0 and SecondsFromTime(TimeToStart) < nMinutes * 60;
def endTime = SecondsFromTime(TimeToStop) >= 0;

# set the initial high / low as the high / low at the start time
# if it is past the end time, then just remember what the previous values were
# if a new high or low is reached, remember that new value
# otherwise, just keep the old value ( H[1] or L[1] )

def H = if startTime then high else if endtime then h[1] else if high > H[1] then high else H[1];
def L = if startTime then low else if low < L[1] then low else L[1];

# calculate the range
def range = H - L;

# display the range in a label
AddLabel(yes, "Range: " + range, Color.YELLOW);
```