OPEN-SOURCE SCRIPT
Order Flow + Spread Proxy Prediction [Pine v6]

Order Flow + Spread Proxy Prediction [Pine v6] is a market microstructure-inspired indicator designed to estimate short-term directional pressure using TradingView-accessible OHLCV data. Since Pine Script does not normally provide full Level 2 order book depth, true bid-ask spread, tick-by-tick trade classification, or real aggressive buy and sell order flow, this script does not claim to measure institutional order flow directly. Instead, it builds a volume-price order-flow proxy model based on candle structure, volume behavior, close-location value, cumulative volume delta proxy, VWAP deviation, range-based spread risk, Amihud illiquidity, VPIN-like toxic flow risk, and liquidity confirmation. The model first estimates directional buying or selling pressure from candle body direction, close position within the bar, and volume distribution. It then measures whether that pressure is accumulating through a CVD slope proxy and adjusts the signal using VWAP positioning, liquidity conditions, spread risk, and toxicity risk. The final composite score is smoothed and converted into an estimated probability of upward price movement. A long signal is generated when the estimated upside probability exceeds the bullish threshold, the composite score is sufficiently positive, and the EMA trend filter confirms a bullish regime. A short signal is generated when the estimated upside probability falls below the bearish threshold, the composite score is sufficiently negative, and the EMA trend filter confirms a bearish regime. The indicator also includes background coloring, signal labels, VWAP and EMA plots, and a dashboard showing probability, composite score, OFI proxy, CVD score, VWAP score, spread risk, VPIN risk, and trend direction. This tool is best suited for liquid intraday markets such as BTC, ETH, major futures, and high-volume equities on short timeframes such as 1-minute, 3-minute, 5-minute, and 15-minute charts. It should be understood as a proxy-based microstructure indicator rather than a true order book or institutional flow system, and its signals should be used together with risk management, execution-cost awareness, and independent market judgment.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.