# Index 4H/30M Pullback EA (MT5)

## Included
- `Index_4H_30M_Pullback.mq5` — Expert Advisor source code.
- H4 EMA 50/200 trend filter.
- M30 EMA 20 pullback/confirmation entry.
- Swing-based stop loss and 2R take profit.
- Position sizing based on 0.5% of current equity.
- Daily equity-loss lock (default 2%).
- High-impact MT5 Economic Calendar filter.
- End-of-day close (default 23:45 broker-server time).

## Install
1. Open MetaTrader 5 desktop.
2. Press F4 to open MetaEditor.
3. In MT5, use File -> Open Data Folder, then open `MQL5/Experts`.
4. Copy `Index_4H_30M_Pullback.mq5` into that folder.
5. Open the file in MetaEditor and press F7 to compile.
6. In MT5 Navigator, right-click Expert Advisors -> Refresh.
7. Attach the EA to the desired index symbol chart and enable Algo Trading.
8. Verify the broker's symbol specifications, server time, volume minimum/step, and trading hours.

## Default risk settings
- Risk per trade: 0.5% of equity.
- Daily loss limit: 2% of the equity baseline recorded when the EA first starts that broker-server day.
- Reward/risk: 2.0.
- News currencies: USD, EUR, GBP.
- News block: 30 minutes before and after high-impact events.
- End-of-day close: 23:45 broker-server time.

## Important limitations
- This source has not been compiled in MetaEditor or validated in a live broker environment here. Compile and test before use.
- The daily baseline is first recorded when the EA starts during a broker-server day; if started mid-day, the baseline starts then.
- The daily equity threshold includes account-wide equity changes, while close/lock actions are scoped to this EA's symbol and magic number. Other positions can therefore affect the threshold.
- News filtering uses MT5's built-in Economic Calendar. Calendar access may be unavailable in some environments; the EA blocks new entries if the live calendar query fails.
- MT5's built-in calendar is unavailable in Strategy Tester. The news filter is bypassed in tester mode, so ordinary backtests do NOT validate news avoidance. Use a historical-news data implementation to test it properly.
- End-of-day close uses broker-server time, not your local time. The terminal/VPS must be connected and ticks must arrive for `OnTick` to run; execution can fail or slip.
- A daily lock is stored in MT5 terminal global variables and remains for the remainder of that broker-server day. The baseline/lock is per account, EA magic number, symbol and date.
- Risk sizing estimates loss using `OrderCalcProfit`; gaps, slippage, commissions and execution differences can make actual loss larger.
- Demo test first. No strategy or risk control guarantees profit or caps losses in all market conditions.

## Suggested test
In Strategy Tester:
- Expert: Index_4H_30M_Pullback
- Symbol: your broker's index CFD
- Period: M30
- Model: Every tick based on real ticks
- Test several years if data is available
- Include realistic commission and spread settings
- Review drawdown, trade count, expectancy and out-of-sample results

Do not use the news-filter backtest results as evidence of news-filter performance unless you implement historical calendar data.
