OPEN-SOURCE SCRIPT

Latent Energy Reactor [The_lurker]

1 516
Latent Energy Reactor | مفاعل الطاقة الكامنة

═════════════════════════════════════════════════════════════
🔬 THE PHILOSOPHY
═════════════════════════════════════════════════════════════

Markets operate in cycles of compression and expansion. Before every significant price movement, there exists a period where buyers and sellers reach a temporary equilibrium — a consolidation zone where energy accumulates like pressure building in a reactor.

The Latent Energy Reactor was designed to identify these critical zones, measure the energy building within them, and predict the direction of the inevitable breakout.

This indicator transforms the abstract concept of "market energy" into a quantifiable, visual system that traders can use to anticipate high-probability breakout opportunities.

═════════════════════════════════════════════════════════════
🎯 THE THREE BOX STATES
═════════════════════════════════════════════════════════════

Understanding the three box states is crucial for proper interpretation:

📦 STATE 1: ACTIVE ZONE (GRAY BOX)
─────────────────────────────────────
snapshot

Visual Characteristics:
• Color: Gray/Neutral with 3D depth effect
• Extends to the right edge of the chart (future projection)
• Contains pressure lines (dotted horizontal lines inside)
• Displays gravity center line (dashed line showing volume-weighted center)
• Energy progress bar beneath the box
• Real-time information panel appears on screen

What It Means:
The gray box represents a LIVE consolidation zone currently forming. Price is contained within the boundaries, and energy is actively accumulating. This is the "waiting phase" where the reactor is charging.

What to Watch:
• Energy percentage climbing toward critical levels (80%+)
• Gravity center position (upper half = bullish bias, lower half = bearish bias)
• Top and bottom rejection counts in the information panel
• Phase progression (Forming → Growth → Mature → Exhaustion)

Trading Approach:
Do NOT trade inside the gray box. This is the preparation phase. Monitor the energy levels and predicted direction, but wait for confirmation.

📦 STATE 2: BULLISH BREAKOUT BOX (GREEN BOX)
─────────────────────────────────────────────
snapshot

Visual Characteristics:
• Color: Green with 3D depth effect
• Box boundaries are now fixed (no longer extending right)
• Displays "BUY" text centered inside the box
• Stop Loss line appears below the box (orange)
• Three Take Profit lines appear above (teal/cyan)
• Entry line at the box's upper boundary (white dashed)

What It Means:
The green box indicates a CONFIRMED bullish breakout. Price has broken above the consolidation zone's upper boundary, releasing the accumulated energy upward.

Automatic Calculations Displayed:
• Entry Price: Upper boundary of the box
• Stop Loss: Lower boundary minus ATR buffer
• TP1: Entry + (Risk × 1.0) — 1:1 reward ratio
• TP2: Entry + (Risk × 1.5) — 1.5:1 reward ratio
• TP3: Entry + (Risk × 2.0) — 2:1 reward ratio

Trading Approach:
Consider long positions with the displayed SL/TP levels as guidelines. The higher the energy level and breakout quality score were before the breakout, the more reliable the signal.

📦 STATE 3: BEARISH BREAKOUT BOX (RED BOX)
──────────────────────────────────────────
snapshot

Visual Characteristics:
• Color: Red with 3D depth effect
• Box boundaries are now fixed
• Displays "SELL" text centered inside the box
• Stop Loss line appears above the box (orange)
• Three Take Profit lines appear below (teal/cyan)
• Entry line at the box's lower boundary (white dashed)

What It Means:
The red box indicates a CONFIRMED bearish breakout. Price has broken below the consolidation zone's lower boundary, releasing the accumulated energy downward.

Automatic Calculations Displayed:
• Entry Price: Lower boundary of the box
• Stop Loss: Upper boundary plus ATR buffer
• TP1: Entry - (Risk × 1.0) — 1:1 reward ratio
• TP2: Entry - (Risk × 1.5) — 1.5:1 reward ratio
• TP3: Entry - (Risk × 2.0) — 2:1 reward ratio

Trading Approach:
Consider short positions with the displayed SL/TP levels as guidelines. Stronger setups have higher pre-breakout energy and quality scores.

═════════════════════════════════════════════════════════════
⚛️ THE ENERGY CALCULATION SYSTEM
═════════════════════════════════════════════════════════════

The energy percentage (0-100%) is calculated using four factors:

Compression Score (up to 40 points)
Measures how tight the range is relative to normal volatility (ATR). Tighter compression = higher energy storage.

Time Score (up to 35 points)
Longer consolidation periods accumulate more energy. Each bar adds to the score up to the maximum.

Maturity Bonus (up to 15 points)
Zones that reach mature phases receive bonus energy points, recognizing that extended consolidations often produce more powerful breakouts.

Tightness Bonus (up to 10 points)
Extra points awarded when the range height is exceptionally small relative to ATR.

═════════════════════════════════════════════════════════════
📊 THE GRAVITY CENTER SYSTEM
═════════════════════════════════════════════════════════════

How It Works:
The gravity center is the volume-weighted average price within the consolidation zone. It reveals where the majority of trading activity (and thus institutional interest) is concentrated.

Interpretation:
• Gravity center in UPPER half → Institutions accumulating → Bullish bias
• Gravity center in LOWER half → Institutions distributing → Bearish bias
• Gravity center at MIDDLE → Neutral/Uncertain

Visual Display:
A dashed line with a ⚖️ symbol marks the gravity center inside active zones. The line color matches the directional bias.

═════════════════════════════════════════════════════════════
🏦 INSTITUTIONAL FOOTPRINT DETECTION
═════════════════════════════════════════════════════════════

What It Measures:
The indicator scans for volume anomalies — bars where volume significantly exceeds the average while price remains contained within the zone.

Why It Matters:
Large volume without price movement often indicates institutional players building positions. They cannot accumulate or distribute large quantities without leaving a "footprint" in the volume data.

Score Interpretation:
• Below 30%: Normal retail activity
• 30-50%: Some institutional interest detected
• Above 50%: Significant institutional footprint (marked with 🏦 icon)

═════════════════════════════════════════════════════════════
📈 MATURITY PHASES
═════════════════════════════════════════════════════════════

⚒ Forming Phase
The zone has just been identified. Energy is low, and the pattern needs more time to develop. Premature breakouts during this phase have higher failure rates.

📈 Growth Phase
The zone is developing nicely. Energy is building, and the consolidation pattern is becoming more defined. Watch for increasing rejection counts at boundaries.

✅ Mature Phase
Optimal trading phase. The zone has accumulated significant energy, institutional footprints are often visible, and breakout quality scores are typically highest.

⚠ Exhaustion Phase
The zone has persisted beyond typical duration. While energy remains high, the pattern may be losing its predictive power.

═════════════════════════════════════════════════════════════
🎨 VISUAL ELEMENTS GUIDE
═════════════════════════════════════════════════════════════

3D Box Effect
The 3D rendering creates visual depth with a top face and side face, making boxes stand out clearly. Adjustable via "3D Depth" and "3D Height %" settings.

Pressure Lines
Dotted horizontal lines inside active zones visualize internal pressure distribution. Lines closer to the gravity center are more opaque.

Energy Progress Bar
A horizontal bar beneath each zone shows energy level visually. Color progresses: green (low) → yellow (moderate) → orange (high) → red (critical).

Imminent Breakout Warning
When energy reaches critical threshold (default 80%), a warning label "⚠ IMMINENT!" appears above the active zone.

Information Panel
Real-time table displaying: Energy Level, Phase, Prediction, Breakout Quality, Institutional Footprint, Top/Bottom Rejections.

═════════════════════════════════════════════════════════════
📊 READING THE SIGNALS
═════════════════════════════════════════════════════════════

