Combination Strategy error message
Author: wl64bit
Creation Date: 6/21/2011 11:27 PM
profile picture

wl64bit

#1
“Runtime Error: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index”
Gives this error while I am trying to back test a strategy through a Combination Strategy but does not give this error while I back test it in a single strategy mode.
profile picture

Eugene

#2
Not enough details.
profile picture

wl64bit

#3
This error pops up when a strategy uses GetExternalSymbol("^NDX", true); while ^NDX symbol is not located in the tested DataSet. We do not have this problem while testing in the old single strategy mode.
profile picture

Eugene

#4
I think it's rather a provider/provider data access issue.

When requesting this Yahoo! symbol, on which data provider(s) you're running the Combo child strategy?
profile picture

wl64bit

#5
It looks like it does not matter which provider you use because this problem persist with Fidelity and ASCII datasets. I have not tried other datasets yet.
profile picture

wl64bit

#6
Another issue is :

While single strategy backtest reports errors in the debug window, Combination Strategy does not proceed with the testing and does not give any results if there is any error in processing a symbol in the tested dataset.

Here is an example from the Debug window:
Error processing symbol AAIR Basis price for Position entry cannot be zero.

Here is the error of the Combination Strategy popup:

---------------------------

---------------------------
Runtime Error: Basis price for Position entry cannot be zero
---------------------------
OK
---------------------------
profile picture

Cone

#7
The design is abort script processing when an error is detected. In this case, it seems to be pointing to a possible error in the data or a zero value passed to a BuyAtLimit or ShortAtStop order.
profile picture

wl64bit

#8
Is there any way to change this design to work the same way as single strategy does?
profile picture

Eugene

#9
What is easier to change, the design or add a try/catch block in your code?
profile picture

wl64bit

#10
There could be so many different errors to catch or fix. Why would we need to abort script processing while there is an error? It is much more convenient to report it in the Debug window and skip the symbol, the way single strategy does.
profile picture

Cone

#11
I see your point now. Please create a Support Ticket so that the issue doesn't get lost in the shuffle and we'll look into it.

For now however, it is what it is, so you'll have to find a workaround like the one Eugene suggested with try/catch.
profile picture

wl64bit

#12
Any news about correcting this problem? Without fixing it, it is impossible to enjoy using the combination strategy mode in most cases.
profile picture

Eugene

#13
It's an open issue:

Open Issues

"(30461) Runtime error in one Strategy aborts Combination Strategy Run"
profile picture

wl64bit

#14
Is there any timeline for resolving those issues?
profile picture

Cone

#15
"Those issues" No.

The streaming bug and potentially other bugs related to Synchronize() will be fixed in a "patch" release. A timeline doesn't exist, but I'd say it's reasonable to expect something before October.
profile picture

wl64bit

#16
Any news about the "patch" or new release?
profile picture

Cone

#17
It was going to happen last Wednes, but QA had trouble with an update task. That's resolved, but they had to find another launch window - not sure precisely when it will be, but almost for sure it's in the next 2 weeks.
profile picture

wl64bit

#18
It looks like they have not fixed it in the new release.
profile picture

Cone

#19
Hopefully my 8/26/2011 10:28AM response didn't give you the impression that the issue in this thread was supposed to be targeted in the patch release, whose primary purpose was to address the Fidelity Streaming issue.
profile picture

Ben_Zurich

#20
I am experiencing the same thing, when combining two strategies that both use external symbols.
Upon inserting try/catch blocks on both strategies, and displaying the exception in the debug window, I'm getting:

System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at System.ThrowHelper.ThrowArgumentOutOfRangeException()
at System.Collections.Generic.List`1.get_Item(Int32 index)
at WealthLab.DataSeries.get_Item(Int32 i)
at WealthLabCompile.ECRI_double_EMA.Execute()
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at System.ThrowHelper.ThrowArgumentOutOfRangeException()
at System.Collections.Generic.List`1.get_Item(Int32 index)
at WealthLab.DataSeries.get_Item(Int32 i)
at WealthLabCompile.USuptrend.Execute()

But this does not really help me. Is there a circumvention?
profile picture

Cone

