Support Board
Date/Time: Wed, 24 Apr 2024 20:45:54 +0000
AutoTrade Bar Based BackTest - incorrect behavior
View Count: 1602
[2018-10-03 16:10:41] |
Rearden - Posts: 16 |
I have got a simple chart with two "Trading system based on alert condition" studies. One for Buy Entry, one for Buy Exit. I am backtesting a strategy using these two studies. Everything works perfectly when using Replay BackTest on intraday data. There are some buy entries and some buy exits, as expected. However, when using Bar Based BackTest on daily data (nothing else changed), several issues suddenly occur: 1) Buy Entry signals now create SHORT positions instead of long position (and similarly, Sell Entry signals create long positions instead of short positions). 2) Buy Exit signal is ignored (this might be related to the fact that no long positions were created) 3) PT and SL attached orders are automatically cancelled, they are never filled. 4) All short positions generated by the Buy Entry signals are flattened on the last loaded day. AND new short positions are created! I tried using "Spreadsheet System for trading" instead of "Trading system based on alert condition" with the same result. There is just one chart in the chartbook, the chart contains just these two studies, the studies contain the most simple alert condtition (C[-1]>O[-1] and C[-1]<O[-1]). SC version 1814 64bit. Thank you |
[2018-10-03 18:21:15] |
Sierra Chart Engineering - Posts: 104368 |
1) Buy Entry signals now create SHORT positions instead of long position (and similarly, Sell Entry signals create long positions instead of short positions). This is definitively a misunderstanding on your side. This is not even possible. What must be happening, is there is indeed a Sell Entry creating a short position. There simply is no other possibility.Refer to: Automated Trading Management: Troubleshooting Automated Trading System Behavior You can also clearly see this in the Trade Activity Log: Trade Activity Log: Viewing Historical Trade Activity You can see the particular automated trading system order action and the particular study that is submitting an order. 3) PT and SL attached orders are automatically cancelled, they are never filled. Attached Orders: Time In Force Ultimately it is going to be up to you to develop a reliable automated trading system. This is not something we provide help with other than providing links to relevant documentation and there is no problem with the functionality on the Sierra Chart side. 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-10-03 18:22:34
|
[2018-10-04 08:31:23] |
Rearden - Posts: 16 |
Thank you for your answer. Please let me assure you that I really don't want to waste your time unnecessarily - I have already been autotrading live for a couple of months and intraday backtesting / autotrading works perfectly. Please see enclosed image which shows that There is Buy Entry study and that there are short positions created. Also please see further comment which might explain what we are seeing on the picture (although I still consider it invalid behaviour). You can't see details of Buy Exit study on the picture but I later deleted it and it had no effect. Regarding attached orders - I do use GTC TIF for both target and stop-loss, it can also be seen on the image. I think that it is actually the attached orders that create the short positions. Trade activity log shows that the short positions were entered by a stop order (not a market order). When I change PT and SL to unreachable numbers, the backtest creates a long position. However - not on the date of the buy signal but on current day (on the last daily bar of the chart). Therefore, I can see two related issues here (only when running bar based backtest on historical chart; not when running it on intraday chart): - a market order with a positive quantity is created on the last bar of the chart (while it should be created on the signal bar) - attached order with a negative quantity creates a short position (while it should just flatten a long position, if it existed) |
Buy entry signal creates a short positions.jpg / V - Attached On 2018-10-04 08:28:51 UTC - Size: 599.5 KB - 274 views |
[2018-10-05 17:54:14] |
Sierra Chart Engineering - Posts: 104368 |
Please see enclosed image which shows that There is Buy Entry study and that there are short positions created. You cannot come to this conclusion with that particular screenshot and the data it is showing. You must look at only the "Trade Activity" tab of the Trade Activity Log:Trade Activity Log: Viewing Historical Trade Activity And you have to look at the Order Action Source field. And make sure the starting Date-Time for the data on the Trade Activity Log is set to the start of the back test. Not earlier. You need to precisely set that. In regards to attached orders getting canceled, you need to look at the Trade Activity Log to find out the reason if indeed you are using Good till Canceled for those - a market order with a positive quantity is created on the last bar of the chart (while it should be created on the signal bar) From our perspective this is just too vague for us to understand. We need much more precise details and it is doubtful anything is wrong from our side.- attached order with a negative quantity creates a short position (while it should just flatten a long position, if it existed) 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-10-05 21:01:01] |
Sierra Chart Engineering - Posts: 104368 |
But looking at this and thinking about this more, we can see your point with the results and that does not really make sense. We have to test this and see why you would be getting that result if indeed you are just using Buy Entry and Buy Exit. Provide that particular chart by following the instructions here and we will test it and see what the issue is: Support Board Posting Information: Providing Chartbook with Only a Single Chart 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-10-07 16:41:29] |
Rearden - Posts: 16 |
Thank you, please see the chart is enclosed. I have also noticed this in Trade Service Log: Chart #1 | Base Graph ID: 0 DateTime: Array is unallocated. | 2018-10-04 02:48:09 * A few clarifications: - I do use "Trade activity" of the "Trade activity log" - I changed Date-Time to start of the backtest - no effect, still the same output / log. - By "negative amount" I meant a short position (SC showed "-5" when there is a short position with quantity 5); I am sorry for this incorrect terminology - "Buy Exit" is not essential for reproduction of the issue - the corresponding study can be deleted from the chart I am also posting the Trade Activity Log, which will be far better than my explanation of the issue. It seems to me that there might me some kind of "DateTime unallocated array" type of issue as the Trade Service Log suggests - when I look at the first entry, I have no rational explanation for it (since it is the first entry and since the log is properly sorted by DateTime...). ActivityType DateTime Symbol OrderActionSource InternalOrderID ServiceOrderID OrderType Quantity BuySell Price Price2 OrderStatus FillPrice FilledQuantity TradeAccount OpenClose ParentInternalOrderID PositionQuantity FillExecutionServiceID HighDuringPosition LowDuringPosition Note AccountBalance Fill 2018-09-12 00:00:00.000 [Sim]AAPL Trade simulation fill. Bid: 219.84 Ask: 219.85 Last: 219.84 1002583 1002583 Stop 5 Sell 223.94 Filled 223.93 5 Sim1 Close 1002581 1002583.1 225.00 219.84 Fill 2018-09-19 00:00:00.000 [Sim]AAPL Trade simulation fill. Bid: 215.30 Ask: 215.31 Last: 215.30 1002587 1002587 Stop 5 Sell 217.50 Filled 217.49 5 Sim1 Close 1002585 1002587.1 215.30 215.30 Fill 2018-09-25 00:00:00.000 [Sim]AAPL Trade simulation fill. Bid: 222.81 Ask: 222.82 Last: 222.82 1002590 1002590 Limit 5 Sell 220.76 Filled 220.76 5 Sim1 Close 1002589 1002590.1 222.82 219.70 Fill 2018-10-03 00:00:00.000 [Sim]AAPL Trade simulation fill. Bid: 233.46 Ask: 233.47 Last: 233.47 1002594 1002594 Limit 5 Sell 231.05 Filled 231.05 5 Sim1 Close 1002593 1002594.1 233.47 229.78 Fill 2018-10-07 11:11:55.080 [Sim]AAPL Trade simulation fill. Bid: 224.93 Ask: 224.94 Last: 224.94 1002581 1002581 Market 5 Buy Filled 224.94 5 Sim1 Open 5 1002581.1 Akcie.twconfig Fill 2018-10-07 11:11:55.081 [Sim]AAPL Trade simulation fill. Bid: 225.75 Ask: 225.76 Last: 225.75 1002584 1002584 Market 5 Sell Filled 225.75 5 Sim1 Close 1002584.1 228.35 221.07 Akcie.twconfig Fill 2018-10-07 11:11:55.081 [Sim]AAPL Trade simulation fill. Bid: 218.49 Ask: 218.50 Last: 218.50 1002585 1002585 Market 5 Buy Filled 218.50 5 Sim1 Open 5 1002585.1 Akcie.twconfig Fill 2018-10-07 11:11:55.082 [Sim]AAPL Trade simulation fill. Bid: 220.77 Ask: 220.78 Last: 220.78 1002588 1002588 Market 5 Sell Filled 220.77 5 Sim1 Close 1002588.1 222.28 218.37 Akcie.twconfig Fill 2018-10-07 11:11:55.083 [Sim]AAPL Trade simulation fill. Bid: 219.75 Ask: 219.76 Last: 219.75 1002589 1002589 Market 5 Buy Filled 219.76 5 Sim1 Open 5 1002589.1 Akcie.twconfig Fill 2018-10-07 11:11:55.084 [Sim]AAPL Trade simulation fill. Bid: 224.79 Ask: 224.80 Last: 224.79 1002592 1002592 Market 5 Sell Filled 224.79 5 Sim1 Close 1002592.1 226.44 219.76 Akcie.twconfig Fill 2018-10-07 11:11:55.085 [Sim]AAPL Trade simulation fill. Bid: 230.04 Ask: 230.05 Last: 230.05 1002593 1002593 Market 5 Buy Filled 230.05 5 Sim1 Open 5 1002593.1 Akcie.twconfig |
TEST.Cht - Attached On 2018-10-07 16:24:28 UTC - Size: 39.25 KB - 240 views |
[2018-10-07 17:00:46] |
Rearden - Posts: 16 |
A small clarification of my comment on "Buy Exit" study - it can be deleted (and the issue will persist) but don't delete it if you want to get the "same" trade activity log ouput as the one I provided in the previous post.
|
[2018-10-07 23:18:28] |
Sierra Chart Engineering - Posts: 104368 |
The issue is that during a Bar Based Back Test the Date-Time of the order fills was using the current time for historical daily charts, and that was causing problems with the Order Fill matching and therefore the Position calculations. This is a recent issue. Additionally, in order to improve performance during a back test, Trade Activity other than order fills was being filtered out of the Trade Activity Log, but that prevents users from being able to have a clear understanding of the trading activity of their trading system and knowing the source of the orders. We always say it is important to look at the source of an order but you could not during a bar based back test. So that filtering is now removed. We are releasing version 1818 in about 20 minutes. 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-10-07 23:19:55
|
To post a message in this thread, you need to log in with your Sierra Chart account: