129.302 Urgent - MultiTF code produces max number of bars error in MultiCharts

I cannot tell if this is user error or not but I have tried everything to get the output source code to work in MC. The source code compiles just fine but I always get this error : Not enough series length.



After researching in MC threads I have tried increasing the maximum number of bars to 1500 but I still get the same error.


All my data is correct and I am loading thousands of bars while my max period on any parameter in the strategy is less than 200

Attachments
Screen Shot 2020-08-19 at 120009 PM.png
(239.78 KiB)
Screen Shot 2020-08-19 at 120053 PM.png
(164.92 KiB)
Screen Shot 2020-08-19 at 120149 PM.png
(166.40 KiB)
Screen Shot 2020-08-19 at 115925 AM.png
(72.86 KiB)
Screen Shot 2020-08-19 at 115945 AM.png
(988.82 KiB)
Screen Shot 2020-08-19 at 120115 PM.png
(151.56 KiB)
  • Votes +2
  • Project StrategyQuant X
  • Type Bug
  • Status Fixed
  • Priority Normal

History

KL
#1

kainc301

19.08.2020 18:08

Task created

KL
#2

kainc301

19.08.2020 18:11

Attachment YM_1H_mc_multTF.pla added

Attachment YM_1H_mc_multTF.sqx added

YM_1H_mc_multTF.sqx
(353.66 KiB)
YM_1H_mc_multTF.pla
(11.01 KiB)
If there is anything I am doing incorrectly in my setup to cause this please let me know as I need to find a solution to this as soon as possible. If there is nothing I can do, it may have to do with the strategy itself. However, I looked at the source code and could not find anything wrong.
KL
#3

kainc301

19.08.2020 18:13
Also this error is occurring on any multi tf strategy i build for any asset.
KL
#4

kainc301

20.08.2020 20:07
Voted for this task.
KL
#5

kainc301

25.08.2020 00:44

Attachment Screen Shot 2020-08-24 at 63705 PM.png added

Screen Shot 2020-08-24 at 63705 PM.png
(204.36 KiB)
So while investigating this is what I found. Each strategy I produce has a different value it gets different errors for above or below a certain value. What is even weirder is that sometimes, this value creates a divide by 0 error. 


What I can conclude so far whatever this value is related to is not the periods in the indicators of the strategies. In the errors in these screenshots, the max period used by an indicator in the strategy was over 100. Yet MultiCharts was looking for a value near 79. 


Because I am getting a div by 0 error on some strategies, I can at least assume this value is used in a division function somewhere. Since its a different value for each strategy, it may be in the generated MC code and not relative to the main indicator logic of the strategies.

KL
#6

kainc301

25.08.2020 00:48

Attachment Screen Shot 2020-08-24 at 64528 PM.png added

Screen Shot 2020-08-24 at 64528 PM.png
(779.32 KiB)
In the strategy I submitted, the value 200 for the Maximum number of bars referenced seems to work.


But the value to make the strategy work is different for each one, and as explained above, does not exhibit the same behavior for each strategy when adjusting this parameter in MultiCharts. 

KL
#7

kainc301

25.08.2020 00:54

Attachment Screen Shot 2020-08-24 at 65004 PM.png added

Attachment Screen Shot 2020-08-24 at 65154 PM.png added

Screen Shot 2020-08-24 at 65154 PM.png
(138.93 KiB)
Screen Shot 2020-08-24 at 65004 PM.png
(70.84 KiB)
As you can see the value 200 does not work for other strategies. My global indicators period is a max of 100 for every chart. 


Side note, Ichimoku seems to ignore the global indicator period max value. Most of my strategies using Ichimoku use periods of over 100.

KL
#8

kainc301

25.08.2020 03:02
I may be wrong about this not being related to the indicators used. When I looked at strategies with similar indicator code and settings, the value for both converged on the same number while other strategies that had different indicator code converged on different values. I really don't know what could be causing this. My only guess is that some indicator throws off the value of the variable MC needs to use to determine the max number of bars required by the strategy properly.
KL
#9

kainc301

25.08.2020 22:24
Here is the documentation on Max Number of bars


https://www.multicharts.com/trading-software/index.php?title=Strategy_Properties