#21
See Index out of range near the bottom of that linked page.

The first thing to try is to disable Benchmark Buy & Hold. If that doesn't help, you have to find the piece of code that is potentially addressing an index that's out of range... you're not catching this one with try/catch.
profile picture

Ben_Zurich

#22
I have found the "piece of code" and was able to prove that the combination strategy definitely does not work with external symbols:

Let's assume we have the base symbol of SPX

Without External Symbol:

DataSeries INDEX = Bars.Close;
DataSeries INDEXEMA = EMA.Series(INDEX, parameter, EMacalcparameter);
value = INDEXEMA[bar] works for any bar in the range

With External Symbol:

DataSeries INDEX = GetExternalSymbol("SPX", true).Close;
DataSeries INDEXEMA = EMA.Series(INDEX, parameter, EMacalcparameter);
value = INDEXEMA[bar] works with NO bar at all in the range, INDEXEMA is virtually empty when used in a child strategy within a combination strategy

Note that I have taken the same symbol, namely SPX, for base and external symbol in order to avoid possible synchronization problems between the base and the external symbol.

We ALWAYS use external symbols and apply the results to the base symbol and one of the reasons why we changed to WL6 was the combination strategy. If this is not working it is virtually useless for us.

This bug has been reported back in June 2011 an I really wonder why it has not been addressed and apparently is considered as a minor issue.

Will this issue be adressed at all and when yes would this be a high priority ?

I will make a ticket for this.
profile picture

Eugene

#23
QUOTE:
I will make a ticket for this.

Let's wait a bit.

