OrderCheck() returns nothing in Strategy Tester


Hello, I want to check on margin before opening a trade and was thus using the OrderCheck() function as follows but it always returns zero for all values? Is this function not working in Strategy Tester?

         MqlTradeRequest      TradeRequest;
         MqlTradeCheckResult  TradeCheckResult;
         // Check Order
         TradeRequest.action       =TRADE_ACTION_DEAL;
         TradeRequest.symbol       =Symbol();
         TradeRequest.volume       =Lot_Sum;
         TradeRequest.type         =ORDER_TYPE_BUY;
         TradeRequest.type_filling =ORDER_FILLING_FOK; // Cannot figure out which one is default!
         // TradeRequest.position // Check for SELL order
         // TradeRequest.position_by // Check for SELL order


         message+="TradeCheckResult.retcode      = "+(string)TradeResult.retcode+"\n";
         message+="TradeCheckResult.margin       = "+(string)TradeResult.deal+"\n";
         message+="TradeCheckResult.margin_free  = "+(string)TradeResult.order+"\n";
         message+="TradeCheckResult.margin_level = "+(string)TradeResult.volume+"\n";
         message+="TradeCheckResult.comment      = "+TradeResult.comment+"\n";

Afterwards, I use the Buy function of CTrade to open the trade and this works, so "Lot_Sum" seems not to be the issue...

The checks a trading robot must pass before publication in the Market
The checks a trading robot must pass before publication in the Market
  • www.mql5.com
Before any product is published in the Market, it must undergo compulsory preliminary checks in order to ensure a uniform quality standard. This article considers the most frequent errors made by developers in their technical indicators and trading robots. An also shows how to self-test a product before sending it to the Market.
Hello Vladimir, I cannot see which section should be relevant for me apart from maybe the very first one using OrderCalcMargin and then compare the result to free margin available but that does still not clarify to me why OrderCheck() returns nothing?!
Oh dear, need to stop for today... I used TradeResult and not TradeCheckResult.... too obvious. Sorry for that!

Please take ready-made functions from the article The checks a trading robot must pass before publication in the Market

I also recommend using the trading engine from An attempt at developing an EA constructor