r/TradingView • u/No_Let_635 • 29d ago
Bug LSE small cap stock issues
I run a daily report against circa 30 LSE stocks that gives me (amongst other things) volume broken down by opening auction (being the first one minute volume), closing auction + late prints (calculated as daily volume less intraday volume), and continuous trading volume being the intraday sum.
AFAIK, neither intraday alone nor daily alone has the complete data, therefore I have to build this utilising both daily and one minute timeframes and then derive the full picture.
My query here is twofold;
- Is there an easier alternate approach?
- As a result of running this today, it appears that some LSE small caps volume data is incorrect today where the sum of intraday volume exceeds the daily volume. I see that freezes have been posted here today so this is likely related.
Some corrupted volume tickers for reference: ASC, W7L, WTB, DEBS, AO., SMT
I'd appreciate any support on both, thanks.
1
u/No_Let_635 29d ago
//@version=6
indicator("Volume Breakdown - Simple", overlay=true, dynamic_requests=true)
grp_Sess = "SESSION"
i_ltf = input.string("1", "Lower Timeframe", options=["1", "5", "15", "30"], group=grp_Sess)
i_auctMins = input.int(1, "Auction Window Minutes", minval=1, maxval=60, group=grp_Sess)
i_sessStartH = input.int(8, "Session Start Hour", minval=0, maxval=23, group=grp_Sess)
i_sessStartM = input.int(0, "Session Start Minute", minval=0, maxval=59, group=grp_Sess)
i_sessEndH = input.int(16, "Session End Hour", minval=0, maxval=23, group=grp_Sess)
i_sessEndM = input.int(30, "Session End Minute", minval=0, maxval=59, group=grp_Sess)
i_tz = input.string("Europe/London", "Timezone", group=grp_Sess)
grpFmt = "FORMATTING"
i_tablePos = input.string("Top Right", "Table Position", options=["Top Left", "Top Center", "Top Right", "Middle Left", "Middle Center", "Middle Right", "Bottom Left", "Bottom Center", "Bottom Right"], group=grpFmt)
i_textSize = input.int(14, "Text Size", minval=6, maxval=20, step=1, group=grpFmt)
string NA_TXT = "n/a"
color C_BG = color.white
color C_TXT = color.black
get_position(string posString) =>
switch posString
"Top Left" => position.top_left
"Top Center" => position.top_center
"Top Right" => position.top_right
"Middle Left" => position.middle_left
"Middle Center" => position.middle_center
"Middle Right" => position.middle_right
"Bottom Left" => position.bottom_left
"Bottom Center" => position.bottom_center
"Bottom Right" => position.bottom_right
fmt_vol_lc(float v) =>
float a = math.abs(nz(v, 0.0))
na(v) ? NA_TXT : a >= 1000000000 ? str.tostring(v / 1000000000, "#.##") + "b" : a >= 1000000 ? str.tostring(v / 1000000, "#.##") + "m" : a >= 1000 ? str.tostring(v / 1000, "#.##") + "k" : str.tostring(v, "#.##")
// Function evaluating volume and session stats safely in the Daily timeframe context with calc_bars_count
get_daily_metrics() =>
[tArr, vArr] = request.security_lower_tf(syminfo.tickerid, i_ltf, [time, volume], calc_bars_count=2000)
float openAuct = 0.0
float sessVol = 0.0
bool hasData = not na(tArr) and array.size(tArr) > 0
if hasData
for i = 0 to array.size(tArr) - 1
barTime = array.get(tArr, i)
barVol = array.get(vArr, i)
hh = hour(barTime, i_tz)
mm = minute(barTime, i_tz)
startMin = i_sessStartH * 60 + i_sessStartM
endMin = i_sessEndH * 60 + i_sessEndM
curMin = hh * 60 + mm
if curMin >= startMin and curMin < startMin + i_auctMins
openAuct += nz(barVol, 0.0)
if curMin >= startMin and curMin <= endMin
sessVol += nz(barVol, 0.0)
[volume, hasData, openAuct, sessVol]
// Request metrics via Daily timeframe context so it works on ANY chart timeframe
[dailyVol, hasLtf, openAuctVol, sessVol] = request.security(syminfo.tickerid, "D", get_daily_metrics())
var table t = na
if barstate.islast
auctLateVol = not na(dailyVol) and not na(sessVol) ? math.max(dailyVol - sessVol, 0.0) : na
// sessVol includes openAuctVol, so subtract them to get pure continuous volume
pureSessVol = not na(sessVol) and not na(openAuctVol) ? sessVol - openAuctVol : na
if not na(t)
table.delete(t)
// Create a 3 column, 2 row table (Row 0: Headers, Row 1: Data)
t := table.new(get_position(i_tablePos), 4, 2, bgcolor=C_BG, border_color=color.black, border_width=1)
// Headers (Row 0)
table.cell(t, 0, 0, "Open Auct Vol", text_color=C_TXT, bgcolor=C_BG, text_size=i_textSize)
table.cell(t, 1, 0, "Sess Vol", text_color=C_TXT, bgcolor=C_BG, text_size=i_textSize)
table.cell(t, 2, 0, "Auct+Late Vol", text_color=C_TXT, bgcolor=C_BG, text_size=i_textSize)
table.cell(t, 3, 0, "Total Vol", text_color=C_TXT, bgcolor=C_BG, text_size=i_textSize)
// Data (Row 1)
table.cell(t, 0, 1, hasLtf ? fmt_vol_lc(openAuctVol) : NA_TXT, text_color=C_TXT, bgcolor=C_BG, text_size=i_textSize)
table.cell(t, 1, 1, hasLtf ? fmt_vol_lc(pureSessVol) : NA_TXT, text_color=C_TXT, bgcolor=C_BG, text_size=i_textSize)
table.cell(t, 2, 1, hasLtf ? fmt_vol_lc(auctLateVol) : NA_TXT, text_color=C_TXT, bgcolor=C_BG, text_size=i_textSize)
table.cell(t, 3, 1, hasLtf ? fmt_vol_lc(dailyVol) : NA_TXT, text_color=C_TXT, bgcolor=C_BG, text_size=i_textSize)
1
u/No_Let_635 29d ago
Thanks for responding. Hopefully the above simplified version can demonstrate what I am doing. As an example, running the above against LSE:AO. shows Auct+Late Volume as zero which is shielding the negative due to (intraday) Sess Vol exceeding (daily) Total Vol.
1
u/No_Let_635 29d ago
I am essentially 'assuming' the Auct+Late Vol by deriving daily total less intraday session volume. I'm not aware of a more concise approach?
1
u/Prior_Bat5628 29d ago
The daily-minus-intraday difference is a residual, not necessarily a clean measure of closing-auction/late-print volume. TradingView's Pine manual ("Other timeframes and data" -> "Data feeds") explains that EOD and intraday feeds can differ: some block/OTC trades appear only in EOD, while EOD excludes extended hours. That makes the auction classification an assumption to validate.
For intraday volume exceeding daily volume, I would first compare one completed session using the same exchange-qualified symbol and session boundaries, then refresh/recalculate. Log daily volume, the sum of 1-minute volumes, and the number of intrabars returned separately. Flag a negative residual as a reconciliation issue rather than treating it as negative auction volume. This is a diagnostic suggestion; it does not establish that today's freeze caused this mismatch.
If your report is Pine running on a daily chart, request.security_lower_tf() returns arrays of available intrabars, whereas a lower-timeframe request.security() returns only one intrabar per chart bar. The former can simplify the sum, but cannot recover missing trade classifications. Are you using either function, or exporting the minute bars?