Re: What a clean abort looks like mid-trade when the tape goes thin
Posted: Mon Sep 14, 2026 4:58 pm
1. cAlgo (C#)
In your OnTick method, replace the standard ClosePosition(position) call with this dedicated method. It queries the closed position from the History pool to guarantee it logs the true server-acknowledged fill price.
In your OnTick method, replace the standard ClosePosition(position) call with this dedicated method. It queries the closed position from the History pool to guarantee it logs the true server-acknowledged fill price.
Code: Select all
private void ExecuteMarketAbort(Position position, string abortReason)
{
// 1. Snapshot the expected price before the network call
double expectedPrice = position.TradeType == TradeType.Buy ? Symbol.Bid : Symbol.Ask;
// 2. Execute the close synchronously
TradeResult result = ClosePosition(position);
if (result.IsSuccessful)
{
// 3. Fetch the actual execution record from history
var closedTrade = History.FindLast(position.Label, position.SymbolName);
if (closedTrade != null)
{
double actualPrice = closedTrade.ClosingPrice;
// Calculate slippage in Pips
double slippagePips = position.TradeType == TradeType.Buy
? (expectedPrice - actualPrice) / Symbol.PipSize
: (actualPrice - expectedPrice) / Symbol.PipSize;
Print($"[ABORT: {abortReason}] Expected: {expectedPrice:F5} | Filled: {actualPrice:F5} | Slippage: {slippagePips:F1} pips");
}
}
else
{
Print($"[ABORT FAILED] {abortReason} - Error: {result.Error}");
}
}