Tâche terminée
Spécifications
I need trading robot that my strategy is applied circularly to each new position in a nested loop.
The EA should be coded by MQL5 language
Please deliver the source code with comments.
In summary, the EA should be
_ Place Buy/Sell order when multiple conditions are met:
_ Edit/Cancel order if multiple conditions are met
_ Set stop loss and take profit
_ Check current positions
_ Support the following input settings
0 DEFAULT_VOLUME 10
1 FIRST_ORDER_WAIT_TIME default 5m.
2 FIRST_ORDER_DIRECTION enum [buy, sell].
3 FISRT_STOP_LOSS_PIPS INT DEFAULT -100
4 FISRT_TAKE_PROFIT_PIPS INT DEFAULT 200
5 EDIT_ORDER_BY_PROFIT_PIP_SIGNAL INT DEFAULT 50
6 EDIT_ORDER_BY_LOSS_PIP_SIGNAL IN DEFAULT -50
7 SECOND_STOP_LOSS_PIPS INT DEFAULT 10
8 SECOND_TAKE_PROFIT_PIPS INT DEFAULT 300
9 THIRD_STOP_LOSS_PIPS INT DEFAULT -200
10 THIRD_TAKE_PROFIT_PIPS INT DEFAULT 1
11 MAXIMUM_POSITION 100
12 RISKY_BALANCE =5000
The details of the schedule of my strategy are as the following.
1.1.1 start the robot.
1.2.1 wait for FIRST_ORDER_WAIT_TIME
1.3.1 open a position with the DEFAULT_VOLUME volume in the FIRST_ORDER_DIRECTION immediately
1.3.2 the position should have a stop loss order and a take profit order immediately
1.3.3 the destination price of a stop loss order is away from the position price with a specified number of points which equals the FISRT_STOP_LOSS_POINTS in the loss direction
1.3.4 the destination price of a take profit order is away from the position price with a specified number of points which equals the FISRT_TAKE_PROFIT_PIPS in the profit direction
2.1.1 if the price moves in the profit direction and the price is away from the position price with a specified number of points which equals the EDIT_ORDER_BY_PIP_SIGNAL, then edit the orders related current the position
2.1.2 Edit the stop loss order with the SECOND_STOP_LOSS_PIPS
2.1.2 Edit take profit order with the SECOND_TAKE_PROFIT_PIPS
2.1.3 Immediately, open a same direction position with the DEFAULT_VOLUME volume, and this new position should also abide by my entire strategy.
3.1.1 if the price moves in the loss direction and the price is away from the position price with a specified number of points which equals the EDIT_ORDER_BY_LOSS_PIP_SIGNAL, then edit the orders related current the position
3.1.2 Edit the stop loss order with THIRD_STOP_LOSS_PIPS
3.1.2 Edit take profit order with the THIRD_TAKE_PROFIT_PIPS
3.1.3 Open an opposite hedged position with the DEFAULT_VOLUME volume immediately, and new this position should also abide by my entire strategy.
4.1.1 Execute the following position management:
4.1.2 Check the balance of the account if it is bigger than RISKY_BALANCE. If not, prohibit opening any new position.
4.1.3 Check the volume of the account if it is bigger than MAXIMUM_POSITION. If so, prohibit opening any new position.
5.1.1 Make sure each new position should be opened by the above strategy. No matter the first position or the position which is opened in the process of my strategy.
5.1.2 Make sure the entire strategy is applied circularly to each new position in a nested loop.
6.1.1 This strategy can use for any symbol.