here are some other examples of information you can get about a position:
#define xPOSITION_COMMENT (PositionGetString(POSITION_COMMENT))
#define xPOSITION_SYMBOL (PositionGetString(POSITION_SYMBOL))
#define xPOSITION_EXTERNAL_ID (PositionGetString(POSITION_EXTERNAL_ID))
#define xPOSITION_TYPE (PositionGetInteger(POSITION_TYPE))
#define xPOSITION_MAGIC (PositionGetInteger(POSITION_MAGIC))
#define xPOSITION_OPENTIME (PositionGetInteger(POSITION_TIME))
#define xPOSITION_TICKET (PositionGetInteger(POSITION_TICKET))
#define xPOSITION_IDENTIFIER (PositionGetInteger(POSITION_IDENTIFIER))
#define xPOSITION_PRICE_OPEN (PositionGetDouble(POSITION_PRICE_OPEN))
#define xPOSITION_PRICE_CURRENT (PositionGetDouble(POSITION_PRICE_CURRENT))
#define xPOSITION_PROFIT (PositionGetDouble(POSITION_PROFIT))
#define xPOSITION_PROFIT_LIQUID (PositionGetDouble(POSITION_PROFIT)+PositionGetDouble(POSITION_SWAP))
#define xPOSITION_SL (PositionGetDouble(POSITION_SL))
#define xPOSITION_TP (PositionGetDouble(POSITION_TP))
#define xPOSITION_SWAP (PositionGetDouble(POSITION_SWAP))
#define xPOSITION_VOLUME (PositionGetDouble(POSITION_VOLUME))
#define xPOSITION_ELAPSEDTIME (TimeCurrent()-PositionGetInteger(POSITION_TIME))
#define xPOSITION_TYPE_STRING ((PositionGetInteger(POSITION_TYPE)) ? "Sell" : "Buy ")
#define xPOSITION_TICKVALUE (SymbolInfoDouble(_Symbol,SYMBOL_TRADE_TICK_VALUE))
#define xPOSITION_SPREAD (SymbolInfoInteger(_Symbol,SYMBOL_SPREAD))
#define xMARKET_PIPVALUE (SymbolInfoDouble(_Symbol,SYMBOL_TRADE_TICK_VALUE))
First select any position with:
PositionGetTicket(i);
Then you have access to every info about it using my definitions above.
// ---
if (xPOSITION_TYPE == POSITION_TYPE_SELL) {
ProftInPoints = (int)NormalizeDouble( xPOSITION_PRICE_OPEN/_Point
- xPOSITION_PRICE_CURRENT/_Point
,0);
} else if (xPOSITION_TYPE == POSITION_TYPE_BUY) {
ProftInPoints = (int)NormalizeDouble( xPOSITION_PRICE_CURRENT/_Point
- xPOSITION_PRICE_OPEN/_Point
,0);
}
double profit_money = xPOSITION_PROFIT;
double profit_points = ProftInPoints;
double position_lots = xPOSITION_VOLUME;
// etc.. etc etc..