Energy Levels:
• Below 40%: Low energy — breakout unlikely soon
• 40-60%: Moderate energy — zone developing
• 60-80%: High energy — prepare for potential breakout
• Above 80%: Critical energy — breakout imminent

Breakout Quality Score:
• Below 50%: Weak setup — higher false breakout risk
• 50-70%: Moderate setup — proceed with caution
• Above 70%: Strong setup — high probability trade

Direction Confidence:
• Below 55%: Neutral — wait for clearer signals
• 55-70%: Moderate confidence
• Above 70%: High confidence prediction

═════════════════════════════════════════════════════════════
⚙️ RECOMMENDED SETTINGS
═════════════════════════════════════════════════════════════

For Scalping (1-15 min):
Min Bars in Range: 10-15 | ATR Period: 10 | Range ATR Multiplier: 2.0

For Day Trading (15min-1H):
Min Bars in Range: 15-20 | ATR Period: 14 | Range ATR Multiplier: 2.5

For Swing Trading (4H-Daily):
Min Bars in Range: 20-30 | ATR Period: 20 | Range ATR Multiplier: 3.0


═════════════════════════════════════════════════════════════
🔔 ALERTS
═════════════════════════════════════════════════════════════

• New Zone Alert: Triggers when a new consolidation zone is identified
• Imminent Breakout Alert: Triggers when energy reaches critical levels
• Bullish Breakout Alert: Triggers on confirmed bullish breakout
• Bearish Breakout Alert: Triggers on confirmed bearish breakout

═════════════════════════════════════════════════════════════
⚠️ DISCLAIMER
═════════════════════════════════════════════════════════════
This indicator is designed as a technical analysis tool to identify consolidation patterns and anticipate potential breakout directions. No indicator can predict the future with certainty. The displayed SL/TP levels are suggestions based on mathematical calculations, not guarantees.


This indicator is for educational and analytical purposes only. It does not constitute financial, investment, or trading advice. Use it in conjunction with your own strategy and risk management. Neither TradingView nor the developer is liable for any financial decisions or losses.

═════════════════════════════════════════════════════════════
═════════════════════════════════════════════════════════════
مفاعل الطاقة الكامنة | Latent Energy Reactor

🔬 الفلسفة
═════════════════════════════════════════════════════════════

تعمل الأسواق في دورات من الضغط والتمدد. قبل كل حركة سعرية كبيرة، توجد فترة يصل فيها المشترون والبائعون إلى توازن مؤقت — منطقة تجميع حيث تتراكم الطاقة مثل الضغط المتراكم في مفاعل.

صُمم مفاعل الطاقة الكامنة لتحديد هذه المناطق الحرجة، وقياس الطاقة المتراكمة داخلها، والتنبؤ باتجاه الاختراق الحتمي.

يحوّل هذا المؤشر المفهوم المجرد لـ "طاقة السوق" إلى نظام قابل للقياس والعرض البصري يمكن للمتداولين استخدامه لتوقع فرص الاختراق عالية الاحتمالية.

═════════════════════════════════════════════════════════════
🎯 حالات الصندوق الثلاث
═════════════════════════════════════════════════════════════

فهم حالات الصندوق الثلاث ضروري للتفسير الصحيح:

📦 الحالة الأولى: المنطقة النشطة (الصندوق الرمادي)
─────────────────────────────────────────────────────
snapshot

الخصائص البصرية:
• اللون: رمادي/محايد مع تأثير عمق ثلاثي الأبعاد
• يمتد إلى الحافة اليمنى للرسم البياني (إسقاط مستقبلي)
• يحتوي على خطوط الضغط (خطوط أفقية منقطة بالداخل)
• يعرض خط مركز الثقل (خط متقطع يُظهر المركز المرجح بالحجم)
• شريط تقدم الطاقة أسفل الصندوق
• تظهر لوحة المعلومات الفورية على الشاشة

ماذا يعني:
الصندوق الرمادي يمثل منطقة تجميع حَيّة تتشكل حالياً. السعر محتوى داخل الحدود، والطاقة تتراكم بنشاط. هذه هي "مرحلة الانتظار" حيث المفاعل يشحن.

