Login Page - Create Account

Support Board


Date/Time: Fri, 03 May 2024 13:55:02 +0000



Post From: Discrepancies with backtesting an ACSIL trading system

[2019-10-11 14:41:59]
User704508 - Posts: 20
Hi,

I'm currently running into some issues with my trailing stop loss. I'm not a pro so I'm guessing since I'm not using a market order, it is not yet filled and, the stop loss is already getting modified?

I'm not sure how to check if the order was filled so I can check the trailing stop loss. Is it an attached order or a separate one?

Since I have the orderId, I'd like to use the OrderStatus function but I can't pass the id in parameter.

If you could help me on that I'd really appreciate it.

Thanks in advance,
Matt

Here is a part of the code:


int& OrderId = sc.GetPersistentInt(1);
int& Stop1OrderID = sc.GetPersistentInt(2);

if(/*conditions to buy*/)
{
s_SCNewOrder NewOrder;
NewOrder.OrderQuantity = 1;
NewOrder.OrderType = SCT_ORDERTYPE_STOP_LIMIT;
NewOrder.TimeInForce = SCT_TIF_DAY;
NewOrder.OCOGroup1Quantity = 1;
NewOrder.Price1 = currentPrice + 4*sc.TickSize;
NewOrder.Price2 = currentPrice + 2*sc.TickSize;
NewOrder.Stop1Price = currentPrice + 12*sc.TickSize;

sc.SellEntry(NewOrder);
      
// Remember the order ID for subsequent modification and cancellation
Stop1OrderID = NewOrder.Stop1InternalOrderID;
OrderId = NewOrder.InternalOrderID;
      
orderStop = currentPrice + 12*sc.TickSize;
currentStop = orderStop;
}

//Check this every minute
NewPossibleStop = currentLow + 30*sc.TickSize;
    
if (PositionData.PositionQuantity <= -1 && NewPossibleStop < currentStop && NewPossibleStop < orderStop)
{
s_SCTradeOrder ExistingOrder;
if (sc.GetOrderByOrderID(Stop1OrderID, ExistingOrder) != SCTRADING_ORDER_ERROR)
{
s_SCNewOrder ModifyOrder;
ModifyOrder.InternalOrderID = Stop1OrderID;
ModifyOrder.Price1 = NewPossibleStop;

sc.ModifyOrder(ModifyOrder);
        
currentStop = NewPossibleStop;


Date Time Of Last Edit: 2019-10-11 16:28:42