I'd like to access information about a Open Position.

 

Hello,

I'd like to access information about an Open Position. In particulat the floating Profit/Loss value.

Is there a command available to do that?

Thanks for your help.

 
JuergZimmermann:
In particulat the floating Profit/Loss value.
    for(pos = OrdersTotal()-1; pos >= 0 ; pos--) if (
        OrderSelect(pos, SELECT_BY_POS)                 // Only my orders w/
    &&  OrderMagicNumber()  == magic.number             // my magic number
    &&  OrderSymbol()       == Symbol() ){              // and my pair.
        Print("Order ",OrderTicket()," has profit of ",OrderProfit());
    }
 
WHRoeder:


Thanks for your help'.
 

That one problem i post to you about is still there with my EA

Please can you or anybody in this forum help and give me the right code for solving the situation below:

1. my EA trade very good but it open a new position immediately after taking profit even if the market is going other way.

2. i want a code that will not allow two same order-type from following each other after taking profit.( once it takes profit for example on buy trade, it should wait for next sell signal before opening new position for that same symbol)


i used OrderHistoryTotal but i did not get the right coding.

 
    datetime lastClose;  int lastOP;
    for(int pos=0; pos < HistoryTotal(); pos++) if (
        OrderSelect(pos, SELECT_BY_POS, MODE_HISTORY)   // Only orders w/
    &&  OrderCloseTime()    > lastClose                 // not yet processed,
    &&  OrderMagicNumber()  == magic.number             // my magic number
    &&  OrderSymbol()       == Symbol()                 // and my pair.
    &&  OrderType()         <= OP_SELL){    // Avoid cr/bal forum.mql4.com/32363
        lastClose = OrderCloseTime(); lastOP = OrderType();
   }