ما يجب مراقبته:
• نسبة الطاقة تصعد نحو المستويات الحرجة (80%+)
• موقع مركز الثقل (النصف العلوي = ميل صعودي، النصف السفلي = ميل هبوطي)
• عدد الرفض العلوي والسفلي في لوحة المعلومات
• تقدم المرحلة (تشكّل ← نمو ← نضج ← إرهاق)

نهج التداول:
لا تتداول داخل الصندوق الرمادي. هذه مرحلة الإعداد. راقب مستويات الطاقة والاتجاه المتوقع، لكن انتظر التأكيد.

📦 الحالة الثانية: صندوق الاختراق الصعودي (الصندوق الأخضر)
─────────────────────────────────────────────────────────────snapshot


الخصائص البصرية:
• اللون: أخضر مع تأثير عمق ثلاثي الأبعاد
• حدود الصندوق ثابتة الآن (لم تعد تمتد لليمين)
• يعرض نص "شراء" أو "BUY" في منتصف الصندوق
• يظهر خط وقف الخسارة أسفل الصندوق (برتقالي)
• تظهر ثلاثة خطوط أهداف فوق الصندوق (فيروزي)
• خط الدخول عند الحد العلوي للصندوق (أبيض متقطع)

ماذا يعني:
الصندوق الأخضر يشير إلى اختراق صعودي مُؤَكَّد. كسر السعر فوق الحد العلوي لمنطقة التجميع، محرراً الطاقة المتراكمة للأعلى.

الحسابات التلقائية المعروضة:
• سعر الدخول: الحد العلوي للصندوق
• وقف الخسارة: الحد السفلي ناقص حاجز ATR
• الهدف 1: الدخول + (المخاطرة × 1.0) — نسبة مكافأة 1:1
• الهدف 2: الدخول + (المخاطرة × 1.5) — نسبة مكافأة 1.5:1
• الهدف 3: الدخول + (المخاطرة × 2.0) — نسبة مكافأة 2:1

نهج التداول:
فكر في صفقات شراء مع مستويات وقف الخسارة والأهداف المعروضة كإرشادات. كلما ارتفع مستوى الطاقة ودرجة جودة الاختراق قبل الكسر، كانت الإشارة أكثر موثوقية.


📦 الحالة الثالثة: صندوق الاختراق الهبوطي (الصندوق الأحمر)
─────────────────────────────────────────────────────────────
snapshot

الخصائص البصرية:
• اللون: أحمر مع تأثير عمق ثلاثي الأبعاد
• حدود الصندوق ثابتة الآن
• يعرض نص "بيع" أو "SELL" في منتصف الصندوق
• يظهر خط وقف الخسارة فوق الصندوق (برتقالي)
• تظهر ثلاثة خطوط أهداف أسفل الصندوق (فيروزي)
• خط الدخول عند الحد السفلي للصندوق (أبيض متقطع)

ماذا يعني:
الصندوق الأحمر يشير إلى اختراق هبوطي مُؤَكَّد. كسر السعر تحت الحد السفلي لمنطقة التجميع، محرراً الطاقة المتراكمة للأسفل.

الحسابات التلقائية المعروضة:
• سعر الدخول: الحد السفلي للصندوق
• وقف الخسارة: الحد العلوي زائد حاجز ATR
• الهدف 1: الدخول - (المخاطرة × 1.0) — نسبة مكافأة 1:1
• الهدف 2: الدخول - (المخاطرة × 1.5) — نسبة مكافأة 1.5:1
• الهدف 3: الدخول - (المخاطرة × 2.0) — نسبة مكافأة 2:1

نهج التداول:
فكر في صفقات بيع مع مستويات وقف الخسارة والأهداف المعروضة كإرشادات. الإعدادات الأقوى لديها طاقة ودرجات جودة أعلى قبل الاختراق.


