Please develop a Multi-Timeframe (MTF) Expert Advisor (EA) for MQL5. The EA will use three timeframes for its logic (W1 for trend, H4 for setup, H1 for entry).
1. Filter 1: Primary Trend (W1 Timeframe)
The EA must first check the Keltner Channel on the W1 (Weekly) chart.
Uptrend: Confirmed if the Keltner Channel's midband is sloping up (current midband value > previous midband value).
Downtrend: Confirmed if the Keltner Channel's midband is sloping down (current midband value < previous midband value).
Ranging: If the midband is flat, no new trades are taken.
2. Filter 2: Entry Setup (H4 Timeframe)
The EA only looks for setups in the direction of the W1 trend.
The EA will use a Stochastic of RSI indicator (Stochastic applied to RSI data).
Buy Setup: If W1 Trend is UP, the EA waits for the H4 StochRSI Main Line to cross below the Oversold_Level (e.g., 20). This arms the buy trigger.
Sell Setup: If W1 Trend is DOWN, the EA waits for the H4 StochRSI Main Line to cross above the Overbought_Level (e.g., 80). This arms the sell trigger.
3. Filter 3: Entry Execution (H1 Timeframe)
This filter provides the final confirmation for the trade after the H4 setup is armed.
Execute BUY Trade:
The W1 Trend must be UP.
The H4 StochRSI must be "armed" (have recently been in the oversold zone).
The EA will then monitor H1 candles.
A BUY trade is executed on the open of the next candle after an H1 candle closes green (Close > Open) AND its Close is higher than the previous H1 candle's Close.
Execute SELL Trade:
The W1 Trend must be DOWN.
The H4 StochRSI must be "armed" (have recently been in the overbought zone).
The EA will then monitor H1 candles.
A SELL trade is executed on the open of the next candle after an H1 candle closes red (Close < Open) AND its Close is lower than the previous H1 candle's Close.
4. Trade Management & Exits:
One Trade at a Time: Only one open trade allowed per pair.
Stop Loss (SL): Must have user-selectable options:
Fixed_Pips : A fixed pip value.
ATR_Based : Based on the H4 ATR_Period and ATR_Multiplier .
Keltner_Band : Place SL at the opposite H4 Keltner Channel band.
Take Profit (TP): Must have user-selectable options:
Fixed_Pips : A fixed pip value.
Risk_Reward_Ratio : A multiplier based on the SL (e.g., 2.0 for 1:2 R:R).
Keltner_Band : Place TP at the opposite H4 Keltner Channel band.
Please make all the following parameters configurable:
--- Trade Settings ---
MagicNumber : (e.g., 12345)
Trade_Comment : (e.g., "Strategy_v1")
Max_Slippage : (e.g., 3)
--- W1 Keltner Filter ---
Keltner_EMA_Period : (e.g., 20)
Keltner_ATR_Period : (e.g., 10)
Keltner_ATR_Multiplier : (e.g., 2.0)
--- H4 StochRSI Filter ---
RSI_Period : (e.g., 14)
Stoch_K_Period : 5 (This is your "5" setting)
Stoch_D_Period : 3 (This is your "3" setting)
Stoch_Slowing : (e.g., 3)
Overbought_Level : (e.g., 80.0)
Oversold_Level : (e.g., 20.0)
--- Exit Settings ---
SL_Method : (Dropdown: Fixed_Pips , ATR_Based , Keltner_Band )
SL_Pips : (e.g., 150)
SL_ATR_Period : (e.g., 14)
SL_ATR_Multiplier : (e.g., 2.5)
TP_Method : (Dropdown: Fixed_Pips , Risk_Reward_Ratio , Keltner_Band )
TP_Pips : (e.g., 300)
TP_Risk_Reward_Ratio : (e.g., 2.0)
--- Money Management ---
Fixed_Lot_Size : (e.g., 0.1)
Use_Risk_Percent : (true/false)
Risk_Percent : (e.g., 1.0) % of equity to risk