The variable don't loose its value

 

I try to manage a few EA parallel for different currencies.

 

I want to know, whether the position earns money: 

        PositionSelect("USDCHF",1000);
        double USDCHF_Saldo = PositionGetDouble(POSITION_PROFIT);

 

After the Position is closed the variable "USDCHF_Saldo"  is not Null and behave as if the position is still open.

That's a mirracle, because after each tick (or one second) the EA should generate a new value. 

How can I recognize , whether a position is actuall running or closed ? 

 
24h-worker :

I try to manage a few EA parallel for different currencies.

 

I want to know, whether the position earns money: 

        PositionSelect("USDCHF",1000);
        double USDCHF_Saldo = PositionGetDouble(POSITION_PROFIT);

 

After the Position is closed the variable "USDCHF_Saldo"  is not Null and behave as if the position is still open.

That's a mirracle, because after each tick (or one second) the EA should generate a new value. 

How can I recognize , whether a position is actuall running or closed ? 

 

 


I have found a solution for me:

        bool ok = PositionSelect("EURUSD",1000);
        double EURUSD_Saldo = PositionGetDouble(POSITION_PROFIT);  
        if(ok == false) { EURUSD_Saldo=0; } 

PositionGetDouble returns values, but as PositionSelect will not find any open Position,

the Profit will turn to 0.  

Reason: