Cannot implicitly convert type double to DataSeries
Author: gpwr
Creation Date: 10/25/2008 11:58 PM
profile picture

gpwr

#1
I get this error after compiling the following code
CODE:
Please log in to see this code.


If I declare spr[] as double[] spr = new double[], then I get the error about PlotSeries. What should I do? Can somebody point me to a strategy code example of computing a moving average and plotting it on the price pane?

I downloaded my Wealth-Lab Pro 5 from Fidelity but I can not find the manual in the installation directory. Is there a manual describing the WL 5.1 script?

Thanks.
profile picture

Eugene

#2
QUOTE:
Can somebody point me to a strategy code example of computing a moving average and plotting it on the price pane?

Currently, Fidelity is reviewing their API documentation - that's why the article on creating indicator libraries isn't available. For now, you can find Visual Studio source code for TASCIndicators and Community.Indicators in WL5 Wiki or explore Indicators chapter of the WealthScript Programming Guide (it's under the Help menu).

Why are you trying to create a DataSeries array dependent on the number of loaded bars (this will vary with your data loading settings)?
profile picture

gpwr

#3
Thanks Eugene. I got my code working after browsing some sample codes posted here and on internet. I am guessing that you are a WL developer. I used WL 4.1 and did not like the language. The new one is much closer to C++, which I use regularly. A couple of more questions:

1. Is there a vector data class in WL5? My task is to extract peaks and dips from the price data and store them in an array. Since I do not know the number of peaks and dips ahead of time, I need something similar to a vector or dynamically sizeable array.

2. I was sorry to see that you kept WL4 bar counting: 0 is the first bar and Bars.Count-1 is the most recent one. If you made it the other way (0 is always the most recent bar), it will be much simpler to program a strategy.

Thanks for your efforts to make WL more appealing to traders!
profile picture

Cone

#4
I don't following the logic about how bar counting in reverse can help program a strategy, and I'd even go so far as to say that's nonsensical. I know that it makes sense to find peaks and troughs working in reverse, but when backtesting a strategy, you need to start from the beginning and work to the end of the chart to avoid peeking, and, this way the same bar doesn't change numbers as new bars are added in a streaming chart.

The compiler is C#, so you can use any C# method. An array of DataSeries isn't the right choice for your task. Use an ArrayList or a generic List.
profile picture

gpwr

#5
I tried ArrayList and WL gave me an error message that the type or namespace could not be found. The generic list works. Thanks. One more question. I tried to use System.Console.WriteLine() to display some debugging info on the console, but I am not seeing a console. In the earlier version of WL, the info would show on the chart pane. But, it is not there either. Where does the information from System.Console.WriteLine() go to?
profile picture

Cone

#6
ArrayList is in System.Collections - add a "using" for that.

Someone else will have to tell you exactly what eats the Console.WriteLine output, but since scripts aren't console apps, I wouldn't expect to see one pop up. Use PrintDebug to send output to the debug window.

CODE:
Please log in to see this code.
profile picture

Eugene

#7
QUOTE:
In the earlier version of WL, the info would show on the chart pane. But, it is not there either.

You could use AnnotateChart or other cosmetic function.
profile picture

gpwr

#8
Thanks everybody. The math portion of the code is working fine now and I can see messages in the debugging window. I started coding the entry and exit points. I have a fundamental question about how the backtesting in WL works. Say I have a code whose first part detects if there is a neck and shoulder formation right before the last bar (Bars.Count-1). Can I just write ShortAtMarket(Bars.Count,"neckline is broken")? Will the backtester change Bars.Count automatically? Or, is is my job to create the loop for the backtester to change the last bar? In other words, which code is correct:

Code A (correct if BackTester changes Bars.Count automatically):
CODE:
Please log in to see this code.



Code B (correct if BackTester does NOT change Bars.Count automatically):
CODE:
Please log in to see this code.


As you can see, if the backtester automatically changes Bars.Count and restarts the execute portion of the code for a new Bars.Count, then Code B will be calculating a pattern Bars.Count-StartBackTest times each time Bars.Count is changed. On the other hand, if the backtester does not change Bars.Count automatically, then Code A will just compute the pattern once for the most recent bar. So, which one is correct?
profile picture

Eugene

#9
Code B is correct.
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).