Login Page - Create Account

Support Board


Date/Time: Fri, 03 May 2024 16:59:15 +0000



[Programming Help] - ACSIL - Check if there is an open stop loss order

View Count: 880

[2020-04-13 08:11:54]
MattK - Posts: 42
Hi,

I'm trying to check if there is an open order without a stop loss at any point in time (because I had issues in the past in high volatility environment where an order was placed but the SL was not.

I tried the following:


int Index = -1; //to get the last order placed.

if(sc.GetOrderByIndex (Index, OrderDetails) != SCTRADING_ORDER_ERROR)
{
if(OrderDetails.OrderStatusCode == SCT_OSC_FILLED)
{
//Flatten and cancel positions here since the last order was filled (meaning there is no current open SL order.
}
}

I don't understand what I'm doing wrong here.

Also, is there a simpler way to check that? That'd be great!

Thanks in advance.
Date Time Of Last Edit: 2020-04-13 08:35:15
[2020-04-13 10:26:23]
bradh - Posts: 854
When the order is placed, save the stop order ID number in a persistent variable. Then any time you want to know the status of the stop order use sc.GetOrderByOrderID to check the status and quantity of the stop order.
[2020-04-13 11:22:16]
MattK - Posts: 42
Thank you for your answer.

The thing is that I use multiple algo at the same time and that I want to use a different algo to "clean up" orders without a SL attached.

I found a way using a while loop but I'm afraid it will slow down the performance.
[2020-04-13 11:59:54]
binaryduke - Posts: 360
Automated Trading From an Advanced Custom Study: sc.GetNearestStopOrder()

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

Login

Login Page - Create Account