View Single Post
  #7 (permalink)  
Old 01-15-2007, 10:53 PM
ralph.ronnquist's Avatar
ralph.ronnquist ralph.ronnquist is offline
Senior Member
 
Join Date: Oct 2006
Posts: 280
ralph.ronnquist is on a distinguished road
dreaded multithreading

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 * ( 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".
Reply With Quote