I have tried this but if I change the time frame from 30 min to 5 min it is giving me High and Low of the first 5 min candle. I just need to draw the High and Low of first 30 min candle and it should NOT change if I change to different time frame something similar to DailyHighLow TOS indicator. Thanks in Advance.
def newDay = GetDay() <> GetDay()[1];
rec firstOpen = if newDay then open else firstOpen[1];
rec firstHigh = if newDay then high else firstHigh[1];
rec firstLow = if newDay then low else firstLow[1];
rec firstClose = if newDay then close else firstClose[1];
#plot priceOpen = firstOpen;
plot priceHigh = firstHigh;
plot priceLow = firstLow;
#plot priceClose = firstClose;
I tried this too
input aggregationPeriod = AggregationPeriod.THIRTY_MIN;
input length = 1;
input displace = -1;
input showOnlyLastPeriod = no;
def newDay = GetDay() <> GetDay()[1];
rec firstOpen = if newDay then open else firstOpen[1];
rec firstHigh = if newDay then high else firstHigh[1];
rec firstLow = if newDay then low else firstLow[1];
rec firstClose = if newDay then close else firstClose[1];
#plot priceOpen = firstOpen;
#plot priceHigh = firstHigh;
#plot priceLow = firstLow;
#plot priceClose = firstClose;
plot priceHigh;
plot priceLow;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) {
priceHigh = firstHigh;
priceLow = firstLow;
# priceHigh = Highest(high(period = aggregationPeriod)[-displace], length);
# priceLow = Lowest(low(period = aggregationPeriod)[-displace], length);
}
else {
priceHigh = firstHigh;
priceLow = firstLow;
# priceHigh = Highest(high(period = aggregationPeriod)[-displace], length);
# priceLow = Lowest(low(period = aggregationPeriod)[-displace], length);
}
priceHigh.SetDefaultColor(GetColor(4));
priceHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
priceLow.SetDefaultColor(GetColor(4));
priceLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
def newDay = GetDay() <> GetDay()[1];
rec firstOpen = if newDay then open else firstOpen[1];
rec firstHigh = if newDay then high else firstHigh[1];
rec firstLow = if newDay then low else firstLow[1];
rec firstClose = if newDay then close else firstClose[1];
#plot priceOpen = firstOpen;
plot priceHigh = firstHigh;
plot priceLow = firstLow;
#plot priceClose = firstClose;
I tried this too
input aggregationPeriod = AggregationPeriod.THIRTY_MIN;
input length = 1;
input displace = -1;
input showOnlyLastPeriod = no;
def newDay = GetDay() <> GetDay()[1];
rec firstOpen = if newDay then open else firstOpen[1];
rec firstHigh = if newDay then high else firstHigh[1];
rec firstLow = if newDay then low else firstLow[1];
rec firstClose = if newDay then close else firstClose[1];
#plot priceOpen = firstOpen;
#plot priceHigh = firstHigh;
#plot priceLow = firstLow;
#plot priceClose = firstClose;
plot priceHigh;
plot priceLow;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) {
priceHigh = firstHigh;
priceLow = firstLow;
# priceHigh = Highest(high(period = aggregationPeriod)[-displace], length);
# priceLow = Lowest(low(period = aggregationPeriod)[-displace], length);
}
else {
priceHigh = firstHigh;
priceLow = firstLow;
# priceHigh = Highest(high(period = aggregationPeriod)[-displace], length);
# priceLow = Lowest(low(period = aggregationPeriod)[-displace], length);
}
priceHigh.SetDefaultColor(GetColor(4));
priceHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
priceLow.SetDefaultColor(GetColor(4));
priceLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);