Cannot detect value of Profit

 

Hi,

I trying the get the value of negatif profit using POSITION_PROFIT but the result show the positif value.

 

//+------------------------------------------------------------------+
//|                                                           rt.mq5 |
//|                        Copyright 2013, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(0);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
 int ii;
 for(ii=0;ii<PositionsTotal();ii++)
     
          {
                       
          PositionSelect(PositionGetSymbol(ii));
          if(PositionGetSymbol(ii)==_Symbol)
            {
              if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_SELL && PositionGetDouble(POSITION_PROFIT)<=-300)
              {
              Print("Profit Now ",POSITION_PROFIT);
              }     

            }
          }
 
  }
//+------------------------------------------------------------------+

 

But the result

2013.03.12 13:37:12 rt (EURUSD,M30) Profit Now 10

Anybody can tell me what wrong? or my coding wrong?

tq 

 
jelam:

Hi,

I trying the get the value of negatif profit using POSITION_PROFIT but the result show the positif value.

 But the result

2013.03.12 13:37:12 rt (EURUSD,M30) Profit Now 10

Anybody can tell me what wrong? or my coding wrong?

tq 

Shouldn't it be this ?

Print("Profit Now ", PositionGetDouble(POSITION_PROFIT) );
 
RaptorUK:

Shouldn't it be this ?

I believe RaptorUK is correct. Strange thought that POSITION_PROFIT initializes as 10 :)

Br, Candles

EDIT: OK, all of the ENUM_POSITION_PROPERTY_DOUBLE have initial integer  values. Probably has some deeper meaning which I cannot understand :)

My apologies for the OT.

 
Candles:

I believe RaptorUK is correct. Strange thought that POSITION_PROFIT initializes as 10 :)

Br, Candles

EDIT: OK, all of the ENUM_POSITION_PROPERTY_DOUBLE have initial integer  values. Probably has some deeper meaning which I cannot understand :)

My apologies for the OT.

POSITION_PROFIT is from an ENUM and is an integer constant.

PositionGetDouble(POSITION_PROFIT) is a function that return a double and take an ENUM (integer with limited dataset) as parameter.

Nothing with "some deeper meaning" here.

 
RaptorUK:

Shouldn't it be this ?

Thank RaptorUK for your advise. It work now.

Reason: