Login Page - Create Account

Support Board


Date/Time: Thu, 02 May 2024 01:08:06 +0000



ACSIL Order handling

View Count: 1756

[2017-08-01 09:25:43]
Zdislav - Posts: 73
Hi.
I would like to handle orders in ACSIL. Both entries and exits work just fine. But when it comes to handling targets and stops (up to 5 targets and 5 stops) that's a challenge. I need to reference every single order separately. I tried to search for order IDs stored as persistent variables (int&) as the example suggests, but with no success. I've got a feeling there might be some trick (perhaps my lack of knowledge) in storing of persistent variables. If someone could point me the right direction or provide some simple sample code that would be most helpful. Thanks.

Petr
[2017-08-01 13:53:55]
Sierra Chart Engineering - Posts: 104368
We do not see why this would be difficult in any way. You just simply store the Internal Order ID for each of the Attached Orders in a persistent variable and can access those using a unique variable name.

Here is the documentation for the persistent variable functions:
sc.GetPersistentInt()
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2017-08-01 13:54:33
[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.
[2017-08-02 05:38:05]
Sierra Chart Engineering - Posts: 104368

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

No order has an Internal Order ID of 0. In the next release, this will cause sc.GetOrderByOrderID to return 0.

The function scsf_TradingExample(SCStudyInterfaceRef sc) in the \ACS_Source\tradingsystem.cpp file provides a good example for working with persistent variables.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2017-08-02 05:58:34
[2017-08-02 05:43:06]
Zdislav - Posts: 73
I see. Thank you very much. I will try to dig into that further more...

Z.
[2017-08-04 16:56:47]
Zdislav - Posts: 73
I figured it out. It is working now. Thank you for the kick in the right direction. :-)

Z.

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account