Specification
✅ Overview
I am looking for an experienced MQL4 developer to create a Renko Candle Expert Advisor (EA) for MetaTrader 4 that functions on offline Renko charts. The EA will execute trades based on consecutive same-color Renko candles and a trend direction filter using a Simple Moving Average (SMA). This EA must strictly follow Renko candle logic and not time-based price bars.
⚙️ Core Functionality
🔁 1. Trade Entry Logic
- The EA must check for 2 or 3 consecutive Renko candles of the same color (based on input setting: EntryOnCandle = 2 or 3).
- Once the condition is met, the EA should:
- Open a trade at the open of the next Renko candle in the same direction.
✅ Entry Rules:
- Buy Trade:
- If the last 2 or 3 Renko candles are Green (Bullish) → Open Buy at the open of the next Green candle.
- Sell Trade:
- If the last 2 or 3 Renko candles are Red (Bearish) → Open Sell at the open of the next Red candle.
- Only one trade per valid signal should be executed.
📈 2. Trend Filter (Optional) The EA should have an optional trend filter based on a Simple Moving Average (SMA).
Inputs:
- UseTrendFilter = true/false
- TrendMAPeriod = integer (SMA period)
Logic:
- If UseTrendFilter = true:
- Buy trades are allowed only if price > SMA(TrendMAPeriod)
- Sell trades are allowed only if price < SMA(TrendMAPeriod)
🟡 Important Note:
SMA crossover must not be used as a signal for trade entry.
It is only a directional filter to determine if buy/sell trades are allowed.
Actual trade signals must still be based on Renko candle conditions only.
🔄 3. Trade Management – Close on Opposite Signal
Input:
- CloseOnNextEntry = true/false
Logic:
- If CloseOnNextEntry = true:
- Close the current open trade when a valid opposite Renko signal appears (based on EntryOnCandle setting).
- Even if the opposite trade is blocked by the trend filter, still close the current trade.
- Only place the new opposite trade if allowed by the trend filter.
⏰ 4. Trading Hours Filter (also add true and false)
Inputs:
- StartHour = int (e.g., 8 for 08:00)
- EndHour = int (e.g., 20 for 20:00)
Logic:
- EA should only allow new entries within the defined time range, using the broker's server time.
- No new trades should be initiated outside this range.
- Existing trades may continue to run and be closed as per logic above.
⚙️ 5. General Settings
- LotSize – Define fixed lot size for orders.
- StopLoss – SL in pips (optional, if set > 0).
- TakeProfit – TP in pips (optional, if set > 0).
- Only one trade per signal.
- Prevent multiple entries on the same Renko candle.
🆕 🔁 6. Persistent Signal Hold (Missed Entry Recovery)
To handle cases where trades are skipped due to high volatility, the EA should remember a valid signal for a limited number of Renko candles, and place the trade if the condition remains valid during that time.
Inputs:
- MaxSignalHoldCandles = 3 — Number of Renko candles to hold and reuse a missed signal.
Logic:
- When a valid trade signal occurs but no trade is executed (e.g., due to volatility), set a flag to remember the signal.
- If the same direction candles continue forming (and all filters allow), the EA should place the trade on the next available candle.
- After MaxSignalHoldCandles, the signal is discarded.
- Once a trade is placed, the signal is cleared.
✅ Purpose:
This ensures that missed signals during fast moves are still acted upon if the market direction remains unchanged shortly after.
🔒 7. Spread Control
Inputs:
- EnableSpreadControl = true/false
- MaxAllowedSpread = 20 (points)
- DelayEntryIfSpreadHigh = true/false
Logic:
- If spread higher than MaxAllowedSpread when a valid signal appears:
- No trade will be placed.
- If DelayEntryIfSpreadHigh = true, EA will hold the signal up to MaxSignalHoldCandles.
- If spread returns to acceptable range and signal remains valid and no another trade, the trade is placed.
- Otherwise, the signal is discarded.
✅ Purpose: Avoids poor trade entries during high spread and allows missed signals to be re-entered if conditions normalize.
📎 Technical Requirements
- EA must work on Renko offline charts, not on time-based charts.
- All logic should be applied based on Renko bricks/candles, not standard candles.
- Code must be clean, optimized, and well-commented for future edits or enhancements.
📩 Deliverables
- Final .mq4 and compiled .ex4 files.
- Source code must be fully open and not protected or obfuscated.
- Documentation for input parameters and basic usage.
🧪 Optional (If feasible)
- On-chart labels (current trend direction, active trade, etc.)
- Alerts on new trade signals (popup, email, push notifications)