Download MetaTrader 5

The variable don't loose its value

To add comments, please log in or register
Install apps from the library right in MetaTrader. It is easy!
24h-worker
86
24h-worker 2010.01.07 15:07 

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
86
24h-worker 2010.01.07 21:07  
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.  

To add comments, please log in or register