MQL5- Loop to check if position is profiting or losing?

MQL5- Loop to check if position is profiting or losing?

How to look for profiting and looking positions?

Returning the ticket/deal numbers

Why MQL5. Metatrader 5 is dead in the water IMHO.

MT5 is not dead in the water.


#include <Trade\PositionInfo.mqh>
CPositionInfo m_position;

for(int i=PositionsTotal()-1;i>=0;i--) // returns the number of open positions
      if(m_position.SelectByIndex(i))
         if(m_position.Symbol()==Symbol() && m_position.Magic()==m_magic)
            double profit = m_position.Profit();