New free code from MQL5: indicators, EAs, and scripts for traders.
*Note*- "After detecting an Oder Block it then immediately trade on the open of the next candle'
*Warning* - "This EA hasn't been optimized but feel free to use the code as you wish"
OB Trader (Order Block Scalper)
Description
The OB Trader is a lightweight, automated trading system designed to identify and trade Order Block (OB) patterns based on price action. This Expert Advisor (EA) focuses on a specific two-candle formation to detect potential institutional buying or selling pressure. It is optimized for scalping with a built-in 1:1 risk-to-reward ratio.
Trading Strategy
The EA looks for two distinct patterns at the close of every new candle:
Bullish Order Block: Identified when a bearish candle (index 2) is followed by a bullish candle (index 1) that breaks the previous candle's high while maintaining specific structural ratios.
Bearish Order Block: Identified when a bullish candle (index 2) is followed by a bearish candle (index 1) that breaks the previous candle's low under specific structural conditions.
Key Technical Features
New Bar Execution: The logic runs exclusively at the opening of a new candle to prevent repainting and excessive calculations.
Automated Risk Management: * Stop Loss (SL): Automatically set at the high/low of the Order Block candle.
Take Profit (TP): Calculated dynamically using a Risk multiplier to ensure a consistent Reward-to-Risk ratio.
CTrade Integration: Uses the standard MQL5 CTrade class for reliable execution and magic number tracking.




Grid trading done right – try the robust Grid Expert Advisor for controlled risk. Details here.
Complement community code with advanced automation from RobotFX.
68123