I'm trying to subtract my profits and add my losses, would this work?

To add comments, please log in or register
Graham Pace
189
Graham Pace  

I'm trying to write a code that will make a "Profit Target" which will subtract my profits in the past 24 hours and add my losses. But I think there is something wrong, can anyone help?


int ProfitTarget = 1000

{
  for(int q = 0; q<OrdersHistoryTotal(); q++)
   {
     OrderSelect(q,SELECT_BY_POS,MODE_HISTORY);
     if(OrderCloseTime()>TimeCurrent()-86400)
      {
        ProfitTarget+OrderProfit();
      }
   }
}
Mehmet Bastem
1780
Mehmet Bastem  
int ProfitTarget = 1000;
  double TotalProfit=0;

  {
  for(int q = 0; q<OrdersHistoryTotal(); q++)
   {
     OrderSelect(q,SELECT_BY_POS,MODE_HISTORY);
     if(OrderCloseTime()>TimeCurrent()-86400)
      {
        TotalProfit=TotalProfit+OrderProfit();
      }
   }
   Print(" Daily Profit: "+ProfitTarget-TotalProfit);
}
To add comments, please log in or register