Login Page - Create Account

Support Board


Date/Time: Sun, 08 Sep 2024 00:22:39 +0000



[Programming Help] - Acsil: Limit order to exit a long position, how ?

View Count: 80

[2024-07-01 12:57:19]
BenjFlame - Posts: 324
Hi,
a position is entered with such code:


s_SCNewOrder NewOrder;
NewOrder.OrderQuantity = sc.TradeWindowOrderQuantity;
NewOrder.OrderType = SCT_ORDERTYPE_MARKET;
NewOrder.TimeInForce = SCT_TIF_GOOD_TILL_CANCELED;
NewOrder.Target1Offset = sc.TickSize * Input_DefaultTargetTickDistance.GetInt();
NewOrder.Stop1Offset = sc.TickSize * Input_DefaultStopTickDistance.GetInt();
int Result = sc.BuyEntry(NewOrder);


How to create new code to place limit order to exit that position at entryprice + 3 ticks ?

Attempt with such code:


s_SCNewOrder NewOrder;
NewOrder.OrderQuantity = Quantity; // This is defined elsewhere
NewOrder.OrderType = SCT_ORDERTYPE_LIMIT;
NewOrder.TimeInForce = SCT_TIF_GOOD_TILL_CANCELED;
NewOrder.Price1 = entryPrice + sc.TickSize * 3;
int Result = sc.BuyExit(NewOrder);


fail
[2024-07-01 13:09:04]
BenjFlame - Posts: 324
Answer: the problem was because there was already an exit order placed on entry.
Solution is first cancel that order, then the limit with that code will pass.

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

Login

Login Page - Create Account