Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1510

 
Denis Karavaev #:

You calculate "profit on open positions on symbol and majic", for example in total now 10$ on eurobucks. balance 1100.

If the percentage > 1, close all positions on the symbol.

In this case, the other symbols, which are in minus by 1%, will not let the symbol, which is in plus by 1%, close. As I understand it, it is necessary to make a decoupling from the balance and equity of the account and create additional variables and for each symbol in them to keep a separate account of equity and balance. I can't quite imagine how the code should be, please write an example of how it should be, so that everything works and symbols do not interfere with each other.

 
R3008 #:
As I understand it, you have to do a balance check.

Why would you do that?

The balance is static. Only equity floats.

So if you didn't close the minus, for example 10% of 1100 =110 usd.

you're still waiting for a profit of 11usd to close the eurodollar.

Here's a counter question. Do you know how to calculate the profit on open positions with the Magic, Symbol filter?

 
Denis Karavaev #:

Why?

The balance is static. Only equity floats.

So if you did not close the minus, for example 10% of 1100 =110 usd

you're still waiting for a profit of 11usd to close the Eurodollar.

Here's a counter question. Do you know how to calculate the profit on open positions with the Magic, Symbol filter?

What if some other symbol closes a position?

 
Alexey Viktorov #:

What if some other character closes the position?

Balance 1100.

euric +10

Franc -110. Just closed.

Balance 990.

Checking the eurik on ticks. Balance 990 , 1% = 9.9 . Profit 10. Closing the euric profits.

Let's keep going. How much is our balance? And how much is 1% of it?

And so in a loop of open positions.

 
Denis Karavaev #:

Balance 1100

eurik +10

franc -110. just closed.

Balance 990

Checking the eureka on ticks. Balance 990 , 1% = 9.9 . Profit 10. Closing the eurik profit

Let's keep going. How much is our balance? And how much is 1% of it?

And so in a cycle of open positions.

And if we closed +110, then where do we count from? We were waiting for +11, and now we will wait for 12.1... Then we will close more and more... This is one variant... This is one variant...

And if the current profit is only 7, and closed with a loss of -400... Then you don't need more????

You have each formula for one case of life. And there are quite a lot of them...

 
Alexey Viktorov #:

And if we closed +110 then where do we count from? We were waiting for +11, and now we will wait for 12.1... Further it will close more and more... This is one option... This is one option...

And if the current profit is only 7, and closed with a loss of -400... Then it turns out there is no need for more????

You have each formula for one case of life. And there are quite a lot of them...

That's right, look at the T.Z."prescribe the code of closing profit of each currency pair separately in per cent of the balance, if several pairs work on the account simultaneously. "

If you need another option. Fix.

- then we put BalanceBasic = 1000 in Input. And dance from this figure.

Another variant with balance steps. Balance step 1000. We store the knee in the global system. Until we exceed 2k. We use 1000 in calculations.

Current balance has exceeded 2k. Use roveo 2k in calculations. Then the same, etc.

I will code what you want )

 
Denis Karavaev #:

That's right, see the TOR."specify the code for closing profit of each currency pair separately in per cent of the balance, if several pairs are working on the account simultaneously. "

If a different option is needed. Fix.

- we put BalanceBasic = 1000 in Input. And dance from this figure.

Another variant With balance steps. Balance step 1000. We store the knee in the global system. Until we exceed 2k. We use 1000 in calculations.

Current balance has exceeded 2k. Use roveo 2k in calculations. Then the same, etc.

What you want I will code )

With steps will be an interesting variant, code it if you don't mind.

 
R3008 #:

The steps would be an interesting option, code it up if you don't mind

With pleasure, leave a request for freelancing

 
Denis Karavaev #:

It would be my pleasure, leave a freelance submission

Thanks, but a code example within this branch will suffice for me

 
Denis Karavaev #:

That's right, see the TOR."specify the code for closing profit of each currency pair separately in per cent of the balance, if several pairs are working on the account simultaneously. "

If a different option is needed. Fix.

- we put BalanceBasic = 1000 in Input. And dance from this figure.

Another variant With balance steps. Balance step 1000. We store the knee in the global system. Until we exceed 2k. We use 1000 in calculations.

Current balance has exceeded 2k. Use roveo 2k in calculations. Then the same, etc.

What you want I will code )

I would like it to be calculated from the current balance without steps and other nonsense at any moment, regardless of the profit/loss made by other Expert Advisors.

Reason: