# help with horizontal lines at previous day last 45 min of market close range

#### jonshank62

##### New member
hoping to find help with horizontal lines at previous day last 45 min of market close high range and low range on 5 min chart

Solution
@jonshank62

Code:
``````#plots high and low of defined timeframe.
#Inputs for periodstart and periodend have to be start times for bars of the aggregation period used on chart.

input periodstart = 1515;
input periodend = 1600;
def activeperiod = If secondsFromTime(periodstart)>=0 and secondsTillTime(periodend)>0 then yes else Double.NaN;
def acriveperiodstartbar = if secondsFromTime(periodstart)==0 then barnumber() else acriveperiodstartbar[1];
def activeperiodendbar = fold i=0 to AbsValue(BarNumber()) while !IsNaN(GetValue(activeperiod,-i)) do GetValue(BarNumber(),-i);
def activeperiodlength = 1+(activeperiodendbar-acriveperiodstartbar);

def activeperiodhigh;
if secondsFromTime(periodstart)==0 {...``````

#### Svanoy

##### Active member
@jonshank62

Code:
``````#plots high and low of defined timeframe.
#Inputs for periodstart and periodend have to be start times for bars of the aggregation period used on chart.

input periodstart = 1515;
input periodend = 1600;
def activeperiod = If secondsFromTime(periodstart)>=0 and secondsTillTime(periodend)>0 then yes else Double.NaN;
def acriveperiodstartbar = if secondsFromTime(periodstart)==0 then barnumber() else acriveperiodstartbar[1];
def activeperiodendbar = fold i=0 to AbsValue(BarNumber()) while !IsNaN(GetValue(activeperiod,-i)) do GetValue(BarNumber(),-i);
def activeperiodlength = 1+(activeperiodendbar-acriveperiodstartbar);

def activeperiodhigh;
if secondsFromTime(periodstart)==0 {
activeperiodhigh = high;
}else if !IsNaN(activeperiod) and high>=activeperiodhigh[1]{
activeperiodhigh = high;
}else{
activeperiodhigh = activeperiodhigh[1];}

def activeperiodlow;
if secondsFromTime(periodstart)==0 {
activeperiodlow = low;
}else if !IsNaN(activeperiod) and low<=activeperiodlow[1]{
activeperiodlow = low;
}else{
activeperiodlow = activeperiodlow[1];}

def activephigh = fold iah=0 to AbsValue(activeperiodlength) while !IsNaN(activeperiod) do GetValue(activeperiodhigh,-iah);
def activeplow = fold ial=0 to AbsValue(activeperiodlength) while !IsNaN(activeperiod) do GetValue(activeperiodlow,-ial);
def aph = fold iaph = 0 to 1 while !IsNaN(close[10]) do activeperiodhigh;
def apl = fold iapl = 0 to 1 while !IsNaN(close[10]) do activeperiodlow;

plot ActiveHigh = if !IsNaN(activeperiod) and activephigh>0 then activephigh else Double.NaN;
ActiveHigh.SetPaintingStrategy(PaintingStrategy.LINE);
ActiveHigh.SetDefaultColor(Color.LIME);

plot ActiveLow = if !IsNaN(activeperiod) and activeplow>0 then activeplow else Double.NaN;
ActiveLow.SetPaintingStrategy(PaintingStrategy.LINE);
ActiveLow.SetDefaultColor(Color.PINK);

plot APHigh = if IsNaN(activeperiod) and aph>0 then aph else Double.NaN;
APHigh.SetPaintingStrategy(PaintingStrategy.DASHES);
APHigh.SetDefaultColor(Color.LIME);

plot APLow = if IsNaN(activeperiod) and apl>0 then apl else Double.NaN;
APLow.SetPaintingStrategy(PaintingStrategy.DASHES);
APLow.SetDefaultColor(Color.PINK);