PINE LIBRARY
تم تحديثه Objective Market Structure Framework

This library provides a systematic, rule-based approach to categorize market movements into four objective phases: Compression, Expansion, Distribution, and Consolidation.
Instead of subjective chart patterns, this tool uses volatility-relative thresholds (ATR) and momentum filters to identify significant trading ranges and structural breaks.
Main Use Cases:
Core Features:
How to use (Educational Example included):
The source code contains a fully functional MTF Dashboard example (commented out at the bottom). It demonstrates how to map the library’s output variables into a visual trading interface, showing HTF trend alignment and real-time market phases.
Quick Start (Implementation):
import arnipoer/PriceActionStructure/1 as pa
// Single request for all 19 structural variables
[strHigh, strHighTime, strLow, strLowTime,
highestHigh, lowestLow, upMove, downMove,
raw_strHigh, raw_strHighTime, raw_strLow, raw_strLowTime,
compress, standardRange, hugeRange,
distrLong, distrShort, consolLong, consolShort] =
request.security(syminfo.tickerid, "D",
pa.get_structure(true, 1.0, close, 14, 1.2, 1.5, 4.0))
// Example: Visualization
plot(strHigh, color=color.aqua, title="HTF Structure High")
bgcolor(hugeRange ? color.new(color.purple, 80) : na, title="Expansion Alert")
Disclaimer: No financial advice. Trading involves significant risk. This is an analytical tool for professional traders to build their own systematic strategies.
Instead of subjective chart patterns, this tool uses volatility-relative thresholds (ATR) and momentum filters to identify significant trading ranges and structural breaks.
Main Use Cases:
- Clear & Compact MTF Visualization: Map higher-timeframe (HTF) market structures directly onto your lower-timeframe (LTF) charts. Provides a clean, non-cluttered overview for an intuitive display of key levels without overcomplicating the chart.
- Automated Setup Classification: Assign specific trading setups to distinct market regimes (Uptrends, Corrections, Sideways Ranges). Enables rapid, objective analysis every trading day, eliminating the need for manual re-evaluation or "hunting" for the current trend state.
Core Features:
- Volatility-Adaptive: Range calculations scale automatically with the market's current ATR, making the analysis relevant across all asset classes.
- MTF-Optimized Performance: Engineered for professional Multi-Timeframe workflows. Fetch 19 structural variables with a single request.security() call to minimize script load and prevent memory errors.
- Momentum Validation: Distinguishes between high-conviction structural breaks and low-momentum "noise" using body-to-ATR ratios.
- Reliability & Stability: Built-in Guard-Clauses protect against "Bar 0" and "NA" runtime errors, even when requesting lower timeframe data from a higher timeframe chart.
- Key Parameters (Customizable Defaults):
- Distribution Threshold (e.g. 1.2): Identifies price movement beyond the established range to confirm trend strength.
- Compression (e.g. 1.5x ATR): Detects low-volatility buildup phases.
- Expansion (e.g. 4.0x ATR): Flags explosive "Huge Range" impulses.
How to use (Educational Example included):
The source code contains a fully functional MTF Dashboard example (commented out at the bottom). It demonstrates how to map the library’s output variables into a visual trading interface, showing HTF trend alignment and real-time market phases.
Quick Start (Implementation):
import arnipoer/PriceActionStructure/1 as pa
// Single request for all 19 structural variables
[strHigh, strHighTime, strLow, strLowTime,
highestHigh, lowestLow, upMove, downMove,
raw_strHigh, raw_strHighTime, raw_strLow, raw_strLowTime,
compress, standardRange, hugeRange,
distrLong, distrShort, consolLong, consolShort] =
request.security(syminfo.tickerid, "D",
pa.get_structure(true, 1.0, close, 14, 1.2, 1.5, 4.0))
// Example: Visualization
plot(strHigh, color=color.aqua, title="HTF Structure High")
bgcolor(hugeRange ? color.new(color.purple, 80) : na, title="Expansion Alert")
Disclaimer: No financial advice. Trading involves significant risk. This is an analytical tool for professional traders to build their own systematic strategies.
ملاحظات الأخبار
v21. Core Function Refactoring
• Renamed variables within the core function get_structure() to make the library usage more intuitive.
• The naming convention now better emphasizes the specific methodology used for High/Low identification.
• Note: You may need to update variable references in your existing scripts to match the new syntax.
2. Charting & Visualization Changes
• Removed Quickstart Guide: To keep the execution chart clean, the text-based guide has been removed.
• New Default Plot: The script now plots the OMSF Moving Average (MA) by default to provide immediate visual context.
3. New Feature: OMSF Moving Average (ma)
• Added a new function to calculate the OMSF MA. Unlike the filtered StrHigh/Low levels, the omsf.ma processes the entire price action structure. This provides a smoothed representation of the unfiltered structural flow.
4. Documentation & Education
• New Open-Source Demo: The educational examples have been outsourced to a separate "OMSF DEMO UI" script (releasing soon) to keep this library focused on performance.
• Description Update: The main description has been rewritten to better clarify the framework’s objective and its diverse use cases.
ملاحظات الأخبار
v3What is OMSF? The Objective Market Structure Framework (OMSF) is a tool designed to replace guesswork with a rule-based system. Instead of relying on "gut feelings" or subjective chart interpretation, this library uses a fixed logic to analyze market states. Why use this framework? The main goal is consistency. By using a constant set of rules for every trade, you create a foundation for real statistical analysis. This allows you to track your performance accurately and improve your strategy based on hard data rather than changing emotions.
Key Features
The core function of the library processes market data into 19 structural variables, helping you to:
• Locate Levels: Automatically identify high-probability support and resistance.
• Define Phases: Clearly distinguish between expansion (trending) and correction (ranging).
• Filter Market Noise: Recognize specific states like "Compression" (tight ranges) or "Huge Range" (high volatility) to avoid bad entries.
Main Use Cases
1. Automated Setup Classification. Assign your trading setups to specific market regimes (Uptrends, Corrections, or Sideways Ranges) automatically. This enables rapid, objective analysis every trading day, eliminating the need to manually "hunt" for the current trend or re-evaluate the market state from scratch.
2. Clear & Compact MTF Visualization. Map Higher-Timeframe (HTF) market structures directly onto your Lower-Timeframe (LTF) charts. OMSF provides a clean, clutter-free overview, giving you an intuitive display of key levels without overwhelming your workspace with unnecessary data.
3. For Pine Script® Developers The framework is designed to work seamlessly with the VisualStructureTools library. . By using OMSF-optimized drawing functions, developers can access powerful visual feedback during the building and debugging of complex environments. This integration ensures that you get the visual clarity needed for development without compromising chart performance or creating visual clutter.
(Note: VisualStructureTools is a separate library and must be linked/imported to enable these features.)

