sentiment_ea
This EA trades based on market sentiment by comparing the ratio of buy vs sell orders and volumes from the order book. It opens positions when one side significantly dominates the other in both trader count and volume, and closes when the sentiment ratio reverses or weakens. Trading is restricted to a specific weekday and intraday time window.
Open the interactive view (equity curve, symbol switch)Key facts
Backtest results (H1, about 1 year)
Not backtested yet — this EA could not be converted automatically.
Strategy analysis
The strategy concept is based on detecting buy-sell order imbalance from market depth data to gauge market sentiment direction, classifying it as an order flow/sentiment analysis strategy. Entry conditions require both the trader count ratio and volume ratio between buy and sell sides to exceed configured thresholds simultaneously, with at least one side meeting minimum trader count (MinTraders) and minimum volume (MinVolume) requirements, all within a defined trading session (Mon-Fri 10:15:30 to 23:35:30). After opening a position, the thresholds switch to lower maintenance levels (MinDiffVolumesEx and MinDiffTradersEx), implementing a hysteresis mechanism to avoid frequent open-close cycles. Exit conditions trigger when the sentiment ratio for the held position falls below the maintenance threshold, or when outside the trading session, at which point the position is closed and thresholds reset to entry levels. Position sizing is fixed lot-based (Lots parameter) with no scaling logic. Money management relies solely on fixed-pip stop loss and take profit (SlPips and TpPips) with no dynamic adjustment or proportional risk control.
Strengths
- Uses real order book depth data for sentiment rather than lagging technical indicators
- Hysteresis mechanism (separate entry vs maintenance thresholds) reduces overtrading and transaction costs
- Trading session filter effectively avoids low-liquidity periods and weekends
Weaknesses
- Using Sleep() in OnTick blocks the main thread, potentially freezing the terminal or missing market events
- No proper position check logic; pos variable is int but assigned true/false, causing type inconsistency and potential logic errors
- SL/TP calculated with gTickSize instead of point, which may be inaccurate on non-standard instruments
- No new bar check mechanism, potentially triggering signals repeatedly on the same bar
- Position tracking relies on tradeResult flag instead of actual position state; state is lost on EA restart
Possible improvements
- Replace Sleep() with EventSetTimer/OnTimer to avoid blocking the main thread and maintain EA responsiveness
- Add real position query (PositionSelect) instead of pos flag variable to ensure correct state recovery after restart
- Add new bar check and spread filter to prevent repeated entries under unfavorable conditions
Risk assessment
Overall risk: Medium
- Sleep() blocking the main thread may prevent timely stop-loss execution, creating delay risk
- EA restart loses tradeResult and pos state, potentially causing duplicate entries or failure to close positions
- Fixed lot sizing with no dynamic risk control may lead to excessive losses during extreme market moves
- Buy-sell ratio signals may produce false signals when market depth data is anomalous
Evaluation scores
Parameters
| Parameter | Default | Description |
|---|---|---|
MinVolume | 20000 | Minimum order volume threshold |
MinTraders | 1000 | Minimum trader count threshold |
DiffVolumesEx | 2.0 | Buy/sell volume ratio threshold for entry |
DiffTradersEx | 1.5 | Buy/sell trader ratio threshold for entry |
MinDiffVolumesEx | 1.5 | Volume ratio maintenance threshold while in position |
MinDiffTradersEx | 1.3 | Trader ratio maintenance threshold while in position |
Sleep | 5 | Sleep interval between ticks (minutes) |
Lots | 1 | Trade lot size |
TpPips | 500 | Take profit points |
SlPips | 500 | Stop loss points |
Filling | ORDER_FILLING_RETURN | Order filling type |
Similar Session Trading EAs
Backtests are historical simulations and do not guarantee future results. Not financial advice.