Give the community a little credit. :) Someone else would have noticed that external symbols "definitely" (your word) do not work in Combo strategies. (They found the 6.2 NamedSeries bugs immediately, didn't they?)

Furthermore, the bug reported in June is different from your issue (I did not say "bug"). Compare your error message (AOOR) with their (IOOR). My impression is opposite: GetExternalSymbol works in Combo strategies. Take any published code using GetExternalSymbol, for example "ActiveTrader 2010-07 | Improved R2 Strategy" has been in the wild for a long time, add just it to a new Combo strategy with 100% allocation, run the combo and original strategies on the same DataSet or symbol (preferably Yahoo! Dow 30) and you'll see that it works and their performance results will match.

So I'd suggest you to 1) review your Strategy code for possible errors and 2) make sure that it's not a glitch in the data provider you're using to make external symbol data requests.
profile picture

Ben_Zurich

#24
It IS the same error: I'm getting the same "Runtime Error: Index was out of range. Must be non-negative and less than the size of the collection." as reported in the first post. The first post does NOT report the exception text. It happens at the simple statement: value = index[bar], for all bars!

Before I look for a workaround:

First Question: How can it be that a series is filled in siglee mode and empty in combination mode?

Second Question: Look at the difference of the two code snippets: How do you explain that it works when I take the symbol SPX as base series and that it doesn't work when I take the very same series SPX as an external symbol. The rest of the code (see ticket attachment) is EXACTLY THE SAME. How do you explain this? Is this normal behaviour?

You know, I believe you that there is SOME code around, even with external symbols, where the problem doesn't occur. To find this would probably give me a hint how to avoid the problem. But it is certainly not a solution to the problem. It would be a workaround.

Do you still think it's my problem (i.e. assuming this all is normal behaviour and exactly how it is intended to be)?
profile picture

Eugene

#25
Re: June 2011. Runtime errors aborting Combo strategy runs are in scope for 6.3. The only interim release since 6.2 - the 6.2.46 patch - aimed solely at fixing a pesky problem that prevented streaming strategies from generating an Alert, causing the system to miss entry/exit signal.
QUOTE:
First Question: How can it be that a series is filled in siglee mode and empty in combination mode?

In general, there's enough rope in C# to shoot oneself in the foot - for example by putting PrintDebug in a class's constructor (tongue-in-cheek).

Having just executed your Strategy code (ticket #21560) in a new Combo strategy successfully using Yahoo! data, I think the problem might have to do with external symbol lookup by a 3rd party provider. The provider could be the culprit, and the Debug window output can prove or disprove it. Try replacing SPX with different symbols.

QUOTE:
Do you still think it's my problem (i.e. assuming this all is normal behaviour and exactly how it is intended to be)?

The topic starter claims that "This error pops up when a strategy uses GetExternalSymbol("^NDX", true); while ^NDX symbol is not located in the tested DataSet." I can neither reproduce that nor your error (which appears to be the same, according to your reply). The use of ^NDX implies Yahoo! data, and my ^NDX belongs to a different DataSet.
profile picture

Ben_Zurich

#26
Now that's interesting. It still puzzles me why it works in single strategy mode.
I have to go now and look further on Monday. Thank you for testing this.
profile picture

Ben_Zurich

#27
(A) We are using BBloader to generate our data (.WL files) on a daily basis, among those the SPX.WL mentioned in my previous post, besides thousands of other symbols. There are no streaming data involved. Using "Yahoo" symbols is not an option for us as Yahoo simply doesn't have the data we need. We don't really need SPX. It was just taken as an easy example.

(B) Apparently this data is in the correct format as it works perfectly in single strategy mode. Therefore I see no need to change anything here, except you tell me exactly what to change, data format or program-wise, in order to bypass the problem.

(C) You wrote: "Runtime errors aborting Combo strategy runs are in scope for 6.3." Will this problem be addressed in Release 6.3? When will this release be coming out?


PS: You wrote: "In general, there's enough rope in C# to shoot oneself in the foot - for example by putting PrintDebug in a class's constructor (tongue-in-cheek)." Something like this I do only when the program environment does not function as expected. When indicator parameters did not update as expected, I wanted to know whether they are initialized correctly. Later I learned that sometimes it is mandatory to click in the window "Strategy Parameters" to the lower left. Otherwise the perameters would not initialize correctly.







profile picture

Ben_Zurich

#28
We are generating our data (.WL files) with BBloader on a daily basis, among them SPX.WL (see example above), along with thousands of others. Yahoo is not an option for us as most of the required data is not available there.

As these data work perfectly in single strategy mode, I see no need to make any changes to our programs or data, except you tell me exactly what to change as a workaround until the problem is fixed.

You wrote "Runtime errors aborting Combo strategy runs are in scope for 6.3." Will this problem be addressed as well in this release? When will it come out?
profile picture

Eugene

#29
How well they function in single strategy mode is not important at this point. I suggested you to run a few tests using Yahoo! data, as mentioned above, to test for hypothetic issues with external symbol lookup by the 3rd party provider rising in Combo mode. Hence I'm at a loss as to what made you think that I was questioning your data integrity, let alone changing your production data feed, if I wasn't telling that?

If you would kindly let us technicians to "see the need" and to decide which tests could help reproduce the problem, then we might get anywhere. For now, however, refusing to provide the requested information required for troubleshooting will not help solve the issue anyhow. Consequently, I'm sorry but the answer to your 2nd post is no - it's not possible to address an irreproducible problem.
profile picture

Ben_Zurich

#30
OK this was a misunderstanding. I thought that you already have tested it with Yahoo symbols, and erronously assumed it be the same with me.

Now I have inserted the Yahoo Symbol IBM as external symbol and the problem persists: Single strategies execute correctly, and combo strategy produces the reported error.
profile picture

Eugene

#31
Are you sure the IBM is a Yahoo symbol? It can easily exist in other DataSets. Try something really specific like ^GSPC.
profile picture

Ben_Zurich

#32
Now it works with ^GSPC, and later I tried again with IBM and it worked too, probably because I have removed the two strategies from the combo and re-selected it. Then I tried again with one of our symbols and the error re-appeared.
profile picture

Eugene

#33
I'll take a closer look after meeting a deadline.
profile picture

Eugene

#34
And for now, try using the GetExternalSymbol overload where you specify a DataSet:
CODE:
Please log in to see this code.
profile picture

Eugene

#35
Now that I've met my deadline, I think I was finally able to reproduce the bug.

Sorry for the inconvenience and let's hope the developer is able to resolve it in release 6.3.
profile picture

festipower

#36
I'm also experiencing the bug with "GetExternalSeries" in Combination Strategies.
Do you know if this bug and the other "Combination Strategies" bugs are going to be resolved in WL 6.3 ??
When will version 6.3 be released?

I have also noticed that no externally compiled strategies can be selected in "Combination Strategies". What could be the problem?
profile picture

Eugene

#37
I'd not expect to be fixed by 6.3 -- rather 6.4, to be on the safe side.

For your future reference, live bugs (including this one which goes by the 43339 handle) are listed on this Wiki page:

Open Issues
profile picture

Cone

#38
QUOTE:
I have also noticed that no externally compiled strategies can be selected in "Combination Strategies". What could be the problem?
Overlooked? Please create a support ticket for this.

Most Combo Strategy bugs are fixed in 6.3, but not the GetExternalSeries one, which I believe occurs only if the provider of the external series is different than the chart symbol's provider. We don't have dates for 6.3, but it's "soon".. more than days, less than a month, somewhere in between.
profile picture

festipower

#39
Thanks for your quick answers.

I have done some experiments regarding GetExternalSeries, using the same provider for external series and chart symbol (ASCII Provider) and the same problem still happens.
I have also moved the external series symbol to the DataSet of the chart symbol and the problem still happens also.
The problem appears to be happening always when i use both overloaded "GetExternalSeries" methods with ASCII provider (I haven't tested the problem with other providers).
profile picture

Eugene

#40
Ditto.
profile picture

Cone

#41
Okay, my recollection was wrong... it occurs if the the external series is in a different DataSet. Anyway, it looks like there's a good chance this will get fixed in 6.3, time will tell.
profile picture

festipower

#42
That's right: if the external series is in the same DataSet there's not error.

Workaround for the problem:

1.-Create a library project using Visual Studio or SharpDevelop.
2.-Add "WealthLab.dll" & "WealthLabPro.exe" as referencies to the project.
3.-Add a new class file to the project, with the following code:
CODE:
Please log in to see this code.

4.- Compile and place the generated dll file into the WealthLab path.
5.- In Wealth-Lab, in the strategy editor, add a reference to the generated dll.
6.- Add "using TradingSoftware.WealthLab.Utils;
7.- In the Strategy Code, replace the call to "GetExternalSeries(...)" to the call to "MyUtils.GetExternalSeries(this,...)"

profile picture

Eugene

#43
I thought you're a Developer customer? ;)

It's an interesting workaround but it's not universal. It will only work in Wealth-Lab Pro and will not work for Wealth-Lab Developer users who do not have the WealthLabPro.exe file. (Even if they had, it won't work.) Making it function in Developer is possible but would require more code using System.Reflection.
profile picture

festipower

#44
Eugene:

It is curious what can result sometimes from an error: (or not-error) XD

Actually i have Wealth-Lab Developer. (I'm not from the USA).

When i wrote the step 2 in my last post, i was writing from my memory. Where it says "WealthLabPro.exe" it should have said "WealthLabDev.exe".
I confounded the file names because in "WealthLabDev.exe", the namespace to be imported in the code is "WealthLabPro", and i wrote "WealthLabPro.exe" instead of "WealthLabDev.exe".

In Conclusion:
1.- The workaround method described above works for WealthLab Developer, but the reference "WealthLabPro.exe" must be "WealthLabDev.exe"
2.- I haven't tested it in WealthLab Pro, but it should work also (Taking into account what you have said in the previous post).

Regards and thanks for your great work.
profile picture

Eugene

#45
Carlos,

You're right, it will work after referencing WealthLabDev.exe. Just to clarify my point that wasn't clear enough: with some more effort (using Reflection), the code could be made universal, automatically loading the proper assembly (i.e. no need to reference neither WealthLabPro.exe nor WealthLabDev.exe). At any rate, let's cross our fingers & hope that a slight delay with release allows the developers to fix this bug (QC 43339) too.
profile picture

Eugene

#46
The bug #43339 is fixed in 6.3 (coming later this month).
profile picture

wl64bit

#47
Is there any way to add a fix of "(30461) Runtime error in one Strategy aborts Combination Strategy Run" to the next release?
profile picture

Eugene

#48
It's fixed too.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).