This MQL4 Expert Advisor implements a random timeframe trading strategy with confirmation and revenge trading. Here's a detailed breakdown:
Core Strategy
Entry Logic:
Core Strategy
Entry Logic:
- Randomly selects a timeframe from M1, M5, or M15
- Waits for a bar to close on that timeframe
- Checks if the closed bar is bullish (close > open) or bearish (close < open)
- Requires confirmation from a user-defined timeframe (default M30) - the current progressing bar must move in the same direction
- If both align: opens a BUY (both bullish) or SELL (both bearish)
- Only one trade open at a time
Exit Logic
Three ways a trade can close:
- Take Profit: 100 pips (default)
- Stop Loss: 100 pips (default)
- Manual Exit: If 6 consecutive bars move against the position on the trade's timeframe
- BUY trade: closes after 6 bearish bars
- SELL trade: closes after 6 bullish bars
Key Features
1. Revenge Trading System:
- After a stop loss or manual close (loss): lot size multiplies by RevengeFactor (default 2.0)
- After a take profit (win): lot size resets to initial LotSize
- Example: 0.01 → SL → 0.02 → SL → 0.04 → TP → 0.01
2. Timeframe Management:
- Trades are monitored using the SAME timeframe that triggered them
- After trade closes, a NEW random timeframe is selected for the next trade
- If confirmation fails, immediately selects a new random timeframe
3. Smart Confirmation:
- Random timeframe: Uses CLOSED bar (index 1) - waits for bar completion
- Confirmation timeframe: Uses PROGRESSING bar (index 0) - checks current price action
Workflow Example
- EA selects M5 randomly
- M5 bar closes bearish
- Checks M30 current bar - also bearish ✓
- Opens SELL trade with 0.01 lots
- Monitors M5 bars for 6 consecutive bullish bars
- Trade hits stop loss
- Next trade will use 0.02 lots
- Selects M15 randomly
- Waits for M15 bar to close...
Parameters
- LotSize: 0.01 (initial)
- TakeProfitPips: 100
- StopLossPips: 100
- MagicNumber: 12345 (identifies EA's trades)
- ConfirmationTimeframe: M30
- RevengeFactor: 2.0 (doubles lot size after loss)
This is an aggressive martingale-style system that aims to recover losses through position sizing increases.Attachment 4