╔══════════════════════════════════════════════════════════════╗
║ AI US500 PRO ║
║ Hybrid Trend / Mean-Reversion cBot ║
║ Multi-AI • Multi-Timeframe ║
╚══════════════════════════════════════════════════════════════╝
🧠 **AI US500 PRO** is a professional cBot for cTrader specifically designed for the S&P 500 index (US500). It combines multi-timeframe technical analysis with artificial intelligence to filter every trade before execution.
The bot operates across **3 simultaneous timeframes** (H4 → H1 → M15), automatically detects the market regime (trending or ranging) and applies the most suitable strategy: trend-following when the market has direction, mean-reversion when it's moving sideways. Every generated signal can be validated in real time by an AI model of your choice from **13 supported providers**.
Runs with `AccessRights.None` — no special permissions required, uses cTrader's native HTTP APIs.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📐 **STRATEGY ARCHITECTURE**
The bot follows a cascading decision flow:
```
H4 (EMA 200) → Determines long-term directional bias (bullish / bearish / neutral)
↓
H1 (EMA 50 + RSI 14) → Confirms direction and evaluates overextension
↓
M15 (EMA 21/50 + Stoch + BB + ADX + ATR) → Generates the entry signal
↓
AI (Claude / GPT / Gemini / ...) → Filters the signal with a confidence score
↓
Execution → Volume calculation, dynamic SL/TP, trailing stop
```
⚡ **Regime Detection (ADX)**
— ADX ≥ threshold → trending market → trend-following strategy
— ADX < threshold → ranging market → mean-reversion strategy
The switch is fully automatic, bar by bar.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📊 **TREND-FOLLOWING STRATEGY**
LONG entry conditions:
✅ H4: price above EMA 200 (bullish bias)
✅ H1: price above EMA 50 + RSI > 50
✅ M15: EMA 21 crosses above EMA 50 (bullish crossover)
✅ M15: Stochastic K crosses above D, with K < 65 (not overbought)
SHORT entry conditions: mirrored and inverted.
📊 **MEAN-REVERSION STRATEGY**
LONG entry conditions:
✅ ADX below threshold (ranging market)
✅ M15: price touches or breaks the lower Bollinger Band
✅ M15: Stochastic K < 20 (oversold)
✅ H1: RSI < 35 (bearish overextension)
SHORT entry conditions: mirrored and inverted.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🤖 **AI INTEGRATION — 13 PROVIDERS**
When the bot generates a valid technical signal, before executing it sends the AI a complete data packet containing:
— All multi-timeframe indicators
— The last N M15 candles (OHLCV)
— Proposed direction and active strategy
— Risk parameters (SL/TP in pips, R:R ratio)
— Account status and open positions
The AI responds with:
— **Confidence score** (0-100%)
— **Decision** (GO / NO_GO)
— **Key factors** (2-3 main factors)
— **Risk warning** (main identified risk)
If confidence falls below the minimum threshold, the trade is **blocked**.
After each trade closes, the AI also provides a **post-trade analysis** with assessment, rating and lesson learned.
**Supported providers:**
```
1. Anthropic (Claude) — claude-sonnet-4
2. OpenAI (ChatGPT) — gpt-4o
3. Google (Gemini) — gemini-2.0-flash
4. Mistral — mistral-large-latest
5. Groq — llama-3.3-70b-versatile
6. Perplexity — sonar-pro
7. Cohere — command-r-plus
8. xAI (Grok) — grok-2
9. DeepSeek — deepseek-chat
10. Together AI — Llama-3.3-70B-Instruct-Turbo
11. Fireworks AI — llama-v3p3-70b-instruct
12. OpenRouter — anthropic/claude-sonnet-4
13. Ollama (local, free) — llama3.1
```
Every provider has a pre-configured default URL and model. You can override both the model and the URL for maximum flexibility.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔧 **PARAMETERS — COMPLETE GUIDE**
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
💰 **1. RISK MANAGEMENT**
▸ **Risk Mode** — `PercentRisk` / `FixedLot`
Choose between percentage-based position sizing or fixed lot. In PercentRisk mode the bot automatically calculates volume based on stop loss distance and available capital. Default: `PercentRisk`
▸ **Risk % per Trade** — 0.1% to 5.0%
Percentage of account balance risked on each trade. Volume is calculated so that if the SL is hit, the loss equals exactly this percentage. Default: `1.0%`
▸ **Fixed Volume (Lots)** — 0.01 and up
Fixed volume in lots, only used when Risk Mode is set to FixedLot. Default: `0.1`
▸ **Max Open Positions** — 1 to 10
Maximum number of positions the bot can hold simultaneously. When the limit is reached, no new trades are opened. Default: `3`
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📈 **2. H4 TREND BIAS**
▸ **H4 EMA Period** — 50 and up
EMA period applied to the H4 timeframe. Determines the long-term directional bias. Price above EMA = bullish bias, below = bearish. An ATR-based buffer prevents false signals when price is too close to the average. Default: `200`
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔍 **3. H1 CONFIRMATION**
▸ **H1 EMA Period** — 10 and up
EMA period on the H1 timeframe. Price must be on the correct side of this EMA to confirm entry. Default: `50`
▸ **H1 RSI Period** — 5 and up
Relative Strength Index period on H1. Used both for trend confirmation (RSI > 50 for longs, < 50 for shorts) and overextension filtering in mean-reversion (RSI < 35 or > 65). Default: `14`
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🎯 **4. M15 ENTRY**
▸ **EMA Fast Period** — 5 and up
Fast EMA on the entry timeframe (M15). The crossover with the slow EMA generates the trend-following signal. Default: `21`
▸ **EMA Slow Period** — 10 and up
Slow EMA. The EMA Fast/Slow crossover is the primary trigger for the trend strategy. Default: `50`
▸ **Stochastic K / D / Slowing** — stochastic oscillator periods
Used as momentum confirmation. In trend strategy it filters entries in non-extreme zones; in mean-reversion it identifies overbought/oversold areas. Default: `K=14, D=3, Slowing=3`
▸ **Bollinger Period** — 10 and up
Bollinger Bands period. In mean-reversion, a touch of the upper/lower band is the entry trigger. Default: `20`
▸ **Bollinger Std Dev** — 1.0 and up
Bands standard deviation. Higher values = wider bands = fewer but more reliable signals. Default: `2.0`
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🌡️ **5. REGIME DETECTION (ADX)**
▸ **ADX Period** — 7 and up
Directional Movement System period. Measures trend strength regardless of direction. Default: `14`
▸ **ADX Trend Threshold** — 15 to 40
Threshold separating trending from ranging markets. ADX above this value = trend-following active; below = mean-reversion active. Default: `25`
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🛡️ **6. SL / TP (ATR-BASED)**
All stop losses and take profits are dynamic, calculated as multiples of the current ATR. This means they automatically adapt to volatility: tight stops in calm markets, wider stops in volatile markets.
▸ **ATR Period** — 5 and up
Average True Range period. Measures recent volatility and serves as the base for SL, TP, breakeven and trailing calculations. Default: `14`
▸ **SL x ATR** — 0.5 and up
ATR multiplier for stop loss. E.g.: with ATR = 20 points and multiplier 1.5, the SL will be 30 points from entry price. Default: `1.5`
▸ **TP x ATR (Trend)** — 1.0 and up
ATR multiplier for take profit in trend-following. Typically higher than SL for a favorable R:R. Default: `2.5`
▸ **TP x ATR (Reversion)** — 0.5 and up
ATR multiplier for take profit in mean-reversion. Typically more conservative since the target is a return to the mean. Default: `1.5`
▸ **Min SL (Pips)** — 1 and up
Minimum stop loss in pips. If the ATR calculation produces an SL below this value, the minimum is used instead. Protects against overly tight stops in ultra-low volatility conditions. Default: `10`
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔄 **7. TRAILING STOP**
Active management system for open positions with automatic breakeven and trailing stop, both ATR-based.
▸ **Enable Trailing** — On/Off
Enables/disables the entire trailing system. When off, positions keep their fixed SL/TP until closure. Default: `On`
▸ **Breakeven After x ATR** — 0.3 and up
When unrealized profit reaches this ATR multiple, the SL is moved to entry price (+ half spread to cover costs). The trade becomes risk-free. Default: `1.0`
▸ **Trail Distance x ATR** — 0.5 and up
Trailing stop distance from current price, expressed as an ATR multiple. The SL follows price and never moves back. Default: `1.2`
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🕐 **8. SESSION FILTER**
Filters trading activity based on time. US500 behaves very differently during pre-market, regular session and after-hours.
▸ **Enable Session Filter** — On/Off
Enables/disables the time filter. Default: `On`
▸ **Session Start (Hour CET)** — 0-23
Start hour of the trading window (CET timezone). Default: `15` (US session open)
▸ **Session End (Hour CET)** — 0-23
End hour of the trading window. Default: `22` (US session close)
The bot also supports sessions that cross midnight (e.g. Start=22, End=6).
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚙️ **9. MISC**
▸ **Cooldown (Bars)** — 0 and up
Minimum number of M15 bars that must pass between one trade and the next. Prevents overtrading in rapid-signal situations. Default: `3` (= 45 minutes)
▸ **Show Dashboard** — On/Off
Shows/hides the on-chart dashboard with regime, bias, indicators, P&L, AI status and live statistics. Default: `On`
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🤖 **10. AI ANALYSIS**
▸ **Enable AI Filter** — On/Off
Enables/disables the AI filter. When off, the bot operates on technical analysis only. Default: `Off`
▸ **AI Provider** — selection among 13 providers
Choose which AI provider to use. Each provider has a pre-configured URL and model. Default: `Anthropic`
▸ **API Key** — string
Your API key for the selected provider. Required for all providers except Ollama (which runs locally). Leave blank if using Ollama.
▸ **Model (blank=default)** — string
AI model override. Leave blank to use the selected provider's default model. Useful for testing specific models (e.g. "gpt-4o-mini", "claude-haiku-4-5-20251001").
▸ **Custom API URL (blank=default)** — string
API URL override. Useful for Ollama on a custom port, corporate proxies or custom endpoints.
▸ **Min Confidence (%)** — 30 to 95
Minimum AI confidence threshold to approve a trade. If the AI returns a score below this, the trade is blocked even if all technical signals are valid. Default: `65`
▸ **Fail Open (allow on error)** — On/Off
Behavior when AI fails (timeout, API down, malformed response). On = trade goes through anyway (fail-open). Off = trade is blocked (fail-closed). Default: `On`
▸ **Post-Trade AI Review** — On/Off
When enabled, after each trade closes the bot sends the result details to the AI which provides an assessment, rating (GOOD/NEUTRAL/BAD) and lesson learned. Everything is logged to the console. Default: `On`
▸ **Price Bars to AI** — 5 to 25
Number of recent M15 candles sent to the AI in the analysis context. More bars = more context but more tokens consumed. Default: `12`
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📋 **ON-CHART DASHBOARD**
The dashboard displays in real time:
— Current regime (TREND / RANGE)
— H4 bias (BULL / BEAR / FLAT)
— ADX, ATR, H1 RSI values
— Open positions / maximum
— Open P&L, balance, equity
— Session status (ACTIVE / CLOSED)
— Total trades and win rate %
— AI status: provider, last decision, confidence
— AI call count and blocked trades
Color changes automatically: 🟢 green when P&L is positive, 🔴 red when negative.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📌 **TECHNICAL NOTES**
— Recommended timeframe: **M15** (the bot warns if used on other TFs)
— `AccessRights.None` — no special permissions required
— Uses cTrader native `Http.Send()` for AI calls
— Compatible with cTrader 4.2+ (.NET 6)
— Supports backtesting (without AI) and live trading (with or without AI)
— Bot positions are identified by the label `AiUS500Pro`
— Does not interfere with manual positions or other bots
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠️ **DISCLAIMER**
This cBot is provided for educational and informational purposes only. Trading indices involves significant risk of capital loss. Past results do not guarantee future returns. AI integration improves filtering but does not eliminate risk. Always test on a demo account before using on a live account. You are solely responsible for your trading decisions.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━