═════════════════════════════════════════════════════════════
⚛️ نظام حساب الطاقة
═════════════════════════════════════════════════════════════

تُحسب نسبة الطاقة (0-100%) باستخدام أربعة عوامل:

درجة الضغط (حتى 40 نقطة)
تقيس مدى ضيق النطاق نسبة للتقلب الطبيعي (ATR). ضغط أشد = تخزين طاقة أعلى.

درجة الوقت (حتى 35 نقطة)
فترات التجميع الأطول تراكم طاقة أكثر. كل شمعة تضيف للدرجة حتى الحد الأقصى.

مكافأة النضج (حتى 15 نقطة)
المناطق التي تصل لمراحل النضج تحصل على نقاط طاقة إضافية، اعترافاً بأن التجميعات الممتدة غالباً تنتج اختراقات أقوى.

مكافأة الضيق (حتى 10 نقاط)
نقاط إضافية تُمنح عندما يكون ارتفاع النطاق صغيراً استثنائياً نسبة لـ ATR.

═════════════════════════════════════════════════════════════
📊 نظام مركز الثقل
═════════════════════════════════════════════════════════════

كيف يعمل:
مركز الثقل هو متوسط السعر المرجح بالحجم داخل منطقة التجميع. يكشف أين يتركز معظم النشاط التداولي (وبالتالي الاهتمام المؤسسي).

التفسير:
• مركز الثقل في النصف العلوي ← المؤسسات تجمّع ← ميل صعودي
• مركز الثقل في النصف السفلي ← المؤسسات توزّع ← ميل هبوطي
• مركز الثقل في المنتصف ← محايد/غير مؤكد

العرض البصري:
خط متقطع مع رمز ⚖️ يحدد مركز الثقل داخل المناطق النشطة. لون الخط يطابق الميل الاتجاهي.


═════════════════════════════════════════════════════════════
🏦 كشف البصمة المؤسسية
═════════════════════════════════════════════════════════════

ما يقيسه:
يفحص المؤشر الشذوذات الحجمية — شموع حجمها يتجاوز المتوسط بشكل كبير بينما يبقى السعر محتوى داخل المنطقة.

لماذا هذا مهم:
الحجم الكبير بدون حركة سعرية غالباً يشير إلى لاعبين مؤسسيين يبنون مراكز. لا يمكنهم تجميع أو توزيع كميات كبيرة بدون ترك "بصمة" في بيانات الحجم.

تفسير الدرجة:
• أقل من 30%: نشاط تجزئة عادي
• 30-50%: بعض الاهتمام المؤسسي مكتشف
• فوق 50%: بصمة مؤسسية كبيرة (تُحدد بأيقونة 🏦)

═════════════════════════════════════════════════════════════
📈 مراحل النضج
═════════════════════════════════════════════════════════════

⚒ مرحلة التشكّل
المنطقة تم تحديدها للتو. الطاقة منخفضة، والنمط يحتاج وقتاً أكثر للتطور. الاختراقات المبكرة خلال هذه المرحلة لديها معدلات فشل أعلى.

📈 مرحلة النمو
المنطقة تتطور بشكل جيد. الطاقة تتراكم، ونمط التجميع يصبح أكثر تحديداً. راقب زيادة عدد الرفض عند الحدود.

✅ مرحلة النضج
مرحلة التداول المثلى. المنطقة راكمت طاقة كبيرة، البصمات المؤسسية غالباً مرئية، ودرجات جودة الاختراق عادة في أعلى مستوياتها.

⚠ مرحلة الإرهاق
المنطقة استمرت أطول من المدة النموذجية. بينما تبقى الطاقة مرتفعة، قد يفقد النمط قوته التنبؤية.


═════════════════════════════════════════════════════════════
🎨 دليل العناصر البصرية
═════════════════════════════════════════════════════════════

