# SentyxEA — MT5 Expert Advisor

Thin client, not a reimplementation. This EA calls the same live backend the
website uses (`GET /api/ea/signal`) instead of reimplementing the scoring
engine in MQL5 — whatever change gets deployed to the site, the EA reflects
immediately, with no separate update.

## Setup

**1. Compile it.** Open `SentyxEA.mq5` in MetaEditor (comes with MT5:
File → Open Data Folder → MQL5/Experts, drop the file there, then open and
press F7 to compile). No external libraries needed beyond the standard
`Trade\Trade.mqh` that ships with every MT5 install.

**2. Whitelist the backend URL.** MT5 blocks all outbound web requests by
default. In the terminal: **Tools → Options → Expert Advisors** → check
"Allow WebRequest for listed URL" → add:

```
https://s-backend-production-28d2.up.railway.app
```

Without this step the EA will alert you and do nothing — it's an MT5
security feature, not something the EA can bypass.

**3. Attach it to a chart.** Drag the EA onto a chart for the pair you want
signals for. Set:

- **LoginEmail / LoginPassword** — same as the website login
- **Timeframe** — `M1`, `M5`, or `M15` (the only ones the engine tracks; the
  chart's own timeframe doesn't matter, this is a separate input)
- **SymbolSuffix** — if your broker appends something to symbol names (e.g.
  `EURUSD.m`, `EURUSD-ECN`), put that suffix here so it gets stripped before
  asking the backend about `EURUSD`
- **AutoTrade** — leave `false` at first. The EA will show the current setup
  in the chart comment and pop an alert on a new one, but place no orders.

## Turning on AutoTrade

Only after you've watched it call the signal right on alert-only mode for a
while, and **only on a demo account first**. When `AutoTrade = true`:

- A `TRIGGERED` setup places a market order now
- A `PENDING` setup places a limit order at the entry price and waits
- `TARGET_HIT` (already ran to TP1) and a cost-warning setup (stop too tight
  for the spread) are both skipped, same rules the website itself uses
- Stop-loss and take-profit are set directly on the order — MT5 and your
  broker manage the exit natively, the EA doesn't babysit the position
- Lot size is computed from `RiskPercent` of your account balance against
  the stop distance, floored to your broker's lot step
- Only one open position or pending order per symbol at a time (tracked by
  `MagicNumber`)

## What it does not do

- No trailing stop, no partial close, no re-entry logic — one target, one
  stop, placed once
- No position management beyond the initial order — if you want to close
  early, that's manual
- Doesn't track its own trade history — the backend already does that (same
  place the website's Signal History page reads from)

## Security note

Your login email/password live in the EA's inputs on your own machine —
same login as the website, nothing new. Don't share your compiled EA, `.set`
file, or a screenshot of the inputs panel with anyone, since that would
expose the credentials in plain text.

Not financial advice. Signals come from technical indicators on delayed
public data. Trade your own risk.
