Support Board
Date/Time: Wed, 27 Nov 2024 23:20:37 +0000
[Programming Help] - Skip/Cancel Downloading Data During Backtests
View Count: 376
[2024-06-04 10:07:56] |
gtaranti - Posts: 69 |
Is there a way through the Sierra Chart API to skip or cancel downloading historical or new data during backtests? I have automated my backtests and sometimes before starting a new one, SC starts to download data. I want to disable this behaviour. |
[2024-06-04 18:44:48] |
ForgivingComputers.com - Posts: 960 |
Is there a way through the Sierra Chart API to skip or cancel downloading historical or new data during backtests?
When you start a backtest and Sierra "downloads" data, it is reading it from your hard drive, as you have already downloaded it from the feed. To reduce the time it takes to begin the backtest, limit the number of days loaded in the chart settings to a date before your backtest start date-time. |
[2024-06-13 04:38:07] |
User61168 - Posts: 403 |
Hi Bradh, I dont think your response is relevant to what gtaranti is asking. The auto-reconnect/download at the onset of replay and also at the end of replay is a biggest pain introduced in recent releases. It was never like this in older releases. This happens regardless of how much date filter you apply it will always reconnect and go through the download process. If I have more than one chart or chartbook (which most of us do during strategy development and testing), but only want to backtest one chart, the reconnect feed downloads data for all charts taking a very long time depending on what you have open across all your chartbooks. I just dislike the lack of control with data feed connectivity. I suggested this several years ago to introduce capability of controlling data feed at the chart or chartbook level. It's an unnecessary load on CPU/GPU for charts you just want to keep open for access or not in frequent/active use. If an ASCIL study could control disconnect/reconnect, that would be great! |
[2024-06-13 04:41:45] |
User61168 - Posts: 403 |
I have automated my backtests - I would love to understand how you are automating your backtests/replays. Care to share?
|
[2024-06-13 06:04:08] |
gtaranti - Posts: 69 |
Hey User61168, this is EXACTLY what I was refering to !! At the end of each replay you have this "DOWNLOAD". I've deliberately programmaticaly disconnected from the data services but then this happens : View charts when not connected | Post: 384838 The strange thing is than when I have only a few days loaded, there is no extra download and the automated replays work. As far as the automation method, it's really a standalone custom study using SC API and using some relevant inputs and respective persistent variables to increase/decrease with every run, in order to change the inputs of other studies on the same chart. I want to have 4 offline SC instances which run these on 2 PCs. The gist in the core is as follows : n_ACSIL::s_ChartReplayParameters ReplayParameters; ReplayParameters.ChartNumber = sc.ChartNumber; ReplayParameters.ReplaySpeed = 200000; ReplayParameters.StartDateTime = sc.BaseDateTimeIn[0]; ReplayParameters.SkipEmptyPeriods = 0; ReplayParameters.ReplayMode = n_ACSIL::REPLAY_MODE_CALCULATE_AT_EVERY_TICK; ReplayParameters.ClearExistingTradeSimulationDataForSymbolAndTradeAccount = 1; ReplayParameters.ChartsToReplay = n_ACSIL::CHARTS_TO_REPLAY_ALL_CHARTS_IN_CHARTBOOK; ReplayParameters.ProcessingStepInSeconds = 1; sc.StartChartReplayNew(ReplayParameters); By the way, I'm also utilising the new structure member ProcessingStepInSeconds that SC introduced after my request : Chart Reply - Processing steps in seconds | Post: 384053 I hope you found it useful. |
[2024-06-13 07:51:55] |
User61168 - Posts: 403 |
Thanks for the details. I have very limited knowledge of ASCIL but I get what you are doing. I was hoping you would have some solution to automatically run a single strategy with differing configuration parameters across different sim accounts as part of edge discovery and strategy parameter optimization. I want to have 4 offline SC instances which run these on 2 PCs - Perhaps you could run these 2 PCs in airplane mode as a workaround :-
|
[2024-06-13 08:05:28] |
gtaranti - Posts: 69 |
- Perhaps you could run these 2 PCs in airplane mode as a workaround :-
Hmmm.. Maybe it would work, but it's not viable. I need network connectivity because: a. Every test run sends the trade results in a central database in a NAS b. After every test run I get a notification c. I need to occasionally monitor the replays with remote desktop software I suppose you use different sim accounts to retain the test results, but with a database there is no such need. And the other plus for the database solution is that you can have powerful insights by comparing the tests across any variable you have saved in each trade (long/short, time period, time frame, entry/exit signals, etc) Of course I had to build the database connection layer into the custom study and this was super hard (I use PostgresSQL as a db) Date Time Of Last Edit: 2024-06-13 08:06:14
|
[2024-06-13 08:23:20] |
User61168 - Posts: 403 |
but with a database there is no such need - you could also introduce analytics on post-replay chart values via export study and chart data and then importing into db. I gave up on this due to limitations with excel.
|
[2024-06-16 08:35:31] |
User61168 - Posts: 403 |
gtaranti - I just found one way to avoid auto-downloads with market replays. For all open charts in your platform (even those charts that are not used in backtesting), set "Load data limiting method" to "Use Date Range" and set the "Date Range To" to any date before today's date. This prevents the auto reconnect to date feed. If any open chart is set to "use number of days to load" , platform will always try to reconnect and download missing data to download (which makes sense and should not be considered a design flaw or bug) |
[2024-06-16 11:29:20] |
gtaranti - Posts: 69 |
Thanks User61168, In my case I have one chart that I run the Trading study on and 4 other charts in the same chartbook that have a Linking on 'Days to Load' with the 1st one, so any change I've made to the date range in the 1st chart is propagated to the other ones. Now the "Date Range To" is blank, so it's open ended. Maybe you're right, I'll definetely try this and put yesterday value and get back with results. |
[2024-06-16 12:29:03] |
gtaranti - Posts: 69 |
I'm doing my first backtest right now with only a few days loaded, in order to verify this and I'll get back to you. Being as lazy as I can, I opted to change the setting of ACSIL Interface Members - Variables and Arrays: sc.ChartDataEndDate programmaticaly with ACSIL. I found out that changing this programmaticaly it works but only for the 1st chart. Even if you have other charts linked on 'Days to Load', they do not change their ChartDataEndDate respectivelly. You have to change the setting manually in one of the charts for the others to follow. It's a bummer, but I can live with it. The reason I wanted to change it automatically is to have always set it one day prior to current date and resetting at 0 (open ended) when the backtests end. (Because you can easily forget this one, and it can drive you crazy!) Date Time Of Last Edit: 2024-06-16 12:29:25
|
[2024-06-16 19:54:01] |
gtaranti - Posts: 69 |
Unfortunately setting the "Date Range To" to any date before today's date does not solve the problem for me. It only worked when I had a few days loaded. After increasing the date span, after the first backtest concluded, it just showed the message "Downloading Continuous Contract Data" hanging there forever. I wonder why on earth these data are needed, and why can't the app load them as it did in the first backtest run? |
[2024-06-18 03:11:47] |
User61168 - Posts: 403 |
I wonder why on earth these data are needed, and why can't the app load them as it did in the first backtest run?
I am sure SC engineering has good/valid reasons requiring auto-connect during replays. I have also noticed some of the "random" and unexplained issues/symptoms with replays in past releases have significantly reduced. I wish you all the best :-)
|
[2024-06-19 06:27:21] |
gtaranti - Posts: 69 |
To everybody who finds it useful, I may have found a solution to this problem by enforcing a data recalculate on all my dependent charts in the chartbook and a reload and recalculate on the main chart. After the end of each backtest I have added code in the custom study that does exactly this: sc.RecalculateChart(3); sc.RecalculateChart(4); sc.RecalculateChart(5); sc.RecalculateChart(8); sc.FlagToReloadChartData = 1; // affects only the chart the custom study is running I've observed that now, after each backtest run, the next backtest starts normally without stalling on the dreaded "Downloading Continuous Contract Data" message. As a sidenote, I wanted to have the ability through SC API to reload and recalculate a specific chart in the chartbook by having the FlagToReloadChartData as a function, but this works for now as it is. |
[2024-06-19 11:01:26] |
Sierra_Chart Engineering - Posts: 17198 |
Regarding post #1 this does not make sense. A back test has no association with the downloading of historical data. None at all. A back test does not trigger downloading of historical data. There is no association at all. Such functionality does not even exist. The only thing we can think of is that if the back test is causing Sierra Chart to freeze, maybe it is losing the connection to the data feed. And then when Sierra Chart becomes responsive there is a new connection. However, there is not going to be re-downloading of data. Only a quick check for missing data at the end of the chart data file. Something else is going on that we are not aware of in your particular case. This is definitely completely untrue: The auto-reconnect/download at the onset of replay and also at the end of replay is a biggest pain introduced in recent releases.
There is nothing new at all. When you start a replay, chart data does have to be loaded from the local file, and when a replay is stopped, the chart data also has to be reloaded. But there is no remote downloading of data. 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, use the Teton service: Sierra Chart Teton Futures Order Routing Date Time Of Last Edit: 2024-06-19 11:04:15
|
[2024-06-19 12:39:00] |
Sierra_Chart Engineering - Posts: 17198 |
Before you start back testing: Follow the instructions here to clear the Message Log: Message Log: Clearing the Message Log And then when the back test is finished and then you notice Sierra Chart downloading historical data, wait for the data downloaded to complete and then provide the Message Log: Support Board Posting Information: How to Post Your Message Log (Required In Some Cases) We only want to hear from the user who started this thread and then we will understand what is happening in this particular case. If there is something unexpected going on we will find a solution. 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, use the Teton service: Sierra Chart Teton Futures Order Routing |
[2024-06-19 13:02:34] |
gtaranti - Posts: 69 |
Thanks Sierra_Chart Engineering for trying to look into this. For the time being I have sucessfully tackled the issue (see post #14 in this thread) To understand this better, let me say that I've created an automatic backtest runner custom study, in where some inputs of the actual trading custom study are changed (ie. Smooth Moving Average length range from 10 to 20). The time period is 2020-now, symbol NQ 100, tick data. The file size of the files is significant (~1.2Gb each) and I needed as accurate backtests as possible, that's why I opted for the settings in post #5. Each backtest with these settings, takes a couple of hours, so automating them to run back-to-back was something that I wanted. My chartbook has one chart (on which the custom auto trading study and the backtests runner study are on) and 4 other charts which have different timeframes of the the same symbol and I use them in the main auto trading study. The issue which I had was that after the first backtest, all charts in the chartbook showed the message "Downloading Continuous Contract Data" and stuck there forever (I mean hours). I had to go to each chart and select Chart >> Reload and Recalculate for the backtests runner study to go on and perform the next run (which it did) After adding the relevant code of post #14 which is executed when the sc.GetReplayHasFinishedStatus() condition is true, my issue is resolved. If I ever have this problem agian, I will follow your suggestion of posting Message Log contents. Thanks again. |
To post a message in this thread, you need to log in with your Sierra Chart account: