Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/scripts/validate_portfolio.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from pathlib import Path
import re
from urllib.parse import unquote

ROOT = Path(__file__).resolve().parents[2]
errors: list[str] = []

for markdown in ROOT.rglob("*.md"):
text = markdown.read_text(encoding="utf-8", errors="replace")
for target in re.findall(r"!?\[[^\]]*\]\(([^)]+)\)", text):
target = target.strip().split(" ", 1)[0].strip("<>")
if not target or target.startswith(("http://", "https://", "mailto:", "#")):
continue
local = unquote(target.split("#", 1)[0])
if local and not (markdown.parent / local).resolve().exists():
errors.append(f"Broken link in {markdown.relative_to(ROOT)}: {target}")

pine_files = list(ROOT.rglob("*.pine"))
for pine in pine_files:
text = pine.read_text(encoding="utf-8", errors="replace")
if not re.search(r"^//@version=\d+", text, re.MULTILINE):
errors.append(f"Missing Pine version: {pine.relative_to(ROOT)}")
if not re.search(r"\b(indicator|strategy|library)\s*\(", text):
errors.append(f"Missing Pine declaration: {pine.relative_to(ROOT)}")

if errors:
print("\n".join(errors))
raise SystemExit(1)

print(f"Validated {len(pine_files)} Pine files and local Markdown links.")
15 changes: 15 additions & 0 deletions .github/workflows/portfolio-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Portfolio quality

on:
push:
pull_request:

jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: python .github/scripts/validate_portfolio.py
15 changes: 15 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Copyright (c) 2026 Alaa Hamza (Alaamo7)

All rights reserved.

This repository and its source code are made publicly available solely for
portfolio review, personal study, and educational reference.

No permission is granted to copy, modify, redistribute, sublicense, resell,
publish as another product, or use this work commercially without prior written
permission from the copyright owner.

Trading indicators, strategies, reports, and screenshots are provided as
research software only. They do not constitute financial or investment advice,
and no warranty of performance, accuracy, merchantability, or fitness for a
particular purpose is provided.
149 changes: 49 additions & 100 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,127 +1,76 @@
# EGX Pine Script Technical Analysis Toolkit
# EGX Pine Script Indicators & Strategies

A structured portfolio repository for TradingView Pine Script indicators and backtesting strategy prototypes focused on EGX-style technical analysis.
Verified TradingView research tools for the Egyptian Exchange (EGX), built with Pine Script and documented with chart evidence, strategy reports, and reproducible test notes.

This project demonstrates practical Pine Script development across trend analysis, momentum, liquidity, smart-money concepts, trap detection, price matrices, risk dashboards, and long-only backtesting workflows.
> **Current validation:** 120 exported scripts tested on TradingView · **120 passed** after repairing and re-testing the five original compile failures on 2026-08-22.

## Portfolio Positioning
![Smart EGX Pro institutional dashboard on TradingView](tradingview-export/2026-08-21/indicators/076-smart-egx-pro-v2-3-institutional-legend-dashboard.tests/tradingview-chart.png)

This repository is intended to showcase the ability to design, organize, document, and maintain technical-analysis tools for:
## What this repository demonstrates

- TradingView indicator development.
- EGX-focused technical-analysis workflows.
- Brokerage or fintech technical-research tooling prototypes.
- AI-ready technical-analysis reporting and automation pipelines.
- Pine Script v5/v6 indicator and strategy engineering.
- EGX-oriented trend, momentum, liquidity, pivot, smart-money, trap, and risk dashboards.
- Real TradingView compile and visual checks with a report beside each tested script.
- Honest backtest documentation, including both positive and negative outcomes.
- Repainting-aware design: confirmed pivots, prior-period data, and explicit live-bar caveats.

The current Pine Script layer is primarily rule-based. AI-assisted reporting and automation are documented as a future roadmap, not as a current machine-learning claim.
## Verification evidence

## Current Toolkit Summary
The complete test export is under [`tradingview-export/2026-08-21`](tradingview-export/2026-08-21/README.md). Each tested script has a neighboring `.tests` directory containing its TradingView screenshot and test report.

| Type | Count | Notes |
|---|---:|---|
| Active / Beta indicators | 9 | Usable for chart review and further testing. |
| Experimental indicators | 3 | Research-oriented tools requiring visual validation. |
| Backtest strategies | 2 | EGX-friendly long-only strategy prototypes. |
| Legacy / Archive scripts | 3 | Preserved for reference, not primary production use. |
| Evidence | Result |
|---|---|
| Exported Pine scripts tested | 120 |
| Passed after the repair and re-test | 120 |
| Original compile failures repaired | 5 |
| Chart and report screenshots | 127 |
| Test documentation files | 120+ |

![EMA RSI strategy report on TradingView](tradingview-export/2026-08-21/strategies/099-ema-rsi-tp-sl.tests/tradingview-strategy-report.png)

See the full index:
## Selected case studies

```text
/docs/scripts-index.md
```
- [Ultimate Scalping Pro v2.6 — positive backtest with limitations](docs/case-studies/ultimate-scalping-pro-v2-6.md)
- [Integrated Swing Strategy — negative backtest and lessons learned](docs/case-studies/integrated-swing-strategy.md)
- [Reusable case-study template](docs/case-studies/CASE-STUDY-TEMPLATE.md)

## Indicator Categories
## Toolkit map

| Need | Suggested Tools |
| Need | Representative tools |
|---|---|
| Trend review | Smart EGX Trend Engine, AboSamra Pro, EGX Pro Price Matrix |
| Momentum / correction review | Smart Correction Signals Pro |
| Liquidity and smart-money context | Smart EGX Liquidity S/R Dashboard, Smart EGX Smart Money Core, AI Dynamic Liquidity Engine |
| Trend and market regime | Smart EGX Trend Engine, AboSamra Pro |
| Momentum and corrections | Smart Correction Signals Pro |
| Liquidity and smart money | Smart EGX Liquidity S/R Dashboard, Smart Money Core |
| Trap detection | MM Trap Pro |
| Pivot and matrix levels | EGX Pro Price Matrix, EGX Pro Matrix MTF Filter |
| Pivot and price matrices | EGX Pro Price Matrix, EGX Pro Matrix MTF Filter |
| Risk sizing | EGX Pro Matrix Risk Manager |
| Multi-module dashboard review | Expert EGX Analyst Pro, EGX Smart Balance Matrix Pro |
| Strategy research | Scalping EMA+RSI Strategy, Reverse SMA+RSI Strategy |

## Repository Structure

| Area | Purpose |
|---|---|
| `indicators/` | Active, beta, and experimental Pine indicators. |
| `strategies/` | Backtest strategies and trading logic prototypes. |
| `archive/` | Legacy, deprecated, incomplete, or reference-only scripts. |
| `docs/` | Repository documentation, script index, roadmap, disclaimers, and case-study templates. |
| `assets/` | Screenshots, diagrams, and portfolio visuals. |

## Quality Principles

The cleanup process focuses on:

- Small reviewable pull requests.
- Clear script status labels: Beta, Experimental, Legacy, Incomplete.
- Avoiding stale large PR merges.
- Documenting each script with a README where appropriate.
- Reducing object clutter with managed labels, boxes, and arrays.
- Avoiding future-looking higher-timeframe logic by using `barmerge.lookahead_off` in cleaned scripts.
- Keeping EGX retail assumptions in mind, especially long-only backtesting.

## AI-Assisted Roadmap

The repository is designed to become AI-ready through future layers:

1. Pine Script signal and dashboard layer.
2. Data export and backtest validation layer.
3. Python-based report generation.
4. Telegram/email analysis summaries.
5. AI-assisted explanation layer for structured technical-analysis reports.

Read more:

```text
/docs/AI-ROADMAP.md
```

## Case Studies

A reusable template is available for documenting real chart reviews and signal outcomes:

```text
/docs/case-studies/CASE-STUDY-TEMPLATE.md
```

Suggested case-study examples:

- Smart EGX Liquidity S/R Dashboard on EGX30 daily.
- MM Trap Pro on a 15-minute EGX stock chart.
- EGX Pro Price Matrix on a swing-trading setup.
- Reverse SMA+RSI Strategy backtest on selected EGX symbols.
| Multi-module dashboards | Expert EGX Analyst Pro, EGX Smart Balance Matrix Pro |
| Strategy research | EMA/RSI TP-SL, Ultimate Scalping, Integrated Swing |

## Screenshot Plan
Browse the curated scripts in [`indicators`](indicators), [`strategies`](strategies), and the [script index](docs/scripts-index.md). Historical and incomplete work is isolated under [`archive`](archive).

Screenshots should be stored under:
## Engineering principles

