General description Name: OUR EA Platform: MetaTrader 5 (MT5) Type: Multi‑symbol, multi‑timeframe, CE‑based trading engine Core indicator: Chandelier Exit (CE), user‑configurable Primary style: Scalping and intraday, with support for other timeframes Trade directions: Long and short Assets: Any (FX, metals, indices, crypto), no hardcoded symbol Inputs (external parameters) General: Symbol/Timeframe: UseCurrentSymbol = true/false CustomSymbol = "XAUUSD" (used if UseCurrentSymbol = false) EA always uses the chart timeframe (no override needed). Trading directions: TradeLongs = true/false TradeShorts = true/false Risk & lots: UseAutoLot = true/false FixedLot = 0.01 RiskPerTradePercent = 1.0 (used if UseAutoLot = true) Magic & ID: MagicMode = Auto/Manual MagicNumber = 123456 (used if Manual) Chandelier Exit (CE): CE_ATR_Period = 7 CE_ATR_Multiplier = 1.0 CE_Mode = Manual (future‑proof: could add Auto later) Entry logic mode: EntryMode = 0/1/2 0 = CE_Breakout (simple single‑entry mode) 1 = CE_Band_3Entry (Dark Band‑style, 3 entries) 2 = CE_Pullback (reserved for future) For now, we define 0 and 1 fully. Band / 3‑entry settings (for EntryMode = 1): Use3Entries = true/false (if false, only Entry 1 is used) Entry distance from CE (in points): Entry1_OffsetPoints = 0 (at/just above/below CE) Entry2_OffsetPoints = 200 (20 pips equivalent on 1‑digit gold, adjust by broker) Entry3_OffsetPoints = 400 Stop loss buffers (in points): SL1_BufferPoints = 200 SL2_BufferPoints = 400 SL3_BufferPoints = 600 Take profit: UseSharedTP = true/false TP_RR_Multiplier_Entry1 = 1.2 TP_RR_Multiplier_Entry2 = 1.2 TP_RR_Multiplier_Entry3 = 1.2 If UseSharedTP = true, TP is calculated per entry using its own RR multiplier. Execution & filters: MaxSpreadPoints = 300 (e.g. 3.0 pips on gold; user adjusts per symbol) MaxSlippagePoints = 100 UseSessionFilter = true/false SessionStartHour = 7 (broker time) SessionEndHour = 22 CooldownCandlesAfterLoss = 5 MaxTradesPerDirection = 3 (for 3‑entry mode) Indicator logic — Chandelier Exit (CE) On each tick, for the current symbol/timeframe: ATR calculation: ATR = AverageTrueRange(CE_ATR_Period) Highest high / lowest low over ATR period: HH = HighestHigh(CE_ATR_Period) LL = LowestLow(CE_ATR_Period) CE lines: Long CE (upper line): CE_ Long=HH-ATR\times CE_ ATR_ Multiplier- Short CE (lower line): CE_ Short=LL+ATR\times CE_ ATR_ Multiplier For simplicity, EA can use a single CE line depending on direction: For BUY logic: use CE_Long For SELL logic: use CE_Short Store at least CE[0] and CE[1] (current and previous). Entry logic 4.1. Common pre‑conditions (all modes) Before any entry: Spread ≤ MaxSpreadPoints If UseSessionFilter = true: current broker hour ∈ [SessionStartHour, SessionEndHour] No more than MaxTradesPerDirection open for this MagicNumber and symbol Cooldown: if last closed trade was a loss, ensure at least CooldownCandlesAfterLoss bars have passed 4.2. Mode 0 — CE_Breakout (single entry) BUY conditions: TradeLongs = true Close[1] <= CE_Long[1] Close[0] > CE_Long[0] CE_Long[0] > CE_Long[1] (CE rising) SELL conditions: TradeShorts = true Close[1] >= CE_Short[1] Close[0] < CE_Short[0] CE_Short[0] < CE_Short[1] (CE falling) SL/TP (single entry): For BUY: SL = CE_Long[0] - SL1_BufferPoints If UseAutoLot = true, lot size based on SL distance and RiskPerTradePercent TP = EntryPrice + (EntryPrice - SL) * TP_RR_Multiplier_Entry1 For SELL: SL = CE_Short[0] + SL1_BufferPoints TP = EntryPrice - (SL - EntryPrice) * TP_RR_Multiplier_Entry1 4.3. Mode 1 — CE_Band_3Entry (Dark Band‑style) Trend filter (common for all 3 entries): BUY trend: CE_Long[0] > CE_Long[1] (rising) Close[0] >= CE_Long[0] (price at or above CE) SELL trend: CE_Short[0] < CE_Short[1] (falling) Close[0] <= CE_Short[0] (price at or below CE) BUY entries (up to 3) Define CE reference: CE = CE_Long[0]. Entry 1 (E1 BUY): Trigger: Close[0] > CE + Entry1_OffsetPoints Trend filter satisfied SL: SL1 = CE - SL1_BufferPoints TP: If UseSharedTP = true: TP1 = EntryPrice + (EntryPrice - SL1) * TP_RR_Multiplier_Entry1 Entry 2 (E2 BUY): Trigger (only if E1 is open or allowed): Price touches/pulls back near CE: Bid <= CE + Entry2_OffsetPoints Trend filter still valid SL: SL2 = CE - SL2_BufferPoints TP: TP2 similar to E1 with its own RR Entry 3 (E3 BUY): Trigger: Deeper pullback: Bid <= CE + Entry3_OffsetPoints Trend filter still valid SL: SL3 = CE - SL3_BufferPoints TP: TP3 with its own RR Entries can be opened independently as conditions are met, up to MaxTradesPerDirection. SELL entries (up to 3) Define CE reference: CE = CE_Short[0]. Entry 1 (E1 SELL): Trigger: Close[0] < CE - Entry1_OffsetPoints Trend filter satisfied SL: SL1 = CE + SL1_BufferPoints TP: TP1 = EntryPrice - (SL1 - EntryPrice) * TP_RR_Multiplier_Entry1 Entry 2 (E2 SELL): Trigger: Ask >= CE - Entry2_OffsetPoints Trend filter still valid SL: SL2 = CE + SL2_BufferPoints TP: TP2 similar to above Entry 3 (E3 SELL): Trigger: Ask >= CE - Entry3_OffsetPoints Trend filter still valid SL: SL3 = CE + SL3_BufferPoints TP: TP3 with its own RR Exit logic Hard exits: TP hit SL hit Soft exits (optional but recommended): For BUY trades: If CE_Long[0] < CE_Long[1] (CE starts falling) OR Close[0] < CE_Long[0] (price closes below CE) → Close BUY trade(s) at market. For SELL trades: If CE_Short[0] > CE_Short[1] (CE starts rising) OR Close[0] > CE_Short[0] → Close SELL trade(s) at market. Time‑based exit (optional): If a trade is open longer than MaxBarsInTrade (e.g. 60 bars) and not at TP/SL → close at market. MaxBarsInTrade can be an input (default 0 = disabled). Risk management If UseAutoLot = true: For each new trade: Calculate SL distance in points: SL_DistPoints = abs(EntryPrice - SL) / Point Convert to money risk: RiskMoney=AccountEquity\times \frac{RiskPerTradePercent}{100}- Lot size: Lots=\frac{RiskMoney}{SL_ DistPoints\times TickValue}- Ensure Lots is within broker min/max and step. If UseAutoLot = false, use FixedLot. Trade management rules EA tracks trades by MagicNumber and Symbol. MaxTradesPerDirection limits how many BUY or SELL trades can be open at once. No hedging logic required beyond that; BUY and SELL can coexist if allowed by broker, unless you want to restrict (coder can add AllowHedge = true/false if needed). Pseudocode outline (high level) On each tick: If UseCurrentSymbol = true → use chart symbol, else CustomSymbol. Read CE values (CE_Long[0/1], CE_Short[0/1]). Check spread, session, cooldown. Count open BUY/SELL trades for this MagicNumber & symbol. If EntryMode == 0 → evaluate CE_Breakout rules. If EntryMode == 1 → evaluate CE_Band_3Entry rules for BUY and SELL. For each open trade: Check SL/TP (MT5 handles automatically if set). Check soft exit conditions (CE flip, time‑based). Apply risk logic when opening new trades.