What was my worst loss in a day?

 

I want to put a cap on losses before I turn off the EA to avoid further damage on a clear bad day. Do you think this is the correct way to do it?


starting up:

double TodaysEquity = AccountEquity();
double InitialEquity = AccountEquity();
double TodaysLoss;
double WorstLoss;
int    Today;
int    Yesterday;


the function:

void CheckEquity()   {
   if (AccountEquity() < LowestEquity) {
      LowestEquity = AccountEquity();
      TodaysLoss = (TodaysEquity - LowestEquity);
   }
   
   if (TodaysLoss > WorstLoss)   {
      WorstLoss = TodaysLoss;
      string Date = IntegerToString(Year()) + "-" + IntegerToString(Month()) + "-" + IntegerToString(Day());
      LogText = Date + " ticket: " + orderTicket1 + " TodaysEquity: " + TodaysEquity + " Lowest equity: " + LowestEquity + ", TodaysLoss: " + TodaysLoss + ", Worst: " + WorstLoss;
      LogAppend("WatchEquity.txt", LogText);
   }
   if (Today != Yesterday)  {TodaysEquity = AccountEquity(); LowestEquity = AccountEquity();}
}


in loop:

Today = Day();
CheckEquity();
Yesterday = Today;

...trading code: open, close, etc.


Of course, you can't see the LogAppend function's body here, but that is irrelevant. It just writes to a file.


It looks correct to me, however, the log tells me that the biggest loss in a day was:

2022-10-6 ticket: 23 TodaysEquity: 115.467 Lowest equity: 110.785, TodaysLoss: 4.68, Worst: 4.68


Looking at the StrategyTester report, I can't find that loss.

In the "Chart" session, there seems to be a small dip of only $1.7 on 2022-10-6.

In the "Results" section, I did find two losses on 2022-10-6: -1.65 + -1.68 = -3.33.

But those are orders number 21 and 22, not 23. Off by one? Maybe, but that is still a little far from 4.68.

You may think that either trade closed at only -1.6 but probably dipped further than -1.6 before closing. But my stoploss wouldn't let them dip that far. My stoploss is set at -2.0. Two losses of -2.0 would be -4.0, not 4.68.

Order 23 profits 2.36 and order 24 loses 1.69.

What do you gentlemen think?