Работа завершена
![](https://c.mql5.com/i/avatar/avatar_na2.png)
![](https://c.mql5.com/i/avatar/avatar_na2.png)
Техническое задание
By default it contains 2 indicators that can be activated or deactivated with 2 buttons ( +1 virgin button that will be configured at a later time, when another EA that will have the function of generating signals will be terminated ) from outside:
- the first indicator is a 14-period RSI with levels of 70 and 30 as default (all 3 values can be configured externally as variables)
each time the market crosses these two levels inward, it opens up positions.
Example: the market is above the upper level (which in our example will be 70), going down it crosses it then opens a "SELL" order. Otherwise for the 30 that will open a "BUY" order.
-the second indicator instead works in the following way:
if there are "X" ticks in the upward market sequence then it buys, otherwise it sells.
example:
suppose that the value X is 4, and the market value is 1.3456, if the market value goes through the following steps: 1.3456, 1.3457, 1.3458, 1.3459 then it buys, proceeds in the opposite direction and sells. But if in the middle of the 4 values, even one goes in the opposite direction, then it does not open positions, and starts counting again until the desired scenario is found.
Once the position has been opened, it is expected that there is a positive profit and sets a trailing stop at a market price which, counting various commissions, overnight and spreads, has a positive value of at least "+0.01" as a profit. Practically the minimum level from which the trailing stop will start will guarantee a profit in any case.
for losing operations instead, I would like to be able to set a stop loss that will only work as an indicator to make the robot perform the following logic function:
if the loss is greater than equal to "X%" of the invested amount, then it performs an assessment for which:
if the amount in loss is less than equal to "X%" of the overall gain obtained up to that moment including all the operations carried out on all the markets, then it is closed.
Example:
I have closed 10 deals on 5 different markets to date. the total earnings are $ 10.
if the open loss operation is less than 20% (percentage value that can be entered from outside) of $ 10, then it is closed.
For subsequent loss-making operations, the new earnings will be calculated, corresponding to the remaining 80%. (I would like this last function to be activated or deactivated with an external button)
Example:
- I have earned $ 10 from various operations, a loss operation is closed which is within 20% of $ 10, which is equal to $ 2. There remains $ 8 of profit, which if this function is activated, will be set aside and not counted for the next loss-making operations. In short, for each closed loss operation I will guarantee myself the remaining 80%.
If, on the other hand, it is greater, it is left open until this condition occurs. if, on the other hand, the loss exceeds the second level preset by the external with a percentage of the investment of that operation, then a notification is generated and an email is sent to an address that is entered from outside.
If it is greater than the previous percentage entered, then it is kept open, the operation remains open until this condition occurs. But if this loss-making operation reaches a second level that indicates a greater loss indicated with a percentage of the investment of this operation (variable configurable from outside), a warning notification is generated and an e-mail is sent to an address that can be entered from outside.
I would like it to open trades whenever it receives a signal from the indicator. it does not have to wait for the previous operation to be closed before opening the next one.
On the other hand, regarding the amount to invest for the various operations, I would like a certain percentage of my portfolio to be used (percentage value that can be configured from outside), and to be able to configure a second percentage value that can be configured from outside to adjust the amount of each individual operation. Example:
- my wallet is $ 1000
- I want to use only 50% for the opening of the various orders (value configurable from outside) ----- 1000 $ - 50% = 500 $
- the maximum investment amount for each operation is 5%, or in any case the purchasable microlot that has an amount lower than 5% (value configurable from outside) ----- 500 $ / 100 = 5 $ ___ 5 $ x 5 = $ 25
Obviously I will need the source code of both EAs.