Hey SleepyZ!
Quick question on this, do you mind confirming the fact this won't update if a new low/high is hit in current day correct? For example, lets say 10L is 4000 and in the current day session we hit 3998. Until tomorrow, the marked price level from the indicator will remain at 4000 and not update intraday correct?
The above code as written includes the current day's high/low. Make sure you have the highest days_ago displayed on your chart.
The code below should exclude the current day as you want. The bubbles have been edited to display the days_ago input.
Code:#HH_LL_From_XYZ_days_ago_Excluding_Today_INCLUDING_EXT_HOURS script hl { input Days_Ago = 2; def ymd = GetYYYYMMDD(); def candles = !IsNaN(close); def capture = candles and ymd != ymd[1]; def dayCount = CompoundValue(1, if capture then dayCount[1] + 1 else dayCount[1], 0); def thisDay = (HighestAll(dayCount) - dayCount) ; def H = if thisDay == Days_Ago then high else if thisDay <= Days_Ago and thisDay > 1 then Max(high, H[1]) else Double.NaN; plot HH = if thisDay > Days_Ago then Double.NaN else HighestAll(H); def L = if thisDay == Days_Ago then low else if thisDay <= Days_Ago and thisDay > 1 then Min(low, L[1]) else Double.NaN; plot LL = if thisDay > Days_Ago then Double.NaN else LowestAll(L); } input days_ago_1 = 10; input days_ago_2 = 20; input days_ago_3 = 30; input show_on_lastday_only = no; def lastday = GetDay() == GetLastDay(); plot H1 = if show_on_lastday_only and lastday then hl(days_ago_1) else if !show_on_lastday_only then hl(days_ago_1) else Double.NaN; plot H2 = if show_on_lastday_only and lastday then hl(days_ago_2) else if !show_on_lastday_only then hl(days_ago_2) else Double.NaN; plot H3 = if show_on_lastday_only and lastday then hl(days_ago_3) else if !show_on_lastday_only then hl(days_ago_3) else Double.NaN; plot L1 = if show_on_lastday_only and lastday then hl(days_ago_1).LL else if !show_on_lastday_only then hl(days_ago_1).LL else Double.NaN; plot L2 = if show_on_lastday_only and lastday then hl(days_ago_2).LL else if !show_on_lastday_only then hl(days_ago_2).LL else Double.NaN; plot L3 = if show_on_lastday_only and lastday then hl(days_ago_3).LL else if !show_on_lastday_only then hl(days_ago_3).LL else Double.NaN; DefineGlobalColor("HL10", Color.CYAN); DefineGlobalColor("HL20", Color.WHITE); DefineGlobalColor("HL30", Color.YELLOW); H1.SetDefaultColor(GlobalColor("HL10")); L1.SetDefaultColor(GlobalColor("HL10")); H2.SetDefaultColor(GlobalColor("HL20")); L2.SetDefaultColor(GlobalColor("HL20")); H3.SetDefaultColor(GlobalColor("HL30")); L3.SetDefaultColor(GlobalColor("HL30")); input show_bubbles = yes; input bubblemover = 2; def b = bubblemover; def b1 = b + 1; AddChartBubble(IsNaN(close[b]) and !IsNaN(close[b1]), H1[b], days_ago_1 + "H", H1.TakeValueColor()); AddChartBubble(IsNaN(close[b]) and !IsNaN(close[b1]), H2[b], days_ago_2 + "H", H2.TakeValueColor()); AddChartBubble(IsNaN(close[b]) and !IsNaN(close[b1]), H3[b], days_ago_3 + "H", H3.TakeValueColor()); AddChartBubble(IsNaN(close[b]) and !IsNaN(close[b1]), L1[b], days_ago_1 + "L", L1.TakeValueColor()); AddChartBubble(IsNaN(close[b]) and !IsNaN(close[b1]), L2[b], days_ago_2 + "L", L2.TakeValueColor()); AddChartBubble(IsNaN(close[b]) and !IsNaN(close[b1]), L3[b], days_ago_3 + "L", L3.TakeValueColor());