made few edits to scripts from
RobertPayne. Thank you for your script
Supply Demand Zones on various timeframes
# define swing low points
input length = 10;
input inRange = 1;
def bn = BarNumber();
def lastBar = HighestAll(if IsNaN(close) then 0 else bn);
def offset = Min(length - 1, lastBar - bn);
def swingLow = low < Lowest(low[1], length - 1) and low == GetValue(Lowest(low, length), -offset);
def swingHigh = high > Highest(high[1], length - 1) and high == GetValue(Highest(high, length), -offset);
# change candle colors just to make it easier to see what we are working with
AssignPriceColor(if swingLow then Color.LIME else if swingHigh then Color.red else Color.GRAY);
def atrRange = atr(length, AverageType.wEIGHTED);
# using a single plot to show the swing low points
def demandLow = if swingLow then low else demandLow[1];
plot PdemandLow = demandLow;
PdemandLow.SetDefaultColor(Color.RED);
PdemandLow.SetPaintingStrategy(12);
def demandHigh = if swingLow then high else demandHigh[1];
plot PdemandHigh = demandHigh;
PdemandHigh.SetDefaultColor(Color.GREEN);
PdemandHigh.SetPaintingStrategy(12);
def demandMid = if swingLow then (demandLow+demandHigh)/2 else demandMid[1];
plot PdemandMid = demandMid;
PdemandMid.SetDefaultColor(Color.cyan);
PdemandMid.SetPaintingStrategy(12);
AddCloud(PdemandMid, PdemandLow, Color.green, Color.green);
# using a single plot to show the swing High points
def SupplyLow = if swingHigh then low else SupplyLow[1];
plot PSupplyLow = SupplyLow;
PSupplyLow.SetDefaultColor(Color.RED);
PSupplyLow.SetPaintingStrategy(12);
def SupplyHigh = if swingHigh then high else SupplyHigh[1];
plot PSupplyHigh = SupplyHigh;
PSupplyHigh.SetDefaultColor(Color.GREEN);
PSupplyHigh.SetPaintingStrategy(12);
def SupplyMid = if swingHigh then (SupplyLow + SupplyHigh) / 2 else SupplyMid[1];
plot PSupplyMid = SupplyMid;
PSupplyMid.SetDefaultColor(Color.CYAN);
PSupplyMid.SetPaintingStrategy(12);
PSupplyMid.setLineWeight(2);
AddCloud(PSupplyMid , PSupplyHigh, Color.PINK, Color.PINK);
#def ht1 = if swingLow then c1+ ( c1*inRange ) / 100 else ht1[1];
#plot highTgt1 = ht1;
#highTgt1.SetDefaultColor(Color.green);
#highTgt1.SetPaintingStrategy(12);
#def lt1 = if swingLow then c1- ( c1*inRange ) / 100 else lt1[1];
#plot lowTgt1 = lt1;
#lowTgt1.SetDefaultColor(Color.red);
#lowTgt1.SetPaintingStrategy(12);
#def htAtr1 = if swingLow then c1+ ( c1*atrRange ) / 100 else htAtr1[1];
#plot highAtr11 = htAtr1;
#highAtr11.SetDefaultColor(Color.dark_green);
#highAtr11.SetPaintingStrategy(12);
#def ltAtr1 = if swingLow then c1- ( c1*atrRange ) / 100 else ltAtr1[1];
#plot lowAtr11 = ltAtr1;
#lowAtr11.SetDefaultColor(Color.white);
#lowAtr11.SetPaintingStrategy(12);