Support Board
Date/Time: Tue, 04 Feb 2025 14:47:30 +0000
[User Discussion] - Failure to Do Entry in ACSIL Trading Strategy
View Count: 1342
[2018-11-19 18:18:12] |
User41727 - Posts: 124 |
There is a problem with sc.SellEntry/BuyEntry not triggering an actual order if sc.FlattenAndCancelAllOrders has been called to flatten an existing position first during the same run of a strategy. So far I was only able to verify this behaviour during a simulation using the replay functionality. I do not know whether it happens with live orders too. The entry works fine if I start the simulation just before the entry signal while the strategy is flat, so it is not the case that the entry command is never called. I can also verify in my logs that the code gets to that point when sc.FlattenAndCancelAllOrders has been called during that run to flatten an existing position. So, the entry command is definitely being called, but no orders are created. There is also no entry in the "Trade Service Log" that would give any indication to why that is. |
[2018-11-19 21:06:37] |
Sierra Chart Engineering - Posts: 104368 |
What is the error you are getting from those functions? Refer to: Automated Trading From an Advanced Custom Study: Debugging/Troubleshooting Automated Trading Systems You are going to definitively get an answer from that documentation and following the instructions. There is no other possibility. And we would fully expect the described behavior to not work as you would expect with live trading unless you are using unmanaged automated trading. There is little doubt there is not a problem here. The behavior must be correct based on the settings of the automated trading 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: 2018-11-19 21:12:32
|
[2018-11-19 22:20:21] |
User41727 - Posts: 124 |
What is the error you are getting from those functions?
There is no error. sc.SellEntry returns the expected quantity of the new entry order, but no entry order is actually created. No new entry in the trade service log appears that would explain why there is no order. You are going to definitively get an answer from that documentation and following the instructions. There is no other possibility.
I did everything described in the mentioned section, and I am not. The behavior must be correct based on the settings of the automated trading variables.
The variables are set correctly as far as I can tell from what is documented. The entry does work as long as there is no prior position that had to be flattened by using FlattenAndCancelAllOrders. Mind you, by the time SellEntry is called, the strategy is always flat. The only difference is whether or not FlattenAndCancelAllOrders had to be called. Hence, there is an undocumented side effect of calling that function that may or may not be intentional. I suggest you attempt to figure that out. EDIT: It actually seems like the entry orders are being created, but then get cancelled immediately. They show up under "Orders And Positions" with a status of "canceled" and LastOrderActionSource of "Simulated order canceled". Date Time Of Last Edit: 2018-11-19 22:30:11
|
[2018-11-19 23:47:28] |
ejtrader - Posts: 688 |
User41727 - I am not sure about the "managed" mode of order entries(Buy entry/Sell entry) - but unmanaged orders don't have this problem.
|
[2018-11-19 23:53:38] |
Sierra Chart Engineering - Posts: 104368 |
Why is the order getting canceled? You need to find out the reason for it and it is given in the Order Action Source field for the order when the cancellation is initiated. Hence, there is an undocumented side effect of calling that function that may or may not be intentional. I suggest you attempt to figure that out. This is for you to figure that out. Not us. You are the one who created the automated trading system. Sierra Chart has very detailed logging in order for users to be able to help themselves and determine the source of orders and the source of all actions on those orders. If something is not clear we will make it clear. So if the answer is not clear provide us the lines in the Trade Activity Log for the order cancellation and we will make sure the source of that is clear. This is a very good example of unnecessarily taking our time on this Support Board when you already have the information to resolve the problem. Refer to: Automated Trading Management: Troubleshooting Automated Trading System Behavior 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: 2018-11-20 00:15:21
|
[2018-11-20 00:25:05] |
User41727 - Posts: 124 |
@ejtrader Thank you for the information. I might have to look into this. @Sierra Here is the log for the entry order being cancelled: ActivityType DateTime Symbol OrderActionSource InternalOrderID ServiceOrderID OrderType Quantity BuySell Price Price2 OrderStatus FillPrice FilledQuantity TradeAccount OpenClose ParentInternalOrderID PositionQuantity FillExecutionServiceID HighDuringPosition LowDuringPosition Note AccountBalance
Order 2018-11-15 17:45:04.019 [Sim]GOOS Auto-trade: Replay 1.00X: GOOS [M] 5 Min #6 | Test Trading System | SellEntry | Bar start date-time: 2018-11-15 17:40:00.000 | Last: 65.939995 35627 Stop 100 Sell 65.87 Order Sent Sim3 Open Order 2018-11-15 17:45:04.020 [Sim]GOOS Simulated order accepted 35627 35627 Stop 100 Sell 65.87 Open Sim3 Open Order 2018-11-15 17:45:04.030 [Sim]GOOS Canceling orders on flat position 35627 35627 Stop 100 Sell 65.87 Pending Cancel Sim3 Open Order 2018-11-15 17:45:04.031 [Sim]GOOS Simulated order canceled 35627 35627 Stop 100 Sell 65.87 Canceled Sim3 Open It seems that if FlattenAndCancelAllOrders is called, it will cancel all orders including those that were created during the same execution cycle but after FlattenAndCancelAllOrders was called. Is this the intended behaviour? And if so why, and why is it not properly documented? The documentation states: The working orders are canceled first but all of these actions are immediately executed.
So there is really no reason to suspect that orders created after the call to FlattenAndCancelAllOrders would be cancelled, too. Date Time Of Last Edit: 2018-11-20 00:26:19
|
[2018-11-20 00:52:52] |
Sierra Chart Engineering - Posts: 104368 |
" Canceling orders on flat position" is the answer. This is unrelated to automated trading and we can also tell by the timing of this. It is the result of having this enabled: Basic Trading and the Trade Window: Main/C >> Menu >> Orders >> Cancel Orders on Flat Position (chart specific) We will see how to make that message more clear as to the specific origin. 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 |
[2018-11-20 01:07:24] |
User41727 - Posts: 124 |
How does that behaviour make sense? The timeline is: long position -> flatten & cancel -> short entry Cancelling orders upon flattening makes sense. Cancelling new orders after the position has already been flattened does not. I imagine this is due to the "Cancelling orders on flat position" mechanism only being triggered after the ACSIL code has finished its run and is unable to distinguish newly created order from old ones, cancelling everything. If you want to do it this way (which does not seem like sane behaviour), this should at the very least be documented somewhere, because there is no no reason whatsoever to expect this. |
[2020-01-29 11:56:54] |
rahul - Posts: 167 |
Hello, I noticed the same thing yesterday in Live Trade. Even though I have the flatten and cancel order code before the new order entry code... no new order is actually created. However this issues doesn't arrive in simulated trading when replaying charts...i learnt it the hard way through live trading. There is something wrong with the "sc.FlattenAndCancelAllOrders" function. did anyone find a workaround? |
[2020-01-29 16:55:20] |
User41727 - Posts: 124 |
Check the log to see if the new entry order was actually created in the first place. If yes, and if it was immediately cancelled, then this is likely the same issue. In that case make sure that the "Cancel Orders on Flat Position" option is disabled on the chart. As I have stated previously, this behaviour makes no sense, because the new order is only created after flattened had already been called. But apparently, this is so poorly implemented that flattening an existing position with sc.FlattenAndCancelAllOrders triggers the "Cancel Orders on Flat Position" mechanism after the new order had already been created, so it is cancelled immediately, too. |
[2020-01-29 19:02:47] |
rahul - Posts: 167 |
Looking at the log I don't see a new position created. "Cancel Orders on Flat Position" is disabled already. I have a few issues, please see this too: PLEASE HELP!... STOP ORDERS NOT WORKING PROPERLY Do you have an updated code to deal with this issue? Date Time Of Last Edit: 2020-01-29 19:08:06
|
[2020-01-29 19:50:33] |
User41727 - Posts: 124 |
Looking at the log I don't see a new position created. "Cancel Orders on Flat Position" is disabled already.
If that is the case, this must be a different issue then. Only thing I can tell you is that there are a lot of flags that can affect the way orders are handled. Make sure those are all set correctly. And double check the "Trade Service Log" in case there is any kind of error there. |
[2020-01-29 19:53:39] |
rahul - Posts: 167 |
Thank you... there were no error generated as the orders didn't even go through. I don't see this issue in simulated trading when replaying charts...so there is no way for me to diagnose it. I learnt it the hard way with live trading yesterday! I can't believe Sierra Chart doesn't do any quality control, especially on order execution! I am so pissed off right now and lost without any direction! |
To post a message in this thread, you need to log in with your Sierra Chart account: