TheTradeAssistant — standalone MT5 panel
========================================

No login. No website. No internet connection needed.
This is a single trade panel that draws itself on your MT5 chart.

STEP 0 — EXTRACT THE ZIP FIRST (most common mistake)
----------------------------------------------------
Right-click the downloaded ZIP -> "Extract All..." -> Desktop.
Do NOT run anything from inside the ZIP preview window.

EASIEST WAY — one click (Windows)
---------------------------------
1. LEAVE METATRADER 5 OPEN. The installer detects the running terminal,
   which is the most reliable way to find the right folder.
2. Open the extracted TheTradeAssistant folder
3. Double-click  Install-TheTradeAssistant.bat
   (If SmartScreen warns: More info -> Run anyway)
4. Read what it prints. It tells you the exact folder it installed to and
   whether it compiled. Keep that window open if something failed.
5. In MT5: Navigator -> right-click "Expert Advisors" -> Refresh
6. Drag "TheTradeAssistant" onto any chart -> OK
7. Turn on the ALGO TRADING button in the toolbar (it must be green)

100% MANUAL WAY — always works, takes 30 seconds
------------------------------------------------
Use this if the installer printed anything with [X] or [!].

1. In MetaTrader 5: File -> Open Data Folder
   (a Windows Explorer window opens — this is the ONLY correct location)
2. Open the MQL5 folder, then the Experts folder
3. Copy TheTradeAssistant.mq5 into it
4. In MT5 press F4 (opens MetaEditor)
5. In MetaEditor: Ctrl+O, open that TheTradeAssistant.mq5, press F7
   The bottom panel must say "0 errors, 0 warnings"
6. Back in MT5: Navigator -> right-click "Expert Advisors" -> Refresh
7. TheTradeAssistant now appears in the list. Drag it onto a chart, click OK,
   and make sure ALGO TRADING in the toolbar is green.

Why it usually does not show up
-------------------------------
- The file was copied to a folder that is NOT the terminal's data folder.
  Only "File -> Open Data Folder" shows the correct one. Broker-branded
  and portable installs use different paths.
- It was never compiled: without TheTradeAssistant.ex5 the Navigator entry
  can stay hidden. Step 5 above fixes that.
- Navigator was not refreshed, or MT5 needs one restart.
- The file landed in MQL5\Indicators or MQL5\Files instead of MQL5\Experts.

Using the panel
---------------
- Risk % lot / Fixed lot   : choose how the lot size is calculated
- Risk %                   : percent of balance risked when SL is hit
- R:R                      : take profit = stop loss distance x this number
- Lot                      : lot used in Fixed lot mode
- SL pts                   : stop loss distance in points
- Lot to use               : live preview of the lot and cash at risk
- SELL / BUY               : open a market order with SL and TP applied
- Break even               : move SL to entry once far enough in profit
- Trail: ON/OFF            : trailing stop using the EA's TrailPoints input
- Close 50%                : close half of every open position on this symbol
- Close all / win / lose   : bulk close by result
- The "-" button in the header collapses the panel

Warning: this places real orders on whichever account the terminal is
logged into. Test it on a demo account first.

----------------------------------------
INSTALLER LOG
----------------------------------------
The installer now writes a full diagnostic report to:
  Desktop\TheTradeAssistant-install-log.txt

It lists every MT5 folder found, every file copied, the
MetaEditor exit code and the compile errors (if any).
If TheTradeAssistant still does not appear in Navigator,
send that log file and we can pinpoint the cause.


USING THE CHART LINES + ON-CHART CONTROL ROWS (v2.1)
-----------------------------------------------------
Three control rows now sit on the chart, docked to the lines:

  TOP    (green, on the TP line)   L | TP <points> | +$ | % | price
  MIDDLE (blue,  on the Entry line) R | M | S | BUY | Lot | price | PLACE | X
  BOTTOM (red,   on the SL line)   L | SL <points> | -$ | % | price

- L      = selects that line so you can drag it with the mouse
- R      = reverse BUY <-> SELL (SL/TP mirror around the entry)
- M      = snap the entry to the current market price (market order)
- S      = order type selector: AUTO -> MKT -> STOP -> LMT
- BUY    = current direction, click to flip
- Lot    = position size; typing a value switches to fixed-lot mode,
           otherwise it is calculated from Risk % and the SL distance
- price  = editable Entry / SL / TP prices (type and press Enter)
- PLACE  = submits the order using the selected type
- X      = clears the setup and rebuilds lines around the market price
- Under the entry row: live R:R and current market price.

Workflow: direction -> order type -> entry -> risk % -> SL -> TP ->
lot auto-calculates -> check R:R -> PLACE -> manage the open trade.

POSITION SIZING (v2.2)
----------------------
Three modes in the panel:
  Risk %     lot sized so a stop-out loses that % of equity
  Fixed lot  you type the lot yourself
  Cash risk  lot sized so a stop-out loses that exact amount of money
Sizing uses the instrument tick size, tick value and contract size, and is
rounded down to the broker lot step, clamped to min/max lot (optional
"Max lot cap" input).

EDIT AN EXISTING ORDER WITH THE LINES (v2.3)
--------------------------------------------
You no longer have to rebuild a setup to change a live trade.
  EDIT  (middle chart row, or "Edit existing order" in the panel)
        attaches the lines to an existing position or pending order on the
        symbol. Press it again to step to the next one; after the last one
        it detaches and returns to new-setup mode.
  The lines jump to that order's entry, SL and TP, the middle row shows
  POS / PEND and "Editing position #123456", and PLACE becomes APPLY.
  Drag the SL / TP lines (and, for a pending order, the entry line) or type
  exact prices, then press APPLY to send the modification.
  X detaches without changing anything.
Open positions keep their fill price, so only SL and TP are modified.
Pending orders can also have their entry price moved; the EA blocks a move
that would put the entry on the wrong side of the market.

TRADE MANAGEMENT AFTER ENTRY (v2.2)
-----------------------------------
  Break even   move SL to entry once in profit
  Risk free    SL exactly at entry (0R)
  Lock xR      SL at entry + your Lock-in R multiple
  SL to +1R    SL locked one full R in profit
  Set SL/Set TP apply the current SL / TP line to open positions
  Close %      close the percentage typed in the "Close %" box
  Close all / win / lose, Trailing stop
  Del pending  removes pending orders on this symbol
The panel shows floating P/L, P/L % of balance and the current R multiple.

Dragging the entry line moves SL and TP with it (turn off with the
"Dragging entry moves SL/TP" input). Every drag instantly recalculates
distance, money risk, risk %, reward, R:R and lot size.


LOT CALCULATOR + LINE DRAGGING FIXES (v2.4)
-------------------------------------------
- Lot sizing now uses the broker's own profit calculation, so it is correct on
  FX, metals, indices and CFDs even when the account currency differs from the
  quote currency. The panel shows "pt/lot" and the target risk amount, and warns
  when the broker minimum lot is bigger than your requested risk.
- The lines are created already selected, so you can drag Entry / SL / TP with
  the mouse straight away (or press L on the TP / SL rows to grab one).
- Refreshes no longer snap a line back while you are dragging it; the chart is
  the source of truth unless you typed a price or pressed M / R / X / EDIT.
- Typing an "SL pts" or "R:R" value in the panel now rebuilds the SL and TP
  lines around the entry immediately.

FULLY FLEXIBLE LINES + M TOGGLE (v2.5)
--------------------------------------
- Every line can now be moved with a simple pick-up / drop:
    L on the TP row      picks up the TP line
    L on the SL row      picks up the SL line
    L on the entry row   picks up the entry line (new button, first in the row)
  The button turns orange and shows L*, the line then follows your mouse.
  Click anywhere on the chart to drop it. Press L again to cancel.
  Normal MT5 dragging still works too, and typing an exact price still works.
- Moving the entry carries SL and TP with it (input "Dragging entry moves
  SL/TP" turns that off), and lot, risk, reward and R:R recalculate live.
- M is now a switch, not a forced action:
    M   OFF - the entry line stays exactly where you put it, so you can build
              a buy/sell STOP or LIMIT above or below the market
    M*  ON  - the entry is pinned to the live price (market order) and follows
              it tick by tick
  Turning M off returns the order type to AUTO; picking up the entry line with
  L also switches M off automatically.
- S still forces the order type: AUTO -> MKT -> STOP -> LMT.

EVERYTHING RESPONSIVE + KEYBOARD SHORTCUTS (v2.6)
-------------------------------------------------
- The lot calculator, risk / reward money, R:R and the HUD now update on every
  incoming tick (and once a second when the market is quiet), so the numbers
  always match the current lines and price.
- Every button now ends with a full refresh, so a click is reflected in the
  panel, the calculator and the chart rows immediately.
- Typing into "Risk %", "Risk $", "Lot", "SL pts" or "R:R" and pressing Enter
  switches to that sizing mode, rebuilds the SL/TP lines and recalculates the
  lot straight away.
- Keyboard shortcuts (click the chart once so it has focus):
    1 / 2 / 3    pick up the Entry / SL / TP line
    Up / Down    nudge the picked-up line 10 points (SL line if none picked)
    Esc          drop the line
    R            reverse BUY <-> SELL
    M            market-follow on/off
    P            PLACE (or APPLY when editing an order)
    X            reset the setup
    T            trailing stop on/off

LINES + ROW BUTTONS FULLY IN SYNC (v2.7)
----------------------------------------
- L no longer drops the line instantly. Press L, move the mouse (the line
  follows), then click once to drop it. Esc cancels.
- L, R, M, S, EDIT, BUY/SELL, PLACE and X now redraw the rows, the lines,
  the lot calculator and the panel in the same click, so the button state
  you see is always the real state.
- Each line carries its own price tag on the chart again:
    TP <price>   |   BUY/SELL <price> Lot <lot>   |   SL <price>
  The tag sits to the left of the last bar so it never hides behind the
  control rows on the right.
