I have the following strategy.
CODE:
Please log in to see this code.
This strategy was working great and then I added the loop inside the new loop comments along with the associated processing for the new dataseries. The original strategy would work on a large number of datasets. With the new logic, I get an out of memory error on the 2nd or 3rd dataset.
Can someone see why I am getting this error.
I am also new to C# so if anyone sees programming improvements that I can make to the strategy that would help me learn I would appreciate the help.
Thanks.
Size:
Color:
Here's your bug:
CODE:
Please log in to see this code.
Which creates Close-Close
Close-Close*Close-Close
Close-Close*Close-Close*Close-Close*Close-Close
Close-Close*Close-Close*Close-Close*Close-Close*Close-Close*Close-Close
Close-Close*Close-Close*Close-Close*Close-Close*Close-Close*Close-Close*Close-Close*Close-Close
...
Many thousands of times. I guess you get the picture. Here's what I think your code intended to do originally:
CODE:
Please log in to see this code.
Size:
Color:
Eugene,
I modified the part inside the comments to this:
CODE:
Please log in to see this code.
and I am still getting the out of memory condition. Do you see something else wrong?
I do not understand why "WorkSeries = WorkSeries * WorkSeries;" gets expanded as you show. Can you explain?
Size:
Color:
Simple: you're creating WorkSeries * WorkSeries times series. For each symbol in the loop. Try applying the approach to rest of the code with similar series manipulation (addition, subtraction etc.)
Size:
Color:
Eugene,
I made all of the series calculation changes that you suggested and it still did not work. I then tried adding a statement "DataSeries ZeroSeries = Close - Close". I made each of the statements in the beginning that zeroed a series = to ZeroSeries and then did the same with the statements at the end. Suprisingly, after making the simple changes to zero the series, it ran ok.
Since it did not work until I put in the zero series changes, I went back to the original script above and just made the zero series changes. It did not work. It took all of the changes mentioned above to get it working.
Thanks for your help.
Size:
Color:
Eugene,
The plot thickens. I believe there is a bug in some of the DataSeries logic in WLP as this strategy illustrates
CODE:
Please log in to see this code.
Look at the value of a in the debug window. I believe there are also other combinations of logic that will give the wrong answer for b and c.
Size:
Color:
I would not call that a bug. You declared a series, created two more, and assigned to them a
reference to the first series. Even though the value has changed, the data within the data series it used to refer to hasn't. Please consider taking a moment to read some good source illustrating the concept of reference and value types in C#.
What you did was not a "zero series". To properly initialize a DataSeries, create a new zero-filled DataSeries:
CODE:
Please log in to see this code.
Now compare the Debug log.
Size:
Color:
Thanks Eurgene, that's been a big help.
Size:
Color: