Total profit for orders with same magic number?

 

Guidance needed as I cannot figure out code for looking at total profit value for specific orders in order pool.

Looks like my piece of code is too far off..can someone push me to right direction

//--orders profit/loss with magic
int      Total=OrdersTotal();
double   bProfit=OrderProfit();
double   sProfit=OrderProfit();

if(Total>0 && kill==0)
{
   for(int dollar=Total-1;dollar>=0;dollar--)
   {
      if(!OrderSelect(dollar,SELECT_BY_POS,MODE_TRADES))continue;
      {
         if(OrderMagicNumber()==bMagic)
         {
         sProfit++;
         }
         if(OrderMagicNumber()==sMagic)
         {
         bProfit++;
         }
      }
   }
}
//--end (orders profit/loss with magic)
 
elanin:

Guidance needed as I cannot figure out code for looking at total profit value for specific orders in order pool.

Looks like my piece of code is too far off..can someone push me to right direction

Try . . .

sProfit += OrderProfit();
 
RaptorUK:

Try . . .

 


Tried and it works..thank you RaptorUK!
 
int      Total=OrdersTotal();
double   bProfit=OrderProfit();
double   sProfit=OrderProfit();
You can't call OrderProfit() unless you do a OrderSelect first.
 
ho, dont forget to calculate OrderSwap() & OrderCommission() 2
Reason: