From f48570f64c2dff107dcd5f2962e335690e8b5be2 Mon Sep 17 00:00:00 2001 From: FxPouya <59786270+FxPouya@users.noreply.github.com> Date: Fri, 26 Dec 2025 17:20:46 +0330 Subject: [PATCH] Add files via upload --- USER_MANUAL.md | 171 ++++++++++++++++- css/style.css | 394 +++++++++++++++++++++++++++++++++++++++- index.html | 28 ++- js/main.js | 69 +++++++ js/monte-carlo-modal.js | 338 ++++++++++++++++++++++++++++++++++ js/monte-carlo.js | 275 ++++++++++++++++++++++++++++ manual.html | 159 ++++++++++++++++ 7 files changed, 1426 insertions(+), 8 deletions(-) create mode 100644 js/monte-carlo-modal.js create mode 100644 js/monte-carlo.js diff --git a/USER_MANUAL.md b/USER_MANUAL.md index 8382c9f..721ca6e 100644 --- a/USER_MANUAL.md +++ b/USER_MANUAL.md @@ -11,11 +11,12 @@ 3. [Exporting Data from MT4/MT5](#exporting-data) 4. [Uploading Data](#uploading-data) 5. [Configuring Strategy Generation](#configuration) -6. [Generating Strategies](#generation) -7. [Viewing Results](#results) -8. [Downloading Strategies](#downloading) -9. [Troubleshooting](#troubleshooting) -10. [Contact Support](#support) +6. [Understanding Monte Carlo Results](#understanding-monte-carlo-results) +7. [Generating Strategies](#generation) +8. [Viewing Results](#results) +9. [Downloading Strategies](#downloading) +10. [Troubleshooting](#troubleshooting) +11. [Contact Support](#support) --- @@ -154,8 +155,161 @@ Time,Open,High,Low,Close,Tick_Volume,Spread,Real_Volume - Min Profit Factor: 2.0 - Min Win Rate: 55% +### Monte Carlo Simulation + +**What is Monte Carlo Simulation?** + +Monte Carlo simulation is a powerful risk analysis tool that tests strategy robustness by randomly shuffling the order of trades thousands of times. This reveals whether your strategy's performance is due to genuine edge or just lucky trade sequencing. + +**Why Use Monte Carlo?** + +- **Risk Assessment**: Understand the range of possible outcomes +- **Robustness Testing**: Verify strategy works under different conditions +- **Confidence Intervals**: Know the probability of different results +- **Risk of Ruin**: Calculate probability of catastrophic losses + +**Settings:** + +| Parameter | Default | Range | Description | +|-----------|---------|-------|-------------| +| **Enable Monte Carlo** | Off | On/Off | Activate Monte Carlo analysis | +| **Iterations** | 1,000 | 100-10,000 | Number of random shuffles | +| **Risk of Ruin Threshold** | 20% | 10-50% | Loss threshold for RoR calculation | + +**Recommended Settings:** + +- **Quick Analysis**: 1,000 iterations (1-2 seconds) +- **Standard Analysis**: 5,000 iterations (3-4 seconds) +- **Thorough Analysis**: 10,000 iterations (6-8 seconds) + +**Requirements:** + +- Minimum 20 trades for meaningful results +- More trades = more accurate analysis +- Enable before generating strategies + +**How to Use:** + +1. **Enable Monte Carlo** in configuration section +2. **Set iterations** (1,000 recommended for start) +3. **Generate strategies** as normal +4. **Click "🎲 MC" button** on any strategy card +5. **View professional modal** with: + - Equity distribution histogram + - Risk assessment + - Percentile analysis + - Confidence intervals + --- +## 📊 Understanding Monte Carlo Results + +### Risk Assessment Banner + +The modal displays a color-coded risk assessment: + +- **✅ LOW RISK (< 5% RoR)**: Excellent robustness, safe to trade +- **⚠️ MODERATE RISK (5-15% RoR)**: Acceptable, monitor closely +- **❌ HIGH RISK (> 15% RoR)**: High variance, reduce position size + +### Key Metrics Explained + +**Expected Return** +- Average outcome across all simulations +- More reliable than single backtest result +- Positive value indicates profitable strategy + +**Risk of Ruin (RoR)** +- Probability of losing threshold % of capital +- Lower is better (< 5% is excellent) +- Accounts for worst-case scenarios + +**Standard Deviation** +- Measure of result variability +- Lower = more consistent +- Higher = more unpredictable + +**Percentiles** + +| Percentile | Meaning | Use Case | +|------------|---------|----------| +| **5th** | Worst 5% of outcomes | Downside risk assessment | +| **25th** | Below average | Pessimistic scenario | +| **50th (Median)** | Typical outcome | Most likely result | +| **75th** | Above average | Optimistic scenario | +| **95th** | Best 5% of outcomes | Upside potential | + +**Confidence Intervals** + +- **90% Range**: 90% of outcomes fall within this range +- **50% Range**: 50% of outcomes fall within this range +- Narrower range = more predictable strategy + +### Equity Distribution Histogram + +The histogram shows the distribution of final equity across all simulations: + +**Color Coding:** +- **Red bars**: Worst 5% of outcomes (below 5th percentile) +- **Orange bars**: Below average (5th-25th percentile) +- **Green bars**: Typical range (25th-75th percentile) +- **Teal bars**: Best outcomes (above 75th percentile) + +**What to Look For:** +- **Normal distribution**: Bell curve shape is ideal +- **Skewed right**: More upside potential +- **Skewed left**: More downside risk +- **Wide spread**: High variability (risky) +- **Narrow spread**: Consistent results (safer) + +### Interpreting Results + +**Excellent Strategy:** +- Risk of Ruin < 5% +- 5th percentile is positive +- Narrow confidence intervals +- Normal distribution shape + +**Good Strategy:** +- Risk of Ruin 5-10% +- 5th percentile near breakeven +- Moderate confidence intervals +- Slight positive skew + +**Risky Strategy:** +- Risk of Ruin > 15% +- 5th percentile is negative +- Wide confidence intervals +- High standard deviation + +**Warning Signs:** +- Very wide distribution +- Negative 25th percentile +- High risk of ruin (> 20%) +- Bimodal distribution (two peaks) + +### Best Practices + +**Before Trading:** +1. Run Monte Carlo on all strategies +2. Only trade strategies with RoR < 10% +3. Check 5th percentile is acceptable +4. Verify normal distribution + +**Position Sizing:** +- Low Risk (< 5% RoR): Standard position size +- Moderate Risk (5-15% RoR): Reduce position by 50% +- High Risk (> 15% RoR): Avoid or use micro lots + +**Ongoing Monitoring:** +- Re-run Monte Carlo monthly +- Compare live results to MC predictions +- Stop trading if results fall below 5th percentile +- Adjust position size based on actual variance + +--- + + ## 🎯 Generating Strategies ### Step 1: Start Generation @@ -342,6 +496,11 @@ Click "View Details" to see: - Community support - Updates and announcements +**Telegram Group**: https://t.me/FxMathQuant +- Community discussions +- Share strategies and results +- Get help from other users + **Website**: https://fxmath.com - Documentation - Video tutorials @@ -438,6 +597,6 @@ Please provide: **Happy Trading! 🎯** -For support: fxmathsolution@gmail.com | https://t.me/FxMath +For support: fxmathsolution@gmail.com | https://t.me/FxMath | https://t.me/FxMathQuant © 2025 FxMath Solution. All rights reserved. diff --git a/css/style.css b/css/style.css index 64778bc..91b56d8 100644 --- a/css/style.css +++ b/css/style.css @@ -985,4 +985,396 @@ tbody tr:hover { flex-direction: column; align-items: stretch; } -} \ No newline at end of file +} +/* =================================== + Monte Carlo Simulation Styles + =================================== */ + +/* Monte Carlo Summary Cards */ +.mc-summary { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); + gap: 20px; + margin-bottom: 30px; +} + +.mc-stat-card { + background: var(--card-bg); + padding: 20px; + border-radius: 12px; + text-align: center; + border: 1px solid var(--border-color); + transition: transform 0.2s, box-shadow 0.2s; +} + +.mc-stat-card:hover { + transform: translateY(-2px); + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); +} + +.mc-stat-card h4 { + font-size: 14px; + color: var(--text-secondary); + margin-bottom: 10px; + text-transform: uppercase; + letter-spacing: 0.5px; +} + +.mc-value { + font-size: 2em; + font-weight: 700; + color: var(--accent-color); + margin: 0; +} + +/* Risk level colors */ +.mc-value.good { color: var(--accent-success); } +.mc-value.warning { color: var(--accent-warning); } +.mc-value.bad { color: var(--accent-danger); } + +/* Monte Carlo Histogram */ +#mc-histogram { + width: 100%; + height: 300px; + margin: 20px 0; + border-radius: 8px; +} + +/* Monte Carlo Statistics Table */ +.mc-stats-table { + width: 100%; + border-collapse: collapse; + margin-top: 20px; + background: var(--card-bg); + border-radius: 8px; + overflow: hidden; +} + +.mc-stats-table th, +.mc-stats-table td { + padding: 12px 16px; + text-align: left; + border-bottom: 1px solid var(--border-color); +} + +.mc-stats-table th { + background: rgba(102, 126, 234, 0.1); + color: var(--text-primary); + font-weight: 600; + font-size: 13px; + text-transform: uppercase; + letter-spacing: 0.5px; +} + +.mc-stats-table td { + font-size: 14px; + color: var(--text-secondary); +} + +.mc-stats-table tr:last-child td { border-bottom: none; } +.mc-stats-table tr:hover { background: rgba(102, 126, 234, 0.05); } + +/* Monte Carlo Tab Content */ +#montecarlo-tab { padding: 20px; } + +/* Monte Carlo Settings */ +#montecarlo-settings { margin-top: 15px; } +#montecarlo-settings label { + display: block; + margin-bottom: 8px; + font-weight: 500; +} + +#montecarlo-settings input[type="range"] { + width: 100%; + margin-bottom: 15px; +} + +#montecarlo-settings small { + display: block; + margin-top: -10px; + margin-bottom: 15px; + color: var(--text-secondary); + font-size: 12px; +} + +/* Responsive Monte Carlo */ +@media (max-width: 768px) { + .mc-summary { grid-template-columns: 1fr; } + .mc-value { font-size: 1.5em; } + #mc-histogram { height: 250px; } +} + +/* Monte Carlo Button Style */ +.btn-info { + background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); + color: white; + border: none; + padding: 10px 16px; + border-radius: 6px; + cursor: pointer; + font-weight: 600; + font-size: 14px; + transition: all 0.3s ease; + box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3); +} + +.btn-info:hover { + transform: translateY(-2px); + box-shadow: 0 4px 8px rgba(102, 126, 234, 0.4); +} + +.btn-info:active { + transform: translateY(0); +} + +/* ===== MONTE CARLO MODAL STYLES ===== */ + +/* Monte Carlo Strategy Info */ +.mc-strategy-info { + text-align: center; + margin-bottom: 20px; + padding-bottom: 20px; + border-bottom: 1px solid var(--border-color); +} + +.mc-strategy-info h3 { + margin: 0 0 5px 0; + color: var(--text-primary); +} + +.mc-strategy-info p { + margin: 0; + color: var(--text-secondary); +} + +/* Risk Assessment Banner */ +.mc-risk-banner { + display: flex; + align-items: center; + gap: 20px; + padding: 20px; + border-radius: 12px; + margin-bottom: 30px; + border: 2px solid; +} + +.mc-risk-banner.mc-good { + background: rgba(72, 187, 120, 0.1); + border-color: var(--accent-success); +} + +.mc-risk-banner.mc-warning { + background: rgba(237, 137, 54, 0.1); + border-color: var(--accent-warning); +} + +.mc-risk-banner.mc-bad { + background: rgba(245, 101, 101, 0.1); + border-color: var(--accent-danger); +} + +.mc-risk-icon { + font-size: 48px; + line-height: 1; +} + +.mc-risk-content h3 { + margin: 0 0 10px 0; + font-size: 20px; +} + +.mc-risk-content p { + margin: 0; + color: var(--text-secondary); + line-height: 1.6; +} + +/* Summary Statistics Cards */ +.mc-summary { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); + gap: 20px; + margin-bottom: 30px; +} + +.mc-stat-card { + background: var(--card-bg); + padding: 20px; + border-radius: 12px; + text-align: center; + border: 1px solid var(--border-color); + transition: transform 0.2s, box-shadow 0.2s; +} + +.mc-stat-card:hover { + transform: translateY(-2px); + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); +} + +.mc-label { + font-size: 12px; + text-transform: uppercase; + letter-spacing: 0.5px; + color: var(--text-secondary); + margin-bottom: 8px; +} + +.mc-value { + font-size: 28px; + font-weight: 700; + margin-bottom: 5px; + color: var(--text-primary); +} + +.mc-value.positive { + color: var(--accent-success); +} + +.mc-value.negative { + color: var(--accent-danger); +} + +.mc-value.mc-good { + color: var(--accent-success); +} + +.mc-value.mc-warning { + color: var(--accent-warning); +} + +.mc-value.mc-bad { + color: var(--accent-danger); +} + +.mc-sublabel { + font-size: 11px; + color: var(--text-muted); +} + +/* Percentile Table */ +.mc-percentiles { + margin: 30px 0; +} + +.mc-percentiles h3 { + margin-bottom: 15px; +} + +.mc-percentile-table { + width: 100%; + border-collapse: collapse; + background: var(--card-bg); + border-radius: 8px; + overflow: hidden; +} + +.mc-percentile-table thead { + background: rgba(102, 126, 234, 0.1); +} + +.mc-percentile-table th, +.mc-percentile-table td { + padding: 12px 15px; + text-align: left; + border-bottom: 1px solid var(--border-color); +} + +.mc-percentile-table th { + font-weight: 600; + color: var(--text-primary); + font-size: 13px; + text-transform: uppercase; + letter-spacing: 0.5px; +} + +.mc-percentile-table td { + color: var(--text-secondary); +} + +.mc-percentile-table tr.highlight-row { + background: rgba(102, 126, 234, 0.05); +} + +.mc-percentile-table tr:last-child td { + border-bottom: none; +} + +/* Confidence Intervals */ +.mc-confidence { + margin: 30px 0; +} + +.mc-confidence h3 { + margin-bottom: 15px; +} + +.mc-confidence-grid { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); + gap: 20px; +} + +.mc-confidence-card { + background: var(--card-bg); + padding: 20px; + border-radius: 12px; + border: 1px solid var(--border-color); + text-align: center; +} + +.mc-confidence-label { + font-size: 13px; + text-transform: uppercase; + letter-spacing: 0.5px; + color: var(--text-secondary); + margin-bottom: 10px; +} + +.mc-confidence-value { + font-size: 20px; + font-weight: 700; + color: var(--accent-primary); + margin-bottom: 8px; +} + +.mc-confidence-sublabel { + font-size: 12px; + color: var(--text-muted); +} + +/* Explanation Box */ +.mc-explanation { + background: rgba(102, 126, 234, 0.05); + border-left: 4px solid var(--accent-primary); + padding: 20px; + border-radius: 8px; + margin-top: 30px; +} + +.mc-explanation h4 { + margin: 0 0 10px 0; + color: var(--text-primary); +} + +.mc-explanation p { + margin: 0; + color: var(--text-secondary); + line-height: 1.6; +} + +/* Responsive Design */ +@media (max-width: 768px) { + .mc-summary { + grid-template-columns: repeat(2, 1fr); + } + + .mc-confidence-grid { + grid-template-columns: 1fr; + } + + .mc-risk-banner { + flex-direction: column; + text-align: center; + } +} diff --git a/index.html b/index.html index 32d8226..cc33407 100644 --- a/index.html +++ b/index.html @@ -234,6 +234,30 @@ Higher ratio = more data for training, less for validation + + +