What happens after manual closing?

 

Hi,

After manually closing a trade what will happen? Will it go to init(), or start(), will it go to deinit() ?

 

Assuming this is a trade from an EA.... closing it manually should not impact your EA at all.... it will stay in start() and just wait for the next tick. Obviously, if there are sections of the EA that do specific actions when it closes a trade, then they will not be executed.

V

 

If the EA does a OrderSelect(ticket) that will fail and hopefully the EA is coded to handle it (TP/SL condition.)

If the EA does a for(OrderCount) OrderSelect(position) it won't find it open and will do what ever it normally does when orders close.

If the EA is coded badly, assumes things, doesn't test for error returns, then you may get errors reported, then again may be not reported.

In any case that's all through the start() on the next tick.

 

Thanks for reply.

I am asking this because I have a

bool Var = false;

in the global scope, and in start() after a trade succesfully sent the Var is turned to TRUE (I did a debug using Print() and checked that it actually changes to TRUE), the problem is that after manual clossing of the trade the Var is back to FALSE, is that making any sense ? Or am I missing something ?

 

It will depend where / how you are declaring and setting the variable. If it is declared inside start(), it will need to be static to hold the true value. If it is set by something like OrdersTotal(), then that will impact it. Would need to see more code to advise further.

V

 
Viffer:

It will depend where / how you are declaring and setting the variable. If it is declared inside start(), it will need to be static to hold the true value. If it is set by something like OrdersTotal(), then that will impact it. Would need to see more code to advise further.

V


as I said, it is declared in the global scope, the static thing will solve the problem, thanks.
 
global scope and static are equivalent.
Reason: