OPEN-SOURCE SCRIPT
Coasyn Directional Order Blocks

Coasyn Directional Order Blocks
Coasyn Directional Order Blocks identifies directional supply and demand zones created around market-structure breaks with displacement.
The indicator is designed to help traders visualize potential areas of prior institutional participation without turning those zones into automatic trade signals.
It tracks both:
Demand Order Blocks
Supply Order Blocks
Each block remains active until it is touched, invalidated, or removed according to the settings selected by the user.
How blocks are created
A new block requires two things:
1. A structure break
The indicator tracks recent swing highs and swing lows using the configured Structure Swing Length.
A demand block requires price to break above the most recent tracked swing high.
A supply block requires price to break below the most recent tracked swing low.
2. Displacement
The structure break must occur with a directional displacement candle.
The displacement filter uses:
ATR-relative candle range
minimum candle-body percentage
bullish direction for demand
bearish direction for supply
This helps prevent every minor structure break from automatically becoming an order block.
Origin candle
After a valid structure break, the indicator searches backward for the opposing candle that preceded the move.
For a Demand Block, it searches for a bearish candle.
For a Supply Block, it searches for a bullish candle.
The number of candles searched is controlled by:
Origin Candle Search
Order Block Zone
The Order Block Zone setting determines how much of the origin candle becomes the displayed zone.
Available options:
Full Candle
Uses the full high-to-low range of the origin candle.
Body
Uses only the candle body.
Refined
Uses a directional refinement of the candle range.
For demand, the refined zone uses the candle low through the top of the body.
For supply, the refined zone uses the bottom of the body through the candle high.
Block states
Each block begins as a fresh active zone.
The indicator then tracks whether price returns to the zone.
The Touched When setting controls when a block is considered touched.
Available options:
First Contact
The block becomes touched as soon as price reaches the outer edge of the zone.
50% Reached
Price must reach the midpoint of the order block.
Full Fill
Price must travel completely through the block to its opposite boundary.
Keeping touched blocks
Enable:
Keep Touched Blocks
to leave previously contacted blocks visible.
Touched blocks are displayed with increased transparency so they can be visually distinguished from fresh zones.
Disable this setting if you want a block removed after its first qualifying interaction.
Invalidation
The Invalidated When setting determines when a block is considered structurally broken.
Available options:
Close Beyond
A candle must close beyond the invalidation boundary.
Wick Beyond
Any wick through the invalidation boundary is sufficient.
For demand blocks, invalidation occurs below the zone.
For supply blocks, invalidation occurs above the zone.
Keeping invalidated blocks
Enable:
Keep Invalidated Blocks
if you want failed blocks to remain visible for review.
Invalidated blocks are converted to a neutral gray appearance and stop extending forward.
When disabled, invalidated blocks are removed from the chart.
Maximum active blocks
Maximum Active Blocks per Direction controls how many demand and supply zones can remain active at once.
Older blocks are removed automatically when the configured maximum is exceeded.
Demand and supply limits are tracked independently.
Forward projection
Forward Projection determines how far active order blocks extend to the right of the chart.
The zone continues updating forward while it remains active.
50% midline
Enable:
Show 50% Line
to display the midpoint of each order block.
This provides a visual reference for traders who use partial mitigation or midpoint interaction as part of their own process.
Structure break markers
Enable:
Show Structure Break Marker
to mark the candle where a valid displacement-driven structure break created a new order block.
These markers are optional and are disabled by default.
Labels
Enable:
Show Demand / Supply Label
to display the directional identity of each block directly inside the zone.
Colors
Demand and supply colors are fully configurable.
Users can also adjust:
fresh-block transparency
touched-block transparency
invalidated-block color
Alerts
The indicator includes alert conditions for:
New Demand Order Block
New Supply Order Block
Demand Order Block Entered
Supply Order Block Entered
Demand Order Block Invalidated
Supply Order Block Invalidated
Alerts must still be configured by the user through TradingView's alert system.
Example workflow
A trader may use the indicator to identify a demand zone created after a strong bullish displacement through prior structure.
The trader can then observe whether price:
remains away from the block → returns to the block → reaches the selected touch threshold → holds or invalidates
The indicator reports the state of the zone.
It does not determine whether the trader should enter.
Important
Coasyn Directional Order Blocks is a market-structure visualization tool.
It does not provide:
automatic entries
buy or sell recommendations
targets
stop placement
position sizing
automated execution
Order blocks should be interpreted within the trader's own market structure, risk, and strategy framework.
A displayed block is a reference zone, not a guarantee of future support, resistance, reversal, or continuation.
Built by Coasyn Market Systems.
Coasyn Directional Order Blocks identifies directional supply and demand zones created around market-structure breaks with displacement.
The indicator is designed to help traders visualize potential areas of prior institutional participation without turning those zones into automatic trade signals.
It tracks both:
Demand Order Blocks
Supply Order Blocks
Each block remains active until it is touched, invalidated, or removed according to the settings selected by the user.
How blocks are created
A new block requires two things:
1. A structure break
The indicator tracks recent swing highs and swing lows using the configured Structure Swing Length.
A demand block requires price to break above the most recent tracked swing high.
A supply block requires price to break below the most recent tracked swing low.
2. Displacement
The structure break must occur with a directional displacement candle.
The displacement filter uses:
ATR-relative candle range
minimum candle-body percentage
bullish direction for demand
bearish direction for supply
This helps prevent every minor structure break from automatically becoming an order block.
Origin candle
After a valid structure break, the indicator searches backward for the opposing candle that preceded the move.
For a Demand Block, it searches for a bearish candle.
For a Supply Block, it searches for a bullish candle.
The number of candles searched is controlled by:
Origin Candle Search
Order Block Zone
The Order Block Zone setting determines how much of the origin candle becomes the displayed zone.
Available options:
Full Candle
Uses the full high-to-low range of the origin candle.
Body
Uses only the candle body.
Refined
Uses a directional refinement of the candle range.
For demand, the refined zone uses the candle low through the top of the body.
For supply, the refined zone uses the bottom of the body through the candle high.
Block states
Each block begins as a fresh active zone.
The indicator then tracks whether price returns to the zone.
The Touched When setting controls when a block is considered touched.
Available options:
First Contact
The block becomes touched as soon as price reaches the outer edge of the zone.
50% Reached
Price must reach the midpoint of the order block.
Full Fill
Price must travel completely through the block to its opposite boundary.
Keeping touched blocks
Enable:
Keep Touched Blocks
to leave previously contacted blocks visible.
Touched blocks are displayed with increased transparency so they can be visually distinguished from fresh zones.
Disable this setting if you want a block removed after its first qualifying interaction.
Invalidation
The Invalidated When setting determines when a block is considered structurally broken.
Available options:
Close Beyond
A candle must close beyond the invalidation boundary.
Wick Beyond
Any wick through the invalidation boundary is sufficient.
For demand blocks, invalidation occurs below the zone.
For supply blocks, invalidation occurs above the zone.
Keeping invalidated blocks
Enable:
Keep Invalidated Blocks
if you want failed blocks to remain visible for review.
Invalidated blocks are converted to a neutral gray appearance and stop extending forward.
When disabled, invalidated blocks are removed from the chart.
Maximum active blocks
Maximum Active Blocks per Direction controls how many demand and supply zones can remain active at once.
Older blocks are removed automatically when the configured maximum is exceeded.
Demand and supply limits are tracked independently.
Forward projection
Forward Projection determines how far active order blocks extend to the right of the chart.
The zone continues updating forward while it remains active.
50% midline
Enable:
Show 50% Line
to display the midpoint of each order block.
This provides a visual reference for traders who use partial mitigation or midpoint interaction as part of their own process.
Structure break markers
Enable:
Show Structure Break Marker
to mark the candle where a valid displacement-driven structure break created a new order block.
These markers are optional and are disabled by default.
Labels
Enable:
Show Demand / Supply Label
to display the directional identity of each block directly inside the zone.
Colors
Demand and supply colors are fully configurable.
Users can also adjust:
fresh-block transparency
touched-block transparency
invalidated-block color
Alerts
The indicator includes alert conditions for:
New Demand Order Block
New Supply Order Block
Demand Order Block Entered
Supply Order Block Entered
Demand Order Block Invalidated
Supply Order Block Invalidated
Alerts must still be configured by the user through TradingView's alert system.
Example workflow
A trader may use the indicator to identify a demand zone created after a strong bullish displacement through prior structure.
The trader can then observe whether price:
remains away from the block → returns to the block → reaches the selected touch threshold → holds or invalidates
The indicator reports the state of the zone.
It does not determine whether the trader should enter.
Important
Coasyn Directional Order Blocks is a market-structure visualization tool.
It does not provide:
automatic entries
buy or sell recommendations
targets
stop placement
position sizing
automated execution
Order blocks should be interpreted within the trader's own market structure, risk, and strategy framework.
A displayed block is a reference zone, not a guarantee of future support, resistance, reversal, or continuation.
Built by Coasyn Market Systems.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.