AccountFreeMarginCheck returning positive value, then OrderSend failing because of money

 

Hello,

I'm a bit puzzled by AccountFreeMarginCheck sending an OK (positive value), but then OrderSend not being able to open the order because there's not enough money. Long story short, I'm testing an EA with $1 balance, and before calling OrderSend I'm running some checks on spread, correctness of volumne, max orders, etc, and where I'm truly expecting an error returned is in the FreeMarginCheck, so that I don't call OrderSend. This is the part of the code where I call OrderSend with a couple of "prints":

// OrderSend Checks
   ResetLastError();
   rc = RunChecksBeforeOrderSend(Symbol(), pType, normVolume);
   Print("RC ", rc);
   if(rc == ERR_NO_ERROR) {
         // *** ORDERSEND ***
         Print("ABOUT TO EXEC ORDERSEND");
         tkt = OrderSend(Symbol(), pType, normVolume, normPrice, normSlippage, 0, 0, pComment, INP_magicNumber, 0, clrNONE);
         if(tkt == TKT_ERR)
            Print("ERROR");


...so as you can see before calling "OrderSend" I run some checks in "RunChecksBeforeOrderSend" I send the current symbol, operation type and volume already normalized, and I call OrderSend ONLY if rc is zero. Now this is the part in "RunChecksBeforeOrderSend":

// *** TRADE SERVER RETURN CODES ***
// Free margin
   double freeMargin = AccountFreeMarginCheck(pSymbol, pType, pVolume);
   Print("FREE MARGIN ", freeMargin);
   if(freeMargin <= 0)
      return(ERR_NOT_ENOUGH_MONEY); // RC#134


...at the end of the function I return a "ERR_NO_ERR" (zero) if no error has been found in the checks. Now, when I test the EA this is what the logs shows...

Focus on the blue part, then the cycle repeats for the next try: you see the free margin is above zero, and then the return code is zero, so I'm ready to execute OrderSend because "RunChecksBeforeOrderSend" returned no error... but then I get a Tester error saying there's not enough money, and that shouldn't happen, I guess.

I thought the whole point of AccountFreeMarginCheck is to do a mock-up of the real OrderSend before actually calling it, but here one is giving me the OK then the other is failing right after that. What am I doing wrong??

Thanks in advance.