Trabalho concluído
Termos de Referência
Hi, I've developed an Fratile brake and retest EA. I have not been able to backtest it since i cant get it to work. I need your help in checking the code and making sure that the code is intact and all functions will work as they are or perhaps add your improvements. Please see a detailed description of the EA below. Reachout to me and i will provide you with the full code.
Fractal Breakout EA Overview
The Fractal Breakout EA is designed to execute trades based on fractal breakouts on specified timeframes. It utilizes fractals to identify potential breakout points and enters trades when prices retest these levels. The strategy is enhanced with several risk management and trading optimization features like martingale, trailing stops, and the ability to manage multiple entries per signal.
Inputs and Settings
- StopLossPips and TakeProfitPips: Define the stop loss and take profit settings in pips.
- InitialLotSize: Initial lot size for the first trade.
- MartingaleFactor: Factor by which the lot size increases following a loss if the martingale feature is active.
- UseMartingale: Boolean to activate/deactivate the martingale feature.
- ClosePrevious: Boolean to determine whether to close previous trades when a new trade is opened.
- UseAutoLot: Enables automatic lot size calculation based on account balance and risk.
- RiskPercentage: Percentage of account balance risked per trade.
- MaxEntriesPerSignal: Maximum number of concurrent entries allowed per trading signal.
- TradingStartTime and TradingEndTime: Define the start and end times for trading to avoid low liquidity periods.
- ProfitPipsForAdditionalEntries: Number of pips in profit required to trigger additional entries.
- TrailStopStart and TrailStopDistance: Settings for the trailing stop feature.
Key Components
- CFractals: A fractal indicator used to determine the fractal highs and lows around which trading decisions are made.
- CTrade: An object to handle trade operations.
- cumulativeLoss and martingaleActive: Variables to manage the state and calculations related to the martingale feature.
Functions
- OnInit(): Initializes the EA, sets up the fractal indicator, and starts a timer for periodic execution of the trading logic.
- OnTimer(): Main function called at regular intervals to check trading conditions based on the current market data and system settings.
- ProcessEntries(): Processes trading signals based on fractal data and current price action, managing trade entries and exits.
- PlaceTrade(): Executes trade entries for buy or sell based on signal conditions.
- UpdateTrailingStop(): Adjusts the stop loss dynamically as the trade moves into profit to protect gains.
- CheckForAdditionalEntries(): Evaluates conditions for making additional entries when a trade is in profit.
- AdjustLotSize(): Adjusts the trading lot size according to the martingale strategy or resets it based on the strategy settings.
- CalculateLotSize(): Calculates the lot size based on the risk percentage and account balance.
- CheckMartingaleCondition(): Adjusts the martingale strategy based on the outcome of the last trade.
- OnDeinit(): Cleans up resources when the EA is removed from the chart or the chart is closed.
Strategy Logic
- Fractal Detection: Uses fractals to detect significant breakout levels.
- Trade Execution: Enters trades when prices retest the detected fractal levels from the correct direction.
- Risk Management: Implements a trailing stop loss and a martingale feature for loss recovery.
- Additional Entries: Opens additional trades in profitable conditions to maximize gains.
Visual Features
The EA includes visual components on the chart that display:
- Current total funds.
- Number of open trades.
- Daily profits and losses.
These features provide real-time insights into the EA's performance and help monitor trading activities directly on the chart.