Login Page - Create Account

Support Board


Date/Time: Wed, 15 Jan 2025 16:05:27 +0000



Post From: ACSIL Order handling

[2017-08-01 20:48:55]
Zdislav - Posts: 73
I do not know how to express my confusion so I have a code like this (simplified sample):

int Buy(s_SCNewOrder order, ...parameters){
//do stuff
order.StopAllOffset = 10;
order.Target1Offset = 20;
order........parameters are set correctly

// should I set InternalIDs for attached orders manually? It gives me only zeros when I call them...
//sc.SetPersistentInt(0,order.StopAllInternalOrderID);

int result = sc.BuyEntry(order);

//or is the internalID set after the attached orders are put to the graph at this place?
}

SCSFExport function(.......)
{
if(sc.SetDefaults){
...
return;
}

if(condition1){
s_SCNewOrder order;
int result = Buy(order,...parameters);
if(result > 0){
sc.SetPersistentInt(1,order.StopAllInternalOrderID); //should I do this in my "Buy" function above?
}
}

if(condition2){
s_SCTradeOrder Stoploss;
s_SCNewOrder modOrder;
if (sc.GetOrderByOrderID(sc.GetPersistentInt(1),Stoploss) != SCTRADING_ORDER_ERROR) //since there is an order with internal ID = 0, it is true
modOrder.InternalOrderID = Stoploss.InternalOrderID;
modOrder.Price1 = modPrice;
sc.ModifyOrder(modOrder);
}
}
}


I can obtain attached Stop and 1st Target orders by sc.GetNearestStopOrder() and sc.GetNearestTargetOrder() but not by sc.GetOrderByOrderID(sc.GetPersistentInt(0)). However, it finds an order with InternalID = 0, which I guess is the filled order (?) which cannot be moved. Stop order remains unchanged even though sc.ModifyOrder() function returns success (!= SCTRADING_ORDER_ERROR). Maybe I am just blind and do not see what's obvious to someone else. Please help...

Z.