New functions:
- CancelAllOrders(reason): Cancels all pending orders with logging
- CloseAllPositions(reason): Closes all open positions
- IsBreakout(): Detects when price breaks S2/R2
Order cancellation triggers:
1. ADX rises (trend starts) - Cancel all, wait for ranging
2. Price breaks S2/R2 (breakout) - Cancel all, close positions
3. Buy positions fill - Cancel remaining buy stops (avoid overexposure)
4. Sell positions fill - Cancel remaining sell stops
5. End of day (00:00) - Cancel all, close positions, reset grid
This prevents:
- Orphaned orders when trend starts
- Overexposure when one side fills
- Old orders from previous day causing issues
Added missing input variables:
- input int EquityFactorPercent= 0;
- input int LotsFactorPercent= 0;
These were referenced in CalcLots() function but not declared.
Changed initEquity from int to double to fix:
- Line 217: double - int subtraction
- Line 226: int * double / double calculation
- Added explicit cast for BaseEquity assignment
This resolves implicit type conversion warnings/errors in MT5.
Full MQL4 to MQL5 conversion:
- Replaced OrderSend with CTrade::OrderSend
- Replaced MarketInfo with SymbolInfoDouble/Integer
- Replaced Bid/Ask/Digits/Point with SymbolInfoDouble
- Changed int ticket to ulong ticket
- Updated indicator handling (iRSI/iADX/iATR with CopyBuffer)
- Updated order placement to MqlTradeRequest/Result
- Added proper TRADE_ACTION_PENDING for stop orders
- Added OrderFillling_IOC compliance