Support Board
Date/Time: Sat, 10 May 2025 10:16:33 +0000
Flatten Positions outside of desired time ranges
View Count: 1067
[2015-07-20 22:57:37] |
User424542 - Posts: 6 |
We currently trading Futures with simulation mode on and we would like to flatten and cancel our order before 06:00:00 and after 14:00:00. We are programming for automated trading and we are entering into a BuyEntry. For some reason the Buy Entry is not flattening and cancelling after the 14:00:00. We have the following code. SCInputRef StartTime = sc.Input[7]; SCInputRef EndTime = sc.Input[8]; if (sc.SetDefaults) { StartTime.Name = "Start Time"; StartTime.SetTime(HMS_TIME(06, 00, 00)); EndTime.Name = "End Time"; EndTime.SetTime(HMS_TIME(14, 00, 00)); if (StartTime.GetTime() >= sc.CurrentSystemDateTime && EndTime.GetTime() <= sc.CurrentSystemDateTime) { sc.FlattenAndCancelAllOrders(); } The code compiles. Any help would be appreciated :) |
[2015-07-21 10:50:11] |
|
This code must be located outside of the sc.SetDefaults code block and it needs to be changed as shown: if (sc.CurrentSystemDateTime.GetTime() < StartTime.GetTime() || sc.CurrentSystemDateTime.GetTime() > EndTime.GetTime() ) { sc.FlattenAndCancelAllOrders(); } 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: 2015-07-21 10:51:37
|
To post a message in this thread, you need to log in with your Sierra Chart account: