ProfiGorex
- Experts
- Andrey Kozak
- Versão: 3.0
- Atualizado: 29 junho 2024
- Ativações: 20
General Information
- File Name: ProfiGorex.mql4
- Version: 1.00
- Description: A trading robot that uses the MACD indicator for market analysis and automated trading on the MetaTrader 4 platform. The robot includes risk management and trailing stop functionality.
Input Parameters
- LotSize: Lot size for opening positions (default is 0.01).
- MaxDrawdownPercent: Maximum allowable drawdown in percentage (default is 20.0%).
- TrailingStopPips: Number of pips for the trailing stop (default is 10 pips).
- DistancePips: Minimum distance in pips between orders (default is 20 pips).
- FastEMAPeriod: Fast EMA period for MACD (default is 12).
- SlowEMAPeriod: Slow EMA period for MACD (default is 26).
- SignalPeriod: Signal line period for MACD (default is 9).
- Max_spread: Maximum allowable spread for opening an order (default is 10 pips).
- Magic: Magic number for order identification (default is 777).
Main Functions
- OnTick: The main function executed on every tick. It analyzes the market condition, manages orders, and handles the trailing stop.
- OpenOrder: Opens a new order based on the current market condition and robot parameters.
- ManageTrailingStop: Manages the trailing stop for open orders.
- CloseAllOrders: Closes all open orders if the maximum allowable drawdown is reached.
- CheckDistanceToOrders: Checks the minimum distance to existing orders before opening a new one.
- GetLastOrderType: Determines the type of the last opened order.
- ErrorDescription: Describes errors that occur during trading.
- CheckVolumeValue: Checks the correctness of the lot volume.
- IsNewOrderAllowed: Checks if a new order can be opened.
- CheckStopLoss_Takeprofit: Checks the correctness of stop loss and take profit values.
Logic of Operation
- Account State Check: On each tick, it checks if there are sufficient funds to open new orders.
- MACD and EMA Analysis: Analyzes the current state of the MACD and EMA indicators to make buy or sell decisions.
- Risk Management: Checks the current drawdown and closes all orders if the allowable level is exceeded.
- Order Opening: Orders are opened when MACD and EMA conditions are met, along with the checks for minimum distance to other orders and allowable spread.
- Trailing Stop: Manages the trailing stop to minimize losses and protect profits.
Strategy Settings
- Timeframe: M5 (5-minute chart)
- Trading Instrument: GBPUSD
- Indicators:
- MACD:
- Fast EMA: 12
- Slow EMA: 26
- Signal Line: 9
- EMA:
- Fast EMA: 12
- Slow EMA: 26
- MACD:
Basic Concept
The ProfiGorex robot uses the MACD (Moving Average Convergence Divergence) and EMA (Exponential Moving Average) indicators for market analysis and determining entry and exit points. The primary goal of the strategy is to capture trend movements on the GBPUSD pair on the M5 timeframe while minimizing risks through drawdown management and trailing stop usage.
Conditions for Opening Trades
-
Opening a Buy Order (BUY):
- The main MACD line crosses the signal line from below.
- The fast EMA is above the slow EMA on the M1 timeframe.
- The current spread is less than or equal to the Max_spread value.
- The minimum distance from the current price to existing orders is checked: if there are no BUY orders within the DistancePips radius, a BUY order is opened.
-
Opening a Sell Order (SELL):
- The main MACD line crosses the signal line from above.
- The fast EMA is below the slow EMA on the M1 timeframe.
- The current spread is less than or equal to the Max_spread value.
- The minimum distance from the current price to existing orders is checked: if there are no SELL orders within the DistancePips radius, a SELL order is opened.
Risk Management
-
Maximum Drawdown:
- The robot continuously monitors the current drawdown of the account. If the drawdown exceeds the MaxDrawdownPercent value, all open orders are closed to prevent further losses.
-
Trailing Stop:
- After opening an order, the robot manages the trailing stop. If the price moves favorably, the stop loss is moved to a specified distance (TrailingStopPips) from the current price to protect profits.
Order Closing
- An order is closed when the trailing stop level is reached.
- An order can also be manually closed if the account drawdown exceeds the specified MaxDrawdownPercent value.
Additional Checks
- Volume Check: The robot checks that the lot size matches the minimum and maximum values allowed for the current instrument.
- New Order Allowance Check: Before opening a new order, the robot checks that the total number of orders on the account does not exceed the allowable limit.
Advantages of the Strategy
- Automation: Fully automated trading process that does not require trader intervention.
- Risk Management: Built-in risk management mechanisms such as maximum drawdown and trailing stop.
- Adaptability: Ability to adjust strategy parameters based on market conditions and trader preferences.
Recommendations
- Testing: It is recommended to test the robot on a demo account or in a strategy tester before running it on a real account to verify the effectiveness and correctness of the strategy.
- Monitoring: Despite automation, periodic monitoring of the robot's performance will help to make timely adjustments and avoid unforeseen situations.
This trading strategy is designed for use on the GBPUSD pair on the M5 timeframe, but it can be adapted for other currency pairs and timeframes with appropriate parameter adjustments.