تأثير الصندوق ثلاثي الأبعاد
العرض ثلاثي الأبعاد يخلق عمقاً بصرياً مع وجه علوي ووجه جانبي، مما يجعل الصناديق بارزة بوضوح. قابل للتعديل عبر إعدادات "عمق 3D" و"ارتفاع 3D %".

خطوط الضغط
خطوط أفقية منقطة داخل المناطق النشطة تصور توزيع الضغط الداخلي. الخطوط الأقرب لمركز الثقل أكثر وضوحاً.

شريط تقدم الطاقة
شريط أفقي أسفل كل منطقة يُظهر مستوى الطاقة بصرياً. اللون يتدرج: أخضر (منخفض) ← أصفر (متوسط) ← برتقالي (مرتفع) ← أحمر (حرج).

تحذير الاختراق الوشيك
عندما تصل الطاقة للعتبة الحرجة (افتراضياً 80%)، يظهر تحذير "⚠ كسر وشيك!" فوق المنطقة النشطة.

لوحة المعلومات
جدول فوري يعرض: مستوى الطاقة، المرحلة، التوقع، جودة الاختراق، البصمة المؤسسية، الرفض العلوي/السفلي.

═════════════════════════════════════════════════════════════
📊 قراءة الإشارات
═════════════════════════════════════════════════════════════

مستويات الطاقة:
• أقل من 40%: طاقة منخفضة — الاختراق غير مرجح قريباً
• 40-60%: طاقة متوسطة — المنطقة في طور التطور
• 60-80%: طاقة مرتفعة — استعد لاختراق محتمل
• فوق 80%: طاقة حرجة — الاختراق وشيك

درجة جودة الاختراق:
• أقل من 50%: إعداد ضعيف — خطر اختراق كاذب أعلى
• 50-70%: إعداد متوسط — تقدم بحذر
• فوق 70%: إعداد قوي — صفقة عالية الاحتمالية

ثقة الاتجاه:
• أقل من 55%: محايد — انتظر إشارات أوضح
• 55-70%: ثقة متوسطة
• فوق 70%: توقع عالي الثقة

═════════════════════════════════════════════════════════════
⚙️ الإعدادات الموصى بها
═════════════════════════════════════════════════════════════

للمضاربة السريعة (1-15 دقيقة):
الحد الأدنى للشموع: 10-15 | فترة ATR: 10 | مضاعف ATR: 2.0

للتداول اليومي (15 دقيقة - ساعة):
الحد الأدنى للشموع: 15-20 | فترة ATR: 14 | مضاعف ATR: 2.5

للتداول المتأرجح (4 ساعات - يومي):
الحد الأدنى للشموع: 20-30 | فترة ATR: 20 | مضاعف ATR: 3.0

═════════════════════════════════════════════════════════════
🔔 التنبيهات
═════════════════════════════════════════════════════════════
• تنبيه منطقة جديدة: يُفعّل عند تشكّل منطقة تجميع جديدة
• تنبيه اختراق وشيك: يُفعّل عند وصول الطاقة لمستويات حرجة
• تنبيه اختراق صعودي: يُفعّل عند تأكيد كسر صعودي
• تنبيه اختراق هبوطي: يُفعّل عند تأكيد كسر هبوطي

═════════════════════════════════════════════════════════════
⚠️ إخلاء المسؤولية
═════════════════════════════════════════════════════════════

هذا المؤشر مصمم كأداة تحليل فني لتحديد أنماط التجميع وتوقع اتجاهات الاختراق المحتملة. لا يمكن لأي مؤشر التنبؤ بالمستقبل بيقين. مستويات وقف الخسارة والأهداف المعروضة هي اقتراحات مبنية على حسابات رياضية، وليست ضمانات.

هذا المؤشر لأغراض تعليمية وتحليلية فقط. لا يُمثل نصيحة مالية أو استثمارية أو تداولية. استخدمه بالتزامن مع استراتيجيتك الخاصة وإدارة المخاطر. لا يتحمل TradingView ولا المطور مسؤولية أي قرارات مالية أو خسائر.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.