Experts: Close all positions

 

Close all positions:

Closing positions when reaching a profit level

Author: Vladimir Karputov

 
Hi, can you please tell me if this profit is only the net worth to reach the target to close all positions?
 
opmopt :
Hi, can you please tell me if this profit is only NAV reaches the target Close all positions?

Closing positions when the profit level is reached Close all if Profit. In this case, the total profit for all positions is summed up: regardless of the symbol and magic number.

Profit is calculated only at the moment of the birth of a new bar.

 
Vladimir Karputov:

Closing positions when the profit level is reached Close all if Profit. In this case, the total profit for all positions is summed up: regardless of the symbol and magic number.

In this case the total profit for all positions is summed up: regardless of the symbol and magic number.

Hi, is it possible to change it so that all positions are closed when the NAV is greater than a certain value? Thank you.

 
opmopt :

Hi, is it possible to modify it so that all positions are closed when the NAV is greater than a certain value? Thanks.

Please read the description. When the profit of all positions reaches 'Close all if Profit', all positions are closed.

True, this is a very simple code and there is no 100% guarantee for closing all positions.

 
Vladimir Karputov:

Please read the description. When the profit of all positions reaches 'Close all if Profit', all positions are closed.

True, this is a very simple code and there is no 100% guarantee for closing all positions.

Can this code be written as an EA with automatic execution?

 
opmopt :

That can write this code as an auto-executing EA?

This is already an advisor.

 
Hello.
Can you revise the logic of calculating EA profit so that it is calculated only at the birth of a new bar and additionally on the "current bar"?
Because in large periods of time (H1, H2, H4, etc.) It is possible to instantly reach the target profit levels on the current bar.

Best regards.
 
Edviao:
Hello.
Can you revise the logic of calculating EA profit so that it is calculated only at the birth of a new bar and additionally on the "current bar"?
Because in large periods of time (H1, H2, H4, etc.) It is possible to instantly reach the target profit levels on the current bar.

Best regards.

Ok, I will add such an option. And additionally I will add an option for symbols: calculate profit and close positions only for the current symbol or for all symbols.

 
Vladimir Karputov :

Tamam, bunun gibi bir seçenek ekleyeceğğim. Ayrıca semboller için bir seçenek ekleyeceğim: sadece mevcut semboller için kar ve kapanış pozisyonlarınını hesaplayın.

Super!
The new features will make the EA much more flexible.
Thank you very much, ***.

NOTE:
For example, additional parameters could be:

Parameter A = profit calculation at "birth of a new bar".
Parameter B = "profit calculation on new bar + on current bar".
Обработчик события "новый бар"
Обработчик события "новый бар"
  • www.mql5.com
Для создателей индикаторов и экспертов всегда был актуален вопрос написания экономичного кода с точки зрения времени выполнения. Можно подойти к решению этой задачи с разных сторон. Из этой обширной темы в данной статье будет затронут, казалось бы уже решенный вопрос: проверка появления нового бара. Это достаточно популярный способ ограничения...
 
Edviao:


NOTA:
For example, additional parameters could be:

Parameter A = profit calculation at "birth of a new bar".
Parameter B = "calculation of profit on the new bar + on the current bar".

No, there are two parameters: the pause in seconds between profit calculation is set. If < '10' seconds - check ONLY at the moment of birth of a new bar, if >= '10' - then it is just a check interval in seconds.