PIPSWAY CANDLE BATCH M1 — version 1.002
Updated from your uploaded WORKNG SCALPER.zip (Candle M1 1.001).

WHAT CHANGED
- Three separate trades per entry by default (TradesPerEntry=3).
- FixedRiskUSD=3.00 PER TRADE, so $9 intended stop-risk budget per batch.
- Previous closed M1 candle bullish: BUY; bearish: SELL; doji: skip.
- No FVG confirmation, no impulse-volume filter, no order-flow filter.
- Close all owned positions on the first available tick of the next M1 candle.
- Once successfully closed, the next three-trade batch may open on that same
  new-candle tick, provided all checks pass within the entry window.
- A failed close blocks that candle's entry; overdue exits retry every tick.
- A partial, rejected or uncertain entry halts further entries until reviewed.
- New filename and magic number distinguish this version from your old robot.

SETUP ON PC
1. Wait until the old EA's positions are closed. Remove the old EA from the chart.
   Removing an EA does NOT close its positions. This version will not manage
   positions belonging to the old magic number.
2. Extract the ZIP. MT5 -> File -> Open Data Folder -> MQL5 -> Experts.
3. Create folder PIPSWAY_Candle_Batch and copy BOTH files into it:
   PIPSWAY_Candle_Batch_M1.mq5
   CandleBatchRules.mqh
4. Press F4, open PIPSWAY_Candle_Batch_M1.mq5 in MetaEditor, press F7.
   This ZIP contains source only. Compile to produce the .ex5.
5. Use a USD-denominated HEDGING demo account. Separate trades require hedging.
   ZAR accounts and cent accounts are not supported by this fixed-USD version.
6. Attach to XAUUSDm (Exness) or GOLD (XM), M1, on ONE chart only.
7. Keep AllowLiveTrading=false, TradesPerEntry=3, FixedRiskUSD=3.00.
8. Enable Allow Algo Trading and the terminal's Algo Trading toolbar button.
   Wait for the NEXT candle after attachment. Keep MT5 online and PC awake.

INPUTS
AllowLiveTrading=false: demo/tester only unless deliberately enabled.
TradesPerEntry=3: adjustable 1 to 4.
FixedRiskUSD=3.00: estimated stop budget for EACH child position, USD only.
StopATR=1.0: SL distance at least completed M1 ATR(14), widened for broker stops.
MaxSpreadATR=0.25: spread must be at most 25% of last completed M1 ATR(14).
DojiPoints=0: skip exact doji only; larger values skip small candle bodies too.
MaxEntryDelaySeconds=5: no entries beyond 5 seconds into the new candle.
Magic=26102011: do not change while this version's positions exist.
MaxSlippagePoints=10: broker POINTS, not pips; some execution modes ignore this.
CommissionReservePerLot=10.0: estimated round-trip USD fee reserve per 1 full lot.
  Adjust to actual broker fees; the default is an assumption, not a broker quote.
The old UseFixedRiskUSD and RiskPercent choices are removed; this is fixed USD.

RISK AND EXECUTION
Lots are calculated automatically with OrderCalcProfit, rounded down to broker
volume step. Budget includes a pre-entry adverse slippage allowance and estimated
fee reserve. A broker-side SL is sent with every child order. There is no TP:
the main exit is the next candle, with SL able to exit earlier.
A $3 budget is NOT a guaranteed maximum loss. Actual fills, gaps, fees or delayed
execution can exceed it. Three trades target up to $9 together. On a $10 account
that is 90% of starting funds; on $20 it is 45%. No daily-loss cap is included.
No martingale, averaging or replacement of stopped-out children in a candle.
Orders are sequential, not simultaneous or atomic. A batch can contain fewer
than three positions if conditions change after an earlier order succeeds.
Remaining-batch margin must fit within 80% of currently free margin. Risk budget
must fit funds. Minimum-lot risk over $3 means skip; lots are never rounded up.

WHY IT MAY STILL SKIP
No new candle yet; doji; session/history gap; first tick later than 5 seconds;
spread above ATR limit; minimum lot over risk budget; low margin; other account
positions/orders; disabled Algo Trading; non-USD/non-hedging account; order halt.
It attempts entries every eligible candle. It cannot guarantee trades every
minute regardless of broker conditions. The Experts tab gives the skip reason.

TIMING / RESTART
Example: previous candle closes bullish at 12:01 -> buy batch on first tick
within 12:01:00–12:01:05 -> close on first tick at/after 12:02:00.
If closed successfully, evaluate the candle that just closed for a new batch.
No ticks, outages or disabled trading can delay software exits. SL remains at
broker. On restart, positions with this magic older than current bar are closed
on a tradable tick. Attach mid-candle: no new entry until next candle.
Run one instance per account and symbol. Duplicate-bar guard is terminal-local;
do not run copies in different terminals. Manual/other-EA trades are not closed.

ENTRY HALT RECOVERY
After an entry failure/partial/uncertain response, current positions still receive
next-candle exit management. Review Trade AND History; verify no unresolved
orders with broker. Once fully flat, remove EA, press F3 in MT5 and find
PWCAB.<account>.<symbol>.26102011.halt. Set its value to 0 and reattach.
Do not clear a halt while an order's status is uncertain.

VALIDATION
13 tests passed against the exact shared direction/exit functions, covering
bull/bear, doji tolerance, intra-candle timing, next-candle boundaries and overdue
positions. Source structure and archive integrity checked. MetaEditor compilation,
broker order execution and performance backtesting were NOT available here.
Compile first; backtest with real ticks and broker costs, then forward-test demo.
Do not treat successful compilation or these unit checks as proof of profit.
