Experts: Prop-Firm Equity Guard - daily and max drawdown protection (FTMO-style)
Nice concept, but there's a state-loss bug that undermines the "permanent" MAX-breach guarantee: OnInit() unconditionally calls GlobalVariableSet(InpHaltFlagName, 0.0) (line 81), and g_maxBreached/g_dailyBreached are plain in-memory bools with no persistence — nothing reads them back in OnInit. So the very first EA restart after a breach (VPS reboot, terminal update, recompile, manual re-attach — routine on a prop-firm VPS) clears the halt flag and re-snapshots the day-start baseline from whatever equity is left, even after a MAX drawdown breach the doc describes as blocking trading "permanently." The account gets unblocked exactly where it was mid-blown, with a fresh (lower) starting point.
Simple fix: persist g_maxBreached (and ideally g_dailyBreached) to a GlobalVariable or file, and have OnInit() check it before ever writing 0.0 to the halt flag — treat "was this account already halted" as state to restore, not state to re-derive from zero on every restart.
Nice concept, but there's a state-loss bug that undermines the "permanent" MAX-breach guarantee: OnInit() unconditionally calls GlobalVariableSet(InpHaltFlagName, 0.0) (line 81), and g_maxBreached/g_dailyBreached are plain in-memory bools with no persistence — nothing reads them back in OnInit. So the very first EA restart after a breach (VPS reboot, terminal update, recompile, manual re-attach — routine on a prop-firm VPS) clears the halt flag and re-snapshots the day-start baseline from whatever equity is left, even after a MAX drawdown breach the doc describes as blocking trading "permanently." The account gets unblocked exactly where it was mid-blown, with a fresh (lower) starting point.
Simple fix: persist g_maxBreached (and ideally g_dailyBreached) to a GlobalVariable or file, and have OnInit() check it before ever writing 0.0 to the halt flag — treat "was this account already halted" as state to restore, not state to re-derive from zero on every restart.
Nice concept, but there's a state-loss bug that undermines the "permanent" MAX-breach guarantee: OnInit() unconditionally calls GlobalVariableSet(InpHaltFlagName, 0.0) (line 81), and g_maxBreached/g_dailyBreached are plain in-memory bools with no persistence — nothing reads them back in OnInit. So the very first EA restart after a breach (VPS reboot, terminal update, recompile, manual re-attach — routine on a prop-firm VPS) clears the halt flag and re-snapshots the day-start baseline from whatever equity is left, even after a MAX drawdown breach the doc describes as blocking trading "permanently." The account gets unblocked exactly where it was mid-blown, with a fresh (lower) starting point.
Simple fix: persist g_maxBreached (and ideally g_dailyBreached) to a GlobalVariable or file, and have OnInit() check it before ever writing 0.0 to the halt flag — treat "was this account already halted" as state to restore, not state to re-derive from zero on every restart.
Prop-Firm Equity Guard - daily and max drawdown protection (FTMO-style):
Account-level protection utility for prop-firm challenges: daily and max drawdown limits with a safety buffer. Closes all positions and raises a global halt flag other EAs can check.
Author: Cristian Ciunae