Experts: Daily Loss Guard

Daily Loss Guard:

Closes all trades when your daily loss reaches your limit.

Daily Loss Guard

Author: Themistokli Kola

Automated-Trading:

Daily Loss Guard:

Author: Themistokli Kola

A daily loss limit looks simple, but the definition decides everything. Some questions that usually matter:

Is the limit measured on equity (including floating loss) or on closed P/L only, and relative to the balance or equity at the start of the day, or to the day’s peak?

Which clock defines “day”: server midnight, broker rollover or a fixed time zone?

After the close-all, what stops the EA, or you, from opening new positions, and what happens to pending orders that could fill later? And if a close fails (requote, market closed, freeze level), is it retried?

It would help to document these points in the description so users know exactly which rule they are getting.

Thanks!

Eduardo Cumplido #:

A daily loss limit looks simple, but the definition decides everything. Some questions that usually matter:

Is the limit measured on equity (including floating loss) or on closed P/L only, and relative to the balance or equity at the start of the day, or to the day’s peak?

Which clock defines “day”: server midnight, broker rollover or a fixed time zone?

After the close-all, what stops the EA, or you, from opening new positions, and what happens to pending orders that could fill later? And if a close fails (requote, market closed, freeze level), is it retried?

It would help to document these points in the description so users know exactly which rule they are getting.

Thanks!

Thanks Eduardo, good questions. How it works now:
1. The loss is today's closed P/L plus the change in floating P/L since the day started, counting only the trades the filters select (symbols, magic). In % mode the limit is a % of the day-start balance. It is not measured from the day's peak.
2. The day follows server time and starts at the hour set in "New day starts at" (default 0 = server midnight).
3. When the limit is hit it closes positions and deletes pending orders (each can be switched off). Until the next day, any new position or order that matches the filters is closed or deleted as soon as it appears. It can't stop an order being sent, it removes it right after.
4. A failed close or delete (requote, market closed, freeze level) is retried every 30 seconds and logged once with the return code.

I'll add these rules to the description in the next update.