Based on the description, I believe some value in the generated final code is somehow affecting this value on every strategy and it does not appear to be a user error

KL
#10

kainc301

02.09.2020 04:04

Attachment Screen Shot 2020-09-01 at 95555 PM.png added

Attachment Screen Shot 2020-09-01 at 100305 PM.png added

Screen Shot 2020-09-01 at 100305 PM.png
(73.36 KiB)
Screen Shot 2020-09-01 at 95555 PM.png
(72.86 KiB)
Here is an example of a divide by 0 error when entering the value for Max Number of bars that MC converges on. The strategy itself has no periods which are 0 in any of the indicators yet some value is make a divide by 0 error. 
KL
#11

kainc301

02.09.2020 04:09
Also now for some reason the strategy I submitted earlier is not working with the value of 200 that made it work before. No idea what this could be. I read all the source code from the MC strategies in the MC editor. 


Is it possible there is a variable MC is expecting to be a specific value for max number of bars and however this is calculated is incorrect?

TB
#12

Tomas Brynda

09.09.2020 07:36

Status changed from New to Fixed

Hi,

I think your problem is that you don't have enough data for all the symbols used by strategy in your Multicharts.


The number of reserved bars needed by Multicharts depends on the strategy logic - mostly indicators periods.


I tried to test the attached strategy and 200 reserved bars are enough, but I had to make sure I have enough history for all symbols, otherwise it threw the error you posted.



Hope it helps


Best regards,

Tomas

KL
#13

kainc301

10.09.2020 01:25

Attachment image-0.png added

image-0.png
(220.63 KiB)
I have a history for all symbols though. way more than enough. And the value 200 is not a universal per strategy. It changes. I can load as many bars into these instruments as I want and I still have the same problem. So can you please advise on how to get enough data for the symbols used? I thought it was the range. Here I am using thousands of bars back in this example. I have also done the same thing with using 300 days for the daily chart.


Is there a different way you are loading data into MultiCharts????


251a4ec80afa005.png

TB
#14

Tomas Brynda

10.09.2020 07:45
From your screenshot I can see that you have only 80 bars available on YM D1. That's probably the problem.


Please note that the number of reserved bars is applied BEFORE the start date of the backtest. So if 200 bars are enough for this strategy, you need to have data for your backtest date range + 200 bars before backtest start date.

KL
#15

kainc301

10.09.2020 11:30

Attachment Screen Shot 2020-09-10 at 52303 AM.png added

Attachment Screen Shot 2020-09-10 at 52225 AM.png added

Attachment Screen Shot 2020-09-10 at 52710 AM.png added

Screen Shot 2020-09-10 at 52710 AM.png
(110.40 KiB)
Screen Shot 2020-09-10 at 52225 AM.png
(184.35 KiB)
Screen Shot 2020-09-10 at 52303 AM.png
(448.84 KiB)
Im sorry but you are mistaken. I have tried changing the value of the daily chart and it does not change the result. Here is a screenshot with the same error. As you can see. none of the parameters are above but it is still trying to access over 200 bars for some reason. I have 300 bars loaded for the daily. This is a SERIOUS problem and isn't solved by simply changing the range. I have tried that for hours 



KL
#16

kainc301

10.09.2020 11:31

Attachment Screen Shot 2020-09-10 at 52942 AM.png added

Attachment Screen Shot 2020-09-10 at 52932 AM.png added

Attachment Screen Shot 2020-09-10 at 52923 AM.png added

Screen Shot 2020-09-10 at 52923 AM.png
(75.69 KiB)
Screen Shot 2020-09-10 at 52942 AM.png
(36.78 KiB)
Screen Shot 2020-09-10 at 52932 AM.png
(182.16 KiB)
Further proof. Tried changing the amount of bars to load to over 1000 for each market and max bars back to 500 and got a div by 0 error. None of this is making any sense. Simply changing this value is NOT the solution. 
KL
#17

kainc301

10.09.2020 11:33
Please look deeper into this. I have tried everything and don't know why I can't get any of my strategies to work. This has been the error that has hit the hardest so far as I can't deploy anything
KL
#18

kainc301

14.09.2020 19:43
This is still not fixed. Please unmark it as fixed. This is a huge problem
TB
#19

Tomas Brynda

15.09.2020 08:01

Status changed from Fixed to In progress

I'm trying to simulate the issue with no success. Everything works for me.

Please upload the exact history data you use here: https://drive.google.com/drive/folders/1ab-xmLabmSqkUFO7ztQlTFoBhuqUPtpf?usp=sharing so I can reproduce it.

It looks like there's some problem with the data


KL
#20

kainc301

15.09.2020 13:26
Okay this might be where the problem lies. 


I do not know where to import/export data directly to and from MultiCharts. I trained the strategies over your futures data but never imported any historical data into MC. Instead, I just connected MC to my Rithmic Data feed and whenever I change the number of bars to load, MC downloads the data from Rithmic on the fly. Is there a different process I should be following for data import into MC? My assumption was you didn't need to upload the entire 10+ years of data from SQX into MC because that data shouldn't be needed to trade the strategy. But if I am mistaken about this please let me know. 


I will look into how to export data from MC. If you have any guides on this, that would help.

TB
#21

Tomas Brynda

15.09.2020 14:33
You don't need to export the data from SQX and import them into MC to be able to trade the strategy. But it is a good practise to backtest the strategy in SQX and MC given the exact same data in both platforms to compare the cross platform results. You should check if it matches before attaching the strategy to a live chart.


You can either export your history data and import it into SQX or export the data from SQX and import it into MC.


You can begin here: https://strategyquant.com/doc/strategyquant/reliable-backtesting-in-tradestation-multicharts/ and then go through our documentation and blog. You should find some relevant info there.

If you still struggle, you can contact our guys on support and they will help you.




KL
#22

kainc301

16.09.2020 23:17
I still don't understand what to do. The guide in that link is just for backtesting in SQX. Backtesting in MC strategies SQX works fine. I need it to work for real trading in MultiCharts because it won't backtest in the MultiCharts platform. I tried importing data into MultiCharts and it would not let me import my SQX data into the QuoteManger. Since I have no idea what else to do, I'm going to try and produce a few more strategies that should show this behavior within MultiCharts. 


I have sent emails into support and not heard back. 

KL
#23

kainc301

05.10.2020 22:09

Attachment Screen Shot 2020-10-05 at 40733 PM.png added

Screen Shot 2020-10-05 at 40733 PM.png
(46.29 KiB)

So it took me forever but I finally figured this out. I was getting two errors that were unrelated. As for the max number of bars error, this is caused because of the Ichimoku Indicator and the periods associated with it. For some reason, MultiCharts adds these periods together. So if the Senkou Period is 150 and the KijunPeriod is 100, Multicharts will add these together and the max number of bars will be 250 instead of the max number of a given period which would be 150. Also I needed to make sure all subcharts loaded more bars than the value of the combined periods. I just set all charts to 1000 bars, set the max number of bars on each strategy to a value above the combined Ichimoku periods and everything worked.


The second error was the divide by 0 error. This is unrelated and actually has to do with a bug I posted here where SQX generates 0 values for parameters it shouldn't: https://roadmap.strategyquant.com/tasks/sq4_6900


In this case, my strategy had a profit target that was 5.5 x ATR(0) where the period of the ATR is 0. MultiCharts cannot accept a 0 value period of the ATR.  This is definitely a bug because the range I set for developing strategies was between 5 and 50. The minimum was never 0. MultiCharts just gives the next error once the previous one is resolved which is why I thought this was related to the max bars back but it is not. Once I changed the ATR period from 0 to 1, the divide by 0 error disappeared and my strategy loaded up correctly

h
#24

hankeys

06.10.2020 07:16
Voted for this task.
TB
#25

Tomas Brynda

06.10.2020 07:34

Status changed from In progress to Fixed

Hi,

thanks for the info. I'm glad that you figured out where the problem was.


I'm closing this task and will take a look at the issue with zero period.


Best regards,

Tomas


Votes: +2

Drop files to upload

or

choose files

Max size: 5MB

Not allowed: exe, msi, application, reg, php, js, htaccess, htpasswd, gitignore

...
Wait please