Login Page - Create Account

Support Board


Date/Time: Tue, 30 Apr 2024 05:27:53 +0000



Post From: How to get ClosedProfitLoss of an order. in ACSIL, given the InternalOrderID

[2019-10-21 02:08:49]
bradh - Posts: 854
If you know a better way and can use InternalOrderID to query Trade data directly, please let us know, thanks.

I suppose you can get there the way you describe, but it all you are looking for is the price, date, and time the order was filled, those are part of the TradeOrder structure. You can use TradeOrderData.LastActivityTime (Automated Trading From an Advanced Custom Study: [Type: SCDateTime] LastActivityTime). You declare an SCDateTime variable and assign it like this:

SCDateTime FillTime = TradeOrderData.LastActivityTime

So the new code snippet would look like this:


s_SCTradeOrder TradeOrderData;

int Result = sc.GetOrderByOrderID(InternalOrderID, TradeOrderData);
int OrderStatusCode = TradeOrderData.OrderStatusCode;

if (OrderStatusCode == SCT_OSC_FILLED)
{
// The order has completely filled
double FillPrice = TradeOrderData.LastFillPrice;
SCDateTime FillTime = TradeOrderData.LastActivityTime
}

I haven't worked with millisecond timing, but I think you can substitute SCDateTimeMS for SCDateTime above and get ms results.