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.
Script de código abierto
Siguiendo fielmente el espíritu de TradingView, el creador de este script lo ha publicado en código abierto, permitiendo que otros traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Puede utilizarlo de forma gratuita, pero tenga en cuenta que la publicación de este código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.
Script de código abierto
Siguiendo fielmente el espíritu de TradingView, el creador de este script lo ha publicado en código abierto, permitiendo que otros traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Puede utilizarlo de forma gratuita, pero tenga en cuenta que la publicación de este código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.