OPEN-SOURCE SCRIPT
Orderflow Label with Offset

This Pine Script automatically displays orderflow labels on the chart to visualize the current market structure and potential breakout or reversal zones.
It compares the current candle’s high and low with those of the previous cycle (e.g., 90 minutes) and places descriptive labels that highlight possible bullish or bearish behavior.
Functionality & Logic (Step-by-step explanation)
Inputs:
cycleLength: Defines the duration of one “cycle” in minutes (for example, 90 minutes).
labelXOffset: Moves the label a few bars to the right, so it doesn’t overlap the current candle.
labelStyleOffset: Controls whether labels appear pointing to the right or left side of the chart.
Previous Cycle:
The script uses request.security to retrieve the high and low from the previous cycle timeframe.
These act as reference points (similar to key levels or market structure highs/lows).
Current Candle:
The script reads the current bar’s high, low, and close values for comparison.
Orderflow Conditions:
bullSupport: The current high and close are both above the previous high → bullish breakout (strong continuation).
bullReject: The high breaks above the previous high but closes below → bullish rejection / possible top.
bearRes: The low and close are both below the previous low → bearish breakdown (continuation to downside).
bearReclaim: The low goes below the previous low but closes above → bearish reclaim / possible reversal.
Label Logic:
Before creating a new label, the previous one is deleted (label.delete(flowLbl)) to avoid clutter.
The label’s X position is shifted using xPos = bar_index + labelXOffset.
The style (left/right) is set based on the user’s preference.
Displayed Labels:
🟢 Bullish Breakout → price closes above the previous cycle high.
🟠 Bullish Rejection → fake breakout or possible top.
🔴 Bearish Breakdown → price closes below the previous cycle low.
🟡 Bearish Reclaim → failed breakdown or potential trend reversal.
⚪ Neutral (Wait) → no clear signal, advises patience and watching for setups (like CHoCH or FVGs).
Visual Behavior:
The labels appear slightly to the right of the bar for better visibility.
The color and text alignment dynamically adjust depending on whether the label is pointing left or right.
It compares the current candle’s high and low with those of the previous cycle (e.g., 90 minutes) and places descriptive labels that highlight possible bullish or bearish behavior.
Functionality & Logic (Step-by-step explanation)
Inputs:
cycleLength: Defines the duration of one “cycle” in minutes (for example, 90 minutes).
labelXOffset: Moves the label a few bars to the right, so it doesn’t overlap the current candle.
labelStyleOffset: Controls whether labels appear pointing to the right or left side of the chart.
Previous Cycle:
The script uses request.security to retrieve the high and low from the previous cycle timeframe.
These act as reference points (similar to key levels or market structure highs/lows).
Current Candle:
The script reads the current bar’s high, low, and close values for comparison.
Orderflow Conditions:
bullSupport: The current high and close are both above the previous high → bullish breakout (strong continuation).
bullReject: The high breaks above the previous high but closes below → bullish rejection / possible top.
bearRes: The low and close are both below the previous low → bearish breakdown (continuation to downside).
bearReclaim: The low goes below the previous low but closes above → bearish reclaim / possible reversal.
Label Logic:
Before creating a new label, the previous one is deleted (label.delete(flowLbl)) to avoid clutter.
The label’s X position is shifted using xPos = bar_index + labelXOffset.
The style (left/right) is set based on the user’s preference.
Displayed Labels:
🟢 Bullish Breakout → price closes above the previous cycle high.
🟠 Bullish Rejection → fake breakout or possible top.
🔴 Bearish Breakdown → price closes below the previous cycle low.
🟡 Bearish Reclaim → failed breakdown or potential trend reversal.
⚪ Neutral (Wait) → no clear signal, advises patience and watching for setups (like CHoCH or FVGs).
Visual Behavior:
The labels appear slightly to the right of the bar for better visibility.
The color and text alignment dynamically adjust depending on whether the label is pointing left or right.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.