```text
assets/screenshots/
```
- Confirm historical signals before presenting them as stable.
- Use `barmerge.lookahead_off` for cleaned higher-timeframe logic.
- Reuse labels, tables, boxes, and arrays to avoid chart-object exhaustion.
- Separate compile/visual validation from profitability claims.
- Document symbol, timeframe, date, settings, and limitations beside every result.
- Treat all tools as research software, never as guaranteed signals.

Recommended naming style:
## AI-assisted roadmap

```text
assets/screenshots/smart-egx-trend-engine-egx30-daily.png
assets/screenshots/mm-trap-pro-btfh-15m.png
assets/screenshots/egx-pro-price-matrix-masr-daily.png
```
The current Pine layer is rule-based. Planned AI work is limited to explainability and reporting: structured signal export, Python validation, automated summaries, and human-readable technical-analysis reports. See the [AI roadmap](docs/AI-ROADMAP.md).

## Important Disclaimer
## Related repositories

This repository is for education, research, and portfolio demonstration only. It does not provide financial advice, investment recommendations, brokerage advice, or guaranteed trading signals.
- [Curated five-indicator portfolio](https://github.com/Alaamo7/pine-script-portfolio)
- [Arabic-friendly Pine Script v6 course](https://github.com/Alaamo7/pine-script-v6-course)

Read the full disclaimer:
## License and risk notice

```text
/docs/DISCLAIMER.md
```
Source is published for portfolio viewing and education. Redistribution, resale, modification, or commercial use requires written permission; see [LICENSE](LICENSE). Nothing here is financial advice, and a successful compile or historical backtest does not predict future performance. See the full [disclaimer](docs/DISCLAIMER.md).

## Author

Developed and maintained by Alaa Hamza as a Pine Script and EGX technical-analysis tools portfolio.
Developed and maintained by **Alaa Hamza** — Pine Script and TradingView developer focused on EGX technical-analysis tooling.
34 changes: 34 additions & 0 deletions docs/case-studies/integrated-swing-strategy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Case Study: Integrated Swing Strategy

## Test context

| Field | Value |
|---|---|
| Platform | TradingView Strategy Tester |
| Symbol | EGX:RMDA |
| Timeframe | 4 hours |
| Test date | 2026-08-21 |
| Direction | Long-only research setup |

## Recorded result

| Metric | Result |
|---|---:|
| Total P&L | -7,189.45 EGP (-0.72%) |
| Maximum drawdown | 24,027.10 EGP (2.39%) |
| Profitable trades | 38.52% (47 of 122) |
| Profit factor | 0.884 |

## Interpretation

This configuration did not demonstrate an edge in the sampled market. A profit factor below 1.0 and a low win rate make the unmodified setup unsuitable for practical use. Publishing the negative result prevents compile success from being confused with trading performance and provides a concrete baseline for improvement.

## Lessons and next steps

1. Review regime filters so entries are reduced during sideways markets.
2. Inspect exit timing and the balance between average win and average loss.
3. Add realistic costs before any optimization.
4. Validate changes out of sample and across multiple EGX symbols.
5. Reject parameter combinations that improve one period but degrade broadly.

This case study is a transparent research record, not financial advice.
34 changes: 34 additions & 0 deletions docs/case-studies/ultimate-scalping-pro-v2-6.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Case Study: Ultimate Scalping Pro v2.6

## Test context

| Field | Value |
|---|---|
| Platform | TradingView Strategy Tester |
| Symbol | EGX:RMDA |
| Timeframe | 15 minutes |
| Test date | 2026-08-21 |
| Direction | Long-only research setup |

## Recorded result

| Metric | Result |
|---|---:|
| Total P&L | +7,446.33 EGP (+0.74%) |
| Maximum drawdown | 7,016.84 EGP (0.70%) |
| Profitable trades | 58.06% (18 of 31) |
| Profit factor | 1.585 |

## Interpretation

The sampled run was profitable and kept its measured drawdown below one percent. The result is encouraging as a software-validation example, but 31 trades on one symbol and timeframe are not enough to claim robustness. Commission, slippage, liquidity, order-fill assumptions, and different market regimes can materially change the outcome.

## Next validation steps

1. Repeat the test on a broader set of liquid EGX symbols.
2. Use out-of-sample dates and multiple volatility regimes.
3. Add realistic commission and slippage assumptions.
4. Compare bar-close execution with intrabar behavior.
5. Record parameter sensitivity instead of selecting only the best settings.

This case study documents one historical test; it is not a forecast or trading recommendation.
4 changes: 2 additions & 2 deletions tradingview-export/2026-08-21/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ These files preserve the source as copied from TradingView. They were not normal
## TradingView validation — 2026-08-22

- All 120 scripts were tested individually on `EGX:RMDA` after removing the default indicator and clearing the chart between tests.
- 115 scripts loaded and rendered successfully.
- 5 scripts produced documented Pine compilation errors.
- All 120 scripts loaded and rendered successfully after a repair and re-test pass.
- Five original compilation failures (036, 045, 047, 049, and 050) were corrected, migrated or confirmed on Pine v6, and re-tested on 2026-08-22.
- Strategy Tester reports and screenshots were captured for all 7 strategies.
- Every `.pine` file now has an adjacent `.tests` folder containing `TEST-REPORT.md` and its TradingView screenshot(s).
- [Open the complete test index](test-results/2026-08-22/README.md).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,43 +93,13 @@ alertcondition(ta.crossover(ema_short1, ema_short2), title="تقاطع EMA لل
alertcondition(ta.crossunder(ema_short1, ema_short2), title="تقاطع EMA للمضارب (بيع)", message="EMA 9 crossed below EMA 21")

// ========== دليل الألوان والمؤشرات ========== //
legendText = "دليل الألوان والمؤشرات:\n"+
"EMA 9: سماوي - اتجاه سريع\n"+
"EMA 21: أزرق - اتجاه قصير\n"+
"EMA 100: بنفسجي - اتجاه متوسط\n"+
"EMA 200: أحمر - اتجاه رئيسي\n"+
"SMA 50: برتقالي - متوسط\n"+
"VWAP: أصفر - متوسط مرجح بالحجم\n"+
"Bollinger Bands: رمادي - تقلب السعر\n"+
"MACD: أخضر - زخم\n"+
"MACD Signal: أحمر - خط الإشارة\n"+
"MACD Histogram: رمادي - أعمدة الزخم\n"+
"Ichimoku Conv.: أخضر فاتح شفاف\n"+
"Ichimoku Base: أحمر فاتح شفاف\n"+
"Senkou A: أخضر شفاف\n"+
"Senkou B: أحمر شفاف\n"+
"سحابة صاعدة: أخضر فاتح جدًا\n"+
"سحابة هابطة: أحمر فاتح جدًا\n"+
"RSI > 70: أحمر - تشبع شراء\n"+
"RSI < 30: أخضر - تشبع بيع\n"+
"RSI عادي: رمادي\n"+
"منطقة طلب: مثلث أخضر\n"+
"منطقة عرض: مثلث أحمر"
string legendText = "دليل الألوان والمؤشرات:\nEMA 9: سماوي - اتجاه سريع\nEMA 21: أزرق - اتجاه قصير\nEMA 100: بنفسجي - اتجاه متوسط\nEMA 200: أحمر - اتجاه رئيسي\nSMA 50: برتقالي - متوسط\nVWAP: أصفر - متوسط مرجح بالحجم\nBollinger Bands: رمادي - تقلب السعر\nMACD: أخضر - زخم\nMACD Signal: أحمر - خط الإشارة\nMACD Histogram: رمادي - أعمدة الزخم\nIchimoku Conv.: أخضر فاتح شفاف\nIchimoku Base: أحمر فاتح شفاف\nSenkou A: أخضر شفاف\nSenkou B: أحمر شفاف\nسحابة صاعدة: أخضر فاتح جدًا\nسحابة هابطة: أحمر فاتح جدًا\nRSI > 70: أحمر - تشبع شراء\nRSI < 30: أخضر - تشبع بيع\nRSI عادي: رمادي\nمنطقة طلب: مثلث أخضر\nمنطقة عرض: مثلث أحمر"

// رسم الدليل أعلى الشارت (label)
var legendLabel = na
if bar_index == ta.highest(bar_index, 100)
legendLabel := label.new(
x = bar_index,
y = high,
text = legendText,
xloc = xloc.bar_index,
yloc = yloc.price,
color = color.new(color.white, 92),
style = label.style_label_down,
textcolor = color.black,
size = size.normal
)
if not na(legendLabel)
label.set_x(legendLabel, bar_index)
label.set_y(legendLabel, high)
var label legendLabel = na
if barstate.islast
if na(legendLabel)
legendLabel := label.new(x=bar_index, y=high, text=legendText, xloc=xloc.bar_index, yloc=yloc.price, color=color.new(color.white, 92), style=label.style_label_down, textcolor=color.black, size=size.normal)
else
label.set_xy(legendLabel, bar_index, high)
label.set_text(legendLabel, legendText)
Loading
Loading