Trabajo finalizado
Tarea técnica
Only apply if you have experience in building multitimeframe indicator. Do not use any software to generate the code automatically.
Code should be concise and proper as per best practices and typed by you.
MQL5 Indicator Requirements: HTF Engulfing or HTF Hammer/Shooting Star Bar Play (EHBP) with Multi-Timeframe Validation
1. Input Parameters
Timeframe Selection
-
Higher Timeframe (HTF):
-
Options: 1 Month , 1 Week , 1 Day , 8 Hour , 4 Hour , 2 Hour , 1 Hour , 15 Minute
-
Default: 1 Day
-
-
Lower Timeframe (LTF):
-
Options: 1 Month , 1 Week , 1 Day , 8 Hour , 4 Hour , 2 Hour , 1 Hour , 15 Minute
-
Default: 4 Hour
-
-
Validation:
-
Ensure LTF < HTF (e.g., if HTF= 4 Hour , LTF cannot be 8 Hour ).
-
Show error message and disable calculations if invalid.
-
2. Core Logic
Step 1: Detect HTF Engulfing or Hammer Candle closure + PO3 Signals
-
Bullish Signal (HTF candle):
-
low < previous low AND close > previous open AND close > Previous close AND close in Lower Timeframe above retracement level of selected Fib after breaching below it in lower timeframe but closing above it in lower timeframe candle . Its not necessary that the HTF candle High will be above the high of its previous candle. Still it should be considered if other conditions are met.
-
-
Bearish Signal (HTF candle):
-
high > previous high AND close < previous open AND CLOSE < PREV close AND close in Lower Timeframe below retracement level of selected Fib after breaching above it in lower timeframe but closing below it in lower timeframe candle .
Its not necessary that the HTF candle Low will be below the low of its previous HTF candle. Still it should be considered if other conditions are met.
-
Step 2: Calculate Retracement Levels
For each HTF signal, compute Fibonacci levels as per selection multiple Fib levels can be selected like 26 percent, 38 percent, 50%, 61.8 percent etc:
-
Bullish:
Copy25% = HTF High - (HTF High - HTF Low) * 0.25 38.2% = HTF High - (HTF High - HTF Low) * 0.382 50% = (HTF High + HTF Low) / 2 ...
-
Bearish:
Copy25% = HTF Low + (HTF High - HTF Low) * 0.25 38.2% = HTF Low + (HTF High - HTF Low) * 0.382 ...
Step 3: Track LTF Candle Closes
For each LTF candle close:
-
Bullish Signal Check:
If LTF candle:-
Breached below a retracement level (intra-candle low < level ).
-
Closed above the same level ( close > level ).
→ Trigger alert/label.
-
-
Bearish Signal Check:
If LTF candle:-
Breached above a retracement level (intra-candle high > level ).
-
Closed below the same level ( close < level ).
→ Trigger alert/label.
-
3. Visualization & Alerts
Labels
-
Display only after LTF candle closes and conditions are met.
-
Format:
-
EBP [Level] Held (LTF)
-
Example: EBP 38.2% Held (4H)
-
-
Placement:
-
Below/above the LTF candle that triggered the condition.
-
Retracement Lines
-
Plot horizontal lines for all active levels.
-
Color Coding:
-
Bullish: Shades of green.
-
Bearish: Shades of red.
-
Alerts
-
Trigger only after LTF candle closes. Give meaningful alerts which are descriptive and easy to understand. Print symbol name in alerts. In Chart labels show small labels like Green Up traingle for Bullish Setup and Red down triangle for Bearish setup.
-
Message Examples:
-
XAUUSD Bullish 38.2% Level Held on 4H LTF on 1 Day HTF at time 09:00 AM Swing Low in LTF price is 2912.
-
XAUUSD Bearish 61.8% Level Held on 2H LTF on 1 Day HTF at time 02:00 PM Swing High in LTF price is 2952.
-
4. Technical Implementation
Key Functions
-
Timeframe Validation:
mql5Copybool validateTimeframes() { int htfMinutes = convertToMinutes(htfInput); int ltfMinutes = convertToMinutes(ltfInput); return (ltfMinutes < htfMinutes); }
-
Track Active Signals:
Use arrays/structs to store:-
HTF signal type (bullish/bearish).
-
Retracement levels.
-
Corresponding LTF candle timestamps.
-
-
Check LTF Closes:
mql5 code example just for reference
void checkLTFCloses() { for (int i = 0; i < arraySize(activeSignals); i++) { // Get retracement levels for signal[i] for (int j = 0; j < levelsCount; j++) { double level = activeSignals[i].levels[j]; if (isBullish) { bool breached = ltfLow < level; bool closedAbove = ltfClose > level; if (breached && closedAbove) triggerAlert(); } else { bool breached = ltfHigh > level; bool closedBelow = ltfClose < level; if (breached && closedBelow) triggerAlert(); } } } }
No Repainting
-
All labels/alerts are tied to closed LTF candles (confirmed price action).
5. Example Workflow
-
HTF Signal: Bullish Engulfing + PO3 on 1D candle.
-
Calculate Levels: 25% = 1900, 38.2% = 1850, 50% = 1800.
-
LTF Candle (4H):
-
Candle 1: Low = 1845 (breaches 38.2%), Close = 1855 → Triggers alert/label.
-
Candle 2: Close = 1895 (no breach) → No action.
-
-
Labels: Display EBP 38.2% Held (4H) below Candle 1 after it closes.
6. Deliverables
-
Indicator Code:
-
.mq5 file with input validation, multi-timeframe logic, and alerts. Source code and executable both for MT5. Strategy should work in Strategy tester also when replaying.
-
-
Documentation:
-
Clear comments explaining HTF/LTF interaction. Inline comments and Header comments.
-
-
Testing:
-
Verify on EURUSD (HTF=1D, LTF=4H). XAUUSD, USOIL, US30, BTCUSD on various timeframe combinations.
-
Ensure labels/alerts never repaint.
-
Example of 50% fib retracement after a Bearish Engulfing HTF candle.

