EvolutionaryTrader
- 专家
- Dipak Dilip Reddy
- 版本: 3.4
The provided code is an example of an Expert Advisor (EA) written in MQL5, a programming language used for creating algorithmic trading systems in MetaTrader 5. Here is a breakdown of the code:
The code begins with various input parameters and settings defined using the input keyword. These parameters allow customization of the EA's behavior, such as entry lots, stop loss, take profit, and indicator parameters.
Several constant values and variables are declared, including session time settings, position-related variables, bar-related variables, and indicator handlers.
The OnInit() function is called during the EA's initialization. It sets up various variables and indicators required for the EA's operation.
The OnTick() function is executed on every tick received by the EA. It checks if a new bar has formed and calls the OnBar() function accordingly.
The OnBar() function is responsible for managing the EA's logic on each new bar. It updates the position, checks for session close conditions, manages position closure, trailing stop, and determines entry signals for opening new positions.
The UpdatePosition() function retrieves information about the current open position, such as position type, ticket, lots, stop loss, and take profit.
The InitIndicators() function initializes the required indicators for the EA. In this example, it adds two indicators: RSI and Standard Deviation.
The GetEntrySignal() function calculates the entry signal based on the defined indicators and their respective parameters. It determines whether to open a buy, sell, or no position (OP_FLAT).
The ManageClose() function checks if the conditions for closing an open position are met. In this case, it checks for a specific condition related to the Standard Deviation indicator.
The OpenPosition() function opens a new position based on the provided command (buy or sell). It calculates the stop loss and take profit prices based on the input parameters and calls the ManageOrderSend() function to execute the trade.
The ClosePosition() function closes the currently open position by executing an opposite trade.
The ManageOrderSend() function handles the order sending process. It attempts to send the order multiple times and waits for a certain duration between retries. It checks if the trade context is free, performs order checks, and sends the order using the OrderSend() function. It also handles the case when the order filling mode needs to be changed.
The remaining functions ModifyPosition(), CheckOrder(), GetStopLossPrice(), GetTakeProfitPrice(), GetTrailingStopPrice(), and ManageTrailingStop() are responsible for modifying positions, checking orders, calculating stop loss/take profit prices, and managing the trailing stop functionality.
The code also includes the OnDeinit() function, which is called when the EA is removed or reloaded from the chart. It cleans up any indicators added to the chart by deleting them.
Preferred: USDCAD H1
Preferred brokers: Octafx incorporated.
I have been using EA for 2 weeks and it gives quite a lot of income. It's coming along well. Will post an update in a few weeks.
Profitable EA
From July 15 to August 1 account grow up 29.92%
7 trades 100% win.