Hello everyone! I was hoping if someone could help me with this script. I am looking for a script that draws a horizontal line from the high and low point (one line for each) of the last closed 5-min candle. For context, I will be using this indicator on the 1-min chart.
Here is what I have so far. While it works, there are some some things about it I would like to change but dont know how.
-First thing if that this script also draws lines for the current working 5-minute candle's high and low and I would rather not have that on my chart. This results in diagonal lines that connect the previous candle's lines to the current candle's.
-Second thing I would like to change is this: each of the two lines should (if possible) originate from the candle where the high or low was formed.
Here is my current code:
And here is the current output: https://postimg.cc/jDDHHHyr
Thank you for any advice!!
Here is what I have so far. While it works, there are some some things about it I would like to change but dont know how.
-First thing if that this script also draws lines for the current working 5-minute candle's high and low and I would rather not have that on my chart. This results in diagonal lines that connect the previous candle's lines to the current candle's.
-Second thing I would like to change is this: each of the two lines should (if possible) originate from the candle where the high or low was formed.
Here is my current code:
Code:
input aggregationPeriod = AggregationPeriod.FIVE_MIN;
input howManyCandlesBack = 1;
input whichCandle = 1;
input showOnlyLastPeriod = yes;
plot PrevDayHigh;
plot PrevDayLow;
if showOnlyLastPeriod and !IsNaN(high(period = aggregationPeriod)[-1]) and !IsNaN(low(period = aggregationPeriod)[-1])
{
PrevDayHigh = Double.NaN;
PrevDayLow = Double.NaN;
}
else
{
PrevDayHigh = Highest(high(period = aggregationPeriod)[whichCandle], howManyCandlesBack);
PrevDayLow = Highest(low(period = aggregationPeriod)[whichCandle], howManyCandlesBack);
}
PrevDayHigh.SetDefaultColor( Color.LIGHT_GREEN);
PrevDayHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PrevDayLow.SetDefaultColor(Color.LIGHT_RED);
PrevDayLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
And here is the current output: https://postimg.cc/jDDHHHyr
Thank you for any advice!!