Builtins: level 1 quotes

The best bid and offer. On a live chart the newest bar carries the current quote, and every bar that formed while a script reading l1.* was on the chart keeps the last quote it saw, how many quotes arrived during it and the spread they showed. Bars from before that carry none and answer l1.available() false. In replay there is no recorded quote at all, so l1.supported() is false there. For a book with a recorded history, use the depth builtins.

SignatureReturns
l1.supported() -> boolWhether quotes are wired on this chart
l1.available() -> boolWhether a quote is attached to this bar
l1.bid_price() -> floatBest bid, nan without a quote
l1.ask_price() -> floatBest offer
l1.bid_size() -> floatSize at the best bid
l1.ask_size() -> floatSize at the best offer
l1.bid_exchange() -> stringBid exchange code, empty when not stated
l1.ask_exchange() -> stringOffer exchange code, empty when not stated
l1.quote_count() -> intHow many quotes arrived while this bar formed, 0 without any
l1.spread_avg() -> floatAverage offer minus bid over those quotes, nan without any
l1.spread_max() -> floatWidest spread seen during the bar
l1.spread_min() -> floatNarrowest spread seen during the bar
  • On past bars the quote is the one standing when the bar closed. On the newest bar it is the quote right now.
  • The chart keeps up to the newest 20,000 bars of quotes per instrument and timeframe. Reopening the chart starts the history again.
  • The spread statistics count only quotes with both a bid and an offer above zero.
let quoted: bool = l1.supported() && l1.available()
let spread: float = l1.ask_price() - l1.bid_price()
let jumpy: bool = quoted && l1.spread_max() > l1.spread_min() * 3
plot.marker(jumpy, high, "#F59E0B", "x", "above", 8, 2)
let book_lean: float = (l1.bid_size() - l1.ask_size()) / (l1.bid_size() + l1.ask_size())
if quoted {
  plot.label(str.concat("SPREAD ", format.fixed(spread, 2), "  BID ", format.compact(l1.bid_size()), " x ASK ", format.compact(l1.ask_size())), "#E5E7EB")
}

Všechny vrstvy trhu – od Orderflow po optionflow – v jednom grafu.

Orderflow data institucionální kvality s vestavěným backtestingem a obchodním deníkem. Zapište se na čekací listinu a získejte předběžný přístup.

Získat přístup