Tarea técnica
Requirements Specification for Asian Range Breakout EA
1. Introduction
This document outlines the functional and technical requirements for the Asian Range Breakout Expert Advisor (EA) for MetaTrader 4 (MT4). The EA identifies a trading range during a specified time window (Asian Range) and executes trades based on specific breakout conditions.
2. Functional Requirements
2.1 Asian Range Identification
-
The EA must define the Asian Range based on a time window specified by the user.
-
Default range: 19:00 EST to 24:00 EST.
-
The user must be able to configure the start and end hours in the input parameters.
-
The EA must account for Daylight Saving Time (DST) in EST and adjust accordingly.
-
The Asian Range High and Low should be determined based on the highest and lowest price between the defined start and end hours.
2.2 Entry Conditions
-
Long Trade Entry:
-
A long position must be entered when a candle wicks below the Asian Range Low but closes above it.
-
The trade must be executed at the close of the triggering candle.
-
-
Short Trade Entry:
-
A short position must be entered when a candle wicks above the Asian Range High but closes below it.
-
The trade must be executed at the close of the triggering candle.
-
-
The EA should execute trades based on the timeframe of the chart it is running on (e.g., 15-minute timeframe means candles are 15-minute).
2.3 Stop Loss (SL) & Take Profit (TP)
-
The Stop Loss (SL) should be set below the low of the wick candle for long trades and above the high of the wick candle for short trades.
-
The user must be able to define a buffer in pips to adjust the SL beyond the wick level.
-
The SL must be at least 5 pips. If the calculated SL is smaller, it must be overridden to 5 pips.
-
The Take Profit (TP) should be set based on a Risk-to-Reward Ratio (RRR) specified by the user.
-
TP = Entry Price + (Risk × Risk-to-Reward Ratio) for long trades.
-
TP = Entry Price - (Risk × Risk-to-Reward Ratio) for short trades.
-
2.4 Position Sizing Based on Account Balance
-
The EA must provide an option for position sizing based on a fixed lot size or a percentage of account balance.
-
The user must be able to define a percentage of the account balance to risk per trade (e.g., 1%).
-
If SL is hit, the total loss should equal the specified percentage of the account balance.
-
The EA must dynamically calculate the trade lot size based on the user-defined risk percentage and the distance of SL from the entry price.
3. Technical Requirements
3.1 MetaTrader 4 Compatibility
-
The EA must be developed in MQL4.
-
The EA should work on any currency pair and timeframe.
-
The EA should use Magic Numbers to distinguish its trades.
-
The EA should allow for user-defined inputs:
-
Asian Range Start & End Hours (EST)
-
Lot Size
-
Slippage
-
Magic Number
-
Stop Loss Buffer (pips)
-
Minimum Stop Loss (pips)
-
Risk-to-Reward Ratio
-
Risk Percentage of Account Balance
-
3.2 Broker Time & DST Handling
-
The EA must adjust for broker time zone differences.
-
The EA must handle Daylight Saving Time (DST) automatically based on North American DST rules:
-
DST starts on the second Sunday of March.
-
DST ends on the first Sunday of November.
-
-
The EA must calculate the correct broker time adjustments based on whether DST is active.
3.3 Trade Execution & Risk Management
-
The EA must place orders with defined slippage.
-
The EA should avoid duplicate trades by ensuring that it does not enter multiple trades on the same signal.
-
The EA should manage active trades independently and avoid interference with manual trades.
4. Performance & Logging
-
The EA should log key events and errors for debugging purposes.
-
The EA should handle unexpected broker rejections or execution errors gracefully.
-
The EA should include basic debugging logs for identifying potential issues in execution.
5. Future Considerations
-
Potential addition of trade filtering conditions such as trend filters, volatility filters, or time-based restrictions.
-
Implementation of partial take profit or trailing stop mechanisms for optimizing profits.
6. Acceptance Criteria
-
The EA correctly identifies the Asian Range based on the user’s configured time.
-
The EA enters long and short trades as per the defined conditions.
-
The EA correctly calculates SL and TP based on the rules provided.
-
The EA correctly adapts to DST changes.
-
The EA does not interfere with manual trades.
-
The EA correctly calculates position sizing based on either fixed lot size or risk percentage of account balance.