Perhaps it's too unikely to happen, but there is a small worry in picking up AccountBalance() two times, beacuse it is possible that the balance changes in between them. The point is that the balance can be affected by other execution threads than the one processing the EA. The following would be a variation to avoid the worry:
PHP Code:
bool drawdown(double maxdrawdownpercent)
{
if ( AccountEquity < AccountBalance * ( 1 - maxdrawdownpercent ) )
{
return( true );
}
return( false );
}
Then there is a similar thread race between reading off the balance and reading off the equity, but that race cannot be avoided. At best you could define which order to read them off in, but I'm not sure the one order is any better than the other in respect of possibly return "wrong result".