The Core: Systematic Structure Identification (The OMSF Lifecycle)
To maintain absolute objectivity, the framework processes price action through a rigorous three-stage validation pipeline. This ensures that every level is based on math rather than visual interpretation.
1. Running Peaks (peakHigh / peakLow) This is the first stage. A Running Peak is the extreme price point recorded during an active move.
• Status: Dynamic.
• Behavior: It updates in real-time with every new high or low as long as the current move continues.
2. Confirmed Levels (omsf.high / omsf.low) A Running Peak is promoted to a "Confirmed Level" only after a defined directional shift occurs.
• Status: Finalized.
• Behavior: This "locks" the price point into the core structure, transforming a temporary extreme into a historical structural point.
3. Validated Framework Levels (omsf.StrHigh / omsf.StrLow) This is the highest tier of validation. These levels represent the "Signal" within the structural noise.
• Status: Filtered & High-Probability.
• Behavior: A confirmed level only becomes a StrHigh/Low after passing additional volatility and momentum filters (e.g., ATR-relative swing size and candle body validation). These are the levels used for high-conviction decision-making.
Technical Prowess & MTF Optimization
The OMSF library is built with performance and stability in mind, ensuring a seamless experience even in complex multi-timeframe (MTF) environments.
• High-Efficiency Data Retrieval: Fetch 19 structural variables (levels, raw prices, and filtered states) with a single request.security() call. This minimizes calculation overhead, ensures maximum performance, and keeps your execution charts fast and responsive.
• Precision MTF-Visualization: The framework tracks precise swing times to enable MTF-safe, time-based visual objects (x-loc.bar_time).
◦ Developer Tip: Use the VisualStructureTools library for MTF-optimized setLine and setBox functions to build clean, professional-grade Pine Script® interfaces.
• Runtime Stability: The code includes robust guard clauses to prevent runtime errors and handle edge cases (such as data gaps or missing history), ensuring a reliable performance across all symbols and timeframes.
Disclaimer. This is an analytical framework designed for professional traders. It provides the structure; you provide the strategy. This is not financial advice.
I release my frameworks to the community to validate the OMSF logic against real-world volatility. This live feedback loop is essential for refining the code and ensuring the framework remains resilient and reliable across all market conditions.
Made in Germany 🇩🇪 with a focus on logic and precision.
مكتبة باين
كمثال للقيم التي تتبناها TradingView، نشر المؤلف شيفرة باين كمكتبة مفتوحة المصدر بحيث يمكن لمبرمجي باين الآخرين من مجتمعنا استخدامه بحرية. تحياتنا للمؤلف! يمكنك استخدام هذه المكتبة بشكل خاص أو في منشورات أخرى مفتوحة المصدر، ولكن إعادة استخدام هذا الرمز في المنشورات تخضع لقواعد الموقع.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
مكتبة باين
كمثال للقيم التي تتبناها TradingView، نشر المؤلف شيفرة باين كمكتبة مفتوحة المصدر بحيث يمكن لمبرمجي باين الآخرين من مجتمعنا استخدامه بحرية. تحياتنا للمؤلف! يمكنك استخدام هذه المكتبة بشكل خاص أو في منشورات أخرى مفتوحة المصدر، ولكن إعادة استخدام هذا الرمز في المنشورات تخضع لقواعد الموقع.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.