Support Board
Date/Time: Wed, 14 May 2025 18:37:47 +0000
Post From: Error with Sim Lock & Orders being executed
[2024-07-21 15:08:45] |
User194332 - Posts: 40 |
im using this piece of code to Flatten a position but when I test it, nothing happens. Does this function return unrealized P&L ? sc.GetTotalNetProfitLossForAllSymbols(1) I have the defaults set as follows sc.MaintainTradeStatisticsAndTradesData = TRUE; // Maintain trade statistics and trades data sc.SendOrdersToTradeService = FALSE; // Prevent sending orders // Get trade position data s_SCPositionData PositionData; sc.GetTradePosition(PositionData); double totalNetPL = sc.GetTotalNetProfitLossForAllSymbols(1); // Check if the loss limit is exceeded if (totalNetPL <= DAILY_LOSS_LIMIT) { sc.AddMessageToLog("Daily PNL exceeds loss limit.", 1); } // Flatten position and cancel all orders if the loss limit is exceeded if (PositionData.PositionQuantity != 0 && totalNetPL <= DAILY_LOSS_LIMIT) { sc.FlattenPosition(); sc.AddMessageToLog("Flattened Position due to loss limit.", 1); } |