002 - Inside Bar
This is a powerful addition to your MetaTrader 5 toolkit designed to optimize market analysis and performance. This Expert Advisor serves as automated trading software. It is utilized to monitor financial markets and execute trades based on predefined algorithmic rules, enabling precise position management without the need for constant manual oversight.
How to Setup and Use 002 - Inside Bar
1. Installation: Open the "File" menu, select "Open Data Folder," navigate to MQL/Experts, paste your file, and restart the terminal.
2. Activation: Drag the EA from the Navigator onto a chart, ensure "Allow live trading" is checked in the Common tab, and verify the AutoTrading button is green.
3. Optimization: Right-click your chart, choose "Expert List," click "Properties" to adjust inputs, and save your preferred setup as a set file for future use.
4. Maintenance: Regularly check the "Experts" tab in the terminal window to monitor trade logs and potential execution errors.
Frequently Asked Questions
Q: Why is my EA not opening trades? A: Check the "AutoTrading" button, ensure "Allow live trading" is enabled, and verify your broker allows automated trading on your account type.
Q: Can I run multiple EAs on one chart? A: No, each chart can only host one active EA; however, you can open multiple charts for different currency pairs to run several EAs.
Q: What does the "smiley face" icon mean? A: A smiley face in the top-right corner of the chart indicates the EA is successfully running; a frowny face means it is disabled.
Description & Settings
Strategy logic: the EA searches for a classic Inside Bar pattern consisting of a
Main Bar
and a
Signal Bar
.
Main Bar
— the larger candle containing the pattern.
Signal Bar
— the Inside Bar fully contained within the Main Bar range.
The Signal Bar must be completely inside the range of the Main Bar. If the Main Bar closes bullish, a Buy Stop order is placed above the Main Bar high. If the Main Bar closes bearish, a Sell Stop order is placed below the Main Bar low.
Stop Loss is calculated as a fraction of the Main Bar range.
Take Profit is calculated using a predefined Risk/Reward ratio.
An optional ATR filter can be applied to require the Main Bar to be significantly larger than recent market volatility.
This EA was built as a research tool for testing the statistical behavior of the Inside Bar pattern across different markets and timeframes.
Parameters
Lot Type
- Position sizing method. Fixed Lot — fixed trade volume. % Risk from Start Balance — position size calculated from a predefined risk percentage.
Lot Size
- Fixed lot size used when Fixed Lot mode is selected.
Risk per Transaction (%)
- Risk per trade in percent. Used only when risk-based position sizing is enabled.
ATR Filter
ATR Filter (Main Bar Size)
- Enables or disables the ATR filter.
ATR Period
- ATR calculation period.
Min Main Bar Size (x ATR)
- Minimum Main Bar size expressed as a multiple of ATR.
Inside Bar Filter
Min Main Bar Body (% of Range)
- Minimum Main Bar body size expressed as a percentage of the Main Bar range.
Max Inside Bar Size (% of Main)
- Maximum Signal Bar size expressed as a percentage of the Main Bar range.
Position Settings
StopLoss (x Main Bar Range)
- Stop Loss distance expressed as a fraction of the Main Bar range.
TakeProfit (Risk/Reward)
- Risk/Reward ratio used to calculate Take Profit (0 disables Take Profit).
Order Management
Cancel Pending Order After N Bars
- Number of bars after which an unfilled pending order is automatically cancelled. Important Notes
The EA analyzes the currently selected chart timeframe.
Pattern detection is performed only when a new bar appears.
The Signal Bar must be fully contained within the range of the Main Bar.
The direction of the Main Bar determines the trade direction.
Buy Stop orders are placed above the Main Bar high.
Sell Stop orders are placed below the Main Bar low.
Only one position per symbol can be open at a time.
Only one pending order per symbol can exist at a time.
Pending orders are automatically removed after the number of bars specified in
Cancel Pending Order After N Bars
.
When using
% Risk from Start Balance
, risk calculations are based on the account balance captured when the EA starts. Backtest Results
The strategy was tested on EURUSD, XAUUSD and SP500 across the
H1 and M15
timeframes.
The purpose of this Expert Advisor is research rather than optimization. The source code is published to allow independent verification, modification and testing of the hypothesis on other markets and datasets.
EURUSD M15 back test
Full research report, equity curves and test results:
Source code is open — feel free to modify it, test it on other instruments and build upon it.
This EA was created to test a trading hypothesis, not to trade real money without additional research and validation.