Login Page - Create Account

Support Board


Date/Time: Mon, 13 Jan 2025 17:21:33 +0000



sc.FlattenAndCancelAllOrders during Replay mode

View Count: 860

[2017-04-29 02:34:37]
User553714 - Posts: 184
Hi, Can you use sc.FlattenAndCancelAllOrders() during replay mode, it's hard to believe that you can't?
I have done a fair bit of testing on this and sc.FlattenAndCancelAllOrders() does not seem to function correctly during reply?
It works fine during an AutoTradeSystem backtesting but seems to produces strange behaviour when used in replay mode. What seems to be happening is that in Replay mode sc.FlattenandcancelAllOrders executes in "real time" even though the GlobalSimulation variable is set to true instead of executing at the current Replay Index. This means that the lastExitTrade Index always returns as the current Replay index so as the chart advances LastExitTradeIndex = Index (current replay Index).
See extract of log below which I think demonstrates what I am explaining, the current replay index/time is 2017-04-27 00:17 but Flatten executes at 2017-04-29 12:26:20.410 (system time)?
Order  2017-04-27 00:17:31.012  [Sim]CL-201706-NYMEX  
Order  2017-04-27 00:17:31.013  [Sim]CL-201706-NYMEX      
Order  2017-04-27 00:17:31.014  [Sim]CL-201706-NYMEX      
Order  2017-04-29 12:26:20.410  [Sim]CL-201706-NYMEX      
Order  2017-04-29 12:26:20.411  [Sim]CL-201706-NYMEX    
Order  2017-04-29 12:26:20.412  [Sim]CL-201706-NYMEX      
Fill  2017-04-29 12:26:20.413  [Sim]CL-201706-NYMEX
I hope I am not missing something simple but I can't seem to work this one out. Any help will be appreciated. Thanks.
[2017-05-01 23:19:22]
Sierra Chart Engineering - Posts: 104368
We cannot debug what you are doing. This is completely outside the scope of our support.

We ran a test of the sc.FlattenAndCancelAllOrders() function. And it does work properly:

ActivityType  Symbol  DateTime  OrderActionSource  InternalOrderID  OrderStatus  ServiceOrderID  OrderType  PositionQuantity  Quantity  BuySell  Price  Price2  FillPrice  FilledQuantity  TradeAccount  OpenClose  ParentInternalOrderID  FillExecutionServiceID  HighDuringPosition  LowDuringPosition
Order  [Sim]GCM17  2017-04-26 15:14:30.000  Replay 60.0X: GCM17 3 Min #1 | User order entry | Last: 1268.6  88  Order Sent    Market    4  Buy          Sim1  Open        
Order  [Sim]GCM17  2017-04-26 15:14:30.001  Simulated order accepted  88  Open  88  Market    4  Buy          Sim1  Open        
Order  [Sim]GCM17  2017-04-26 15:14:30.002  Trade simulation fill. Bid: 1268.2 Ask: 1268.3 Last: 1268.2  88  Filled  88  Market    4  Buy      1268.3  4  Sim1  Open        
Fill  [Sim]GCM17  2017-04-26 15:14:30.003  Trade simulation fill. Bid: 1268.2 Ask: 1268.3 Last: 1268.2  88  Filled  88  Market  4  4  Buy      1268.3  4  Sim1  Open    88.1  1268.3  1268.3
Order  [Sim]GCM17  2017-04-26 15:14:37.000  Auto-trade: Replay 60.0X: GCM17 3 Min #1 | Trading Test 2 | Source: ACSIL Flatten & Cancel | Bar start date-time: 2017-04-26 15:12:00.000. Flatten&Cancel | Last: 1268.2. Current Position quantity: 4  89  Order Sent    Market  4  4  Sell          Sim1  Close        
Order  [Sim]GCM17  2017-04-26 15:14:37.001  Simulated order accepted  89  Open  89  Market  4  4  Sell          Sim1  Close        
Order  [Sim]GCM17  2017-04-26 15:14:37.002  Trade simulation fill. Bid: 1268.2 Ask: 1268.3 Last: 1268.2  89  Filled  89  Market  4  4  Sell      1268.2  4  Sim1  Close        
Fill  [Sim]GCM17  2017-04-26 15:14:37.003  Trade simulation fill. Bid: 1268.2 Ask: 1268.3 Last: 1268.2  89  Filled  89  Market    4  Sell      1268.2  4  Sim1  Close    89.2  1268.2  1268.2

The times do match up with the replay time in the chart.


Refer to:
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-05-01 23:19:58
[2017-05-03 01:04:54]
User553714 - Posts: 184
Hi, Thanks for checking on this; for the benefit of others, having spent days on this, what eventually fixed the issue was creating a new chartbook and re-apply my custom studies. It seems that the study settings saved in the old chartbook had somehow become corrupted? This was causing some very strange behaviour like user inputs returning with the wrong values and the Flatten&Cancel issue I described in my initial post. Regards.
[2017-05-03 03:41:59]
Sierra Chart Engineering - Posts: 104368
This makes no sense to us. We do not see how that would have been the cause.
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
[2017-05-03 06:36:31]
User553714 - Posts: 184
Hi, Your comment is concerning to me. Having done another two or so hours of testing since your reply I still can't produce the error in the new chartbook and there is no odd messages/results in extensive log files I write too which write on every Index if required. Is it possible that an ACSIL request to flattenAndCancel during Replay when no position exists is causing issues? FYI; see two log files that I have attached which shows an order flattened in the old chartbook and two orders (incl attached orders) flattened in the new chartbook. In the old chartbook I have placed a blank line where the Replay BarTime skips to the end of the LastChartBar instead of the current replay bar.
I really don't want you wasting your time on this as I appreciate how busy you always are; from my end the strange behaviour seems to be resolved and I will keep monitoring the issue and reply back if anything else becomes more apparent like some silly error I might be making. Thanks
Private File
Private File

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

Login

Login Page - Create Account