Okay, here´s my shot to create a method that can handle any number of columns in the file and load it to an array containing the series.
Unfortunately I need some more help, as I absolutely dont know why I get "Object reference not set to an instance of an object:
CODE:
Please log in to see this code.
Size:
Color:
1. Because with this, instead of working with Series[0], continuing to Series[1] etc., you're starting with Series[1] and then going out of range:
CODE:
Please log in to see this code.
Either fix it with
Series[i-1], or rewrite the loop like this:
CODE:
Please log in to see this code.
2. Another error:
CODE:
Please log in to see this code.
Should be:
CODE:
Please log in to see this code.
Size:
Color:
Now its working great. I suggest swapping it with the current community.components method since its more flexible.
Size:
Color:
Swapping wouldn't feel great for those people who are already using the original method (and would have to fix their Strategies as the result), but there's no problem adding your idea as a 3rd overload to FillSeriesFile. I'll also work on getting string replacement (i.e. "," to ".") done much faster.
Size:
Color:
That would be great. Thank you Eugene.
I still use
CODE:
Please log in to see this code.
although my decimal separator is ",". You should also have a deeper look into that.
Size:
Color:
That's a mystery to me.
Size:
Color:
I have another sort of files where I´d like to create a Series from.
The file contains information about divdends, stock splits etc. and looks like this:
QUOTE:
05.03.2008 09.05.2008 08.05.2008 09.05.2008 0,5 Annual Regular Cash 1,0000
07.03.2007 11.05.2007 10.05.2007 11.05.2007 0,42 Annual Regular Cash 1,0000
The second colum should be the corresponding bar of the symbol, so I started with this code:
CODE:
Please log in to see this code.
I get the following print:
QUOTE:
05.03.2008
05.03.2008 00:00:00
07.03.2007
07.03.2007 00:00:00
11.05.2006
11.05.2006 00:00:00
02.03.2006
02.03.2006 00:00:00
09.03.2005
09.03.2005 00:00:00
10.03.2004
10.03.2004 00:00:00
30.01.2003
30.01.2003 00:00:00
08.05.2002
08.05.2002 00:00:00
10.05.2001
10.05.2001 00:00:00
11.05.2000
11.05.2000 00:00:00
20.05.1999
20.05.1999 00:00:00
07.05.1998
07.05.1998 00:00:00
28.05.1997
28.05.1997 00:00:00
30.05.1996
30.05.1996 00:00:00
error: String was not recognized as a valid DateTime.
error: String was not recognized as a valid DateTime.
...
Something seems to be wrong with the format, I am calling the method with this line:
CODE:
Please log in to see this code.
Any hints?
Size:
Color:
So, there might be an incorrect string after 30.05.1996 00:00:00.
Size:
Color:
Ahhh. There are lots of empty rows in the file after that until the end of the file.
Size:
Color:
Empty rows should be handled with an extra check, something like String.Empty or .Length > 0.
Size:
Color:
Yes, I will add a check for empty lines. Thanks for your help!
Size:
Color:
I think an overloaded call to FillSeriesFromFile returning an array of DataSeries would be a useful addition.
Size:
Color:
Hi Eugene,
I have a question regarding FillSeriesFromFile:
if I have a file where the date from the last row does not match the date from the last bar, then WLD just takes 0 as the value for the last bar for the imported dataseries. How can this be handled so that, i.e. the dataseries import throws an error/execption or informing the user about it?
regards,
dansmo
Size:
Color:
Hi Daniel,
Have you tried the exactMatch parameter or am I missing something?
Size:
Color:
It does not make any difference. The value is zero for the dataseries that bar.
Moreover I still cannot use the FillSeriesFromFile Method from Community.Components but use my own method due to my regional decimal separator format.
Size:
Color:
QUOTE:
Moreover I still cannot use the FillSeriesFromFile Method from Community.Components but use my own method due to my regional decimal separator format.
It's up to you of course, but the choice of custom separator was added to FillSeriesFromFile in one of the previous releases.
QUOTE:
It does not make any difference. The value is zero for the dataseries that bar.
Still not sure w/o looking at an example, but new DataSeries are usually initialized with zeroes, which can be changed to an arbitrary value in your code.
Size:
Color:
QUOTE:
It's up to you of course, but the choice of custom separator was added to FillSeriesFromFile in one of the previous releases.
No, you mean the
Separator char used to isolate dates from the series.
I mean the
decimal separator.
QUOTE:
Still not sure w/o looking at an example, but new DataSeries are usually initialized with zeroes, which can be changed to an arbitrary value in your code.
Example:
DataSeries data from File:
date;value
20110410;10
20110411;15
20110412;13
Symbol data:
date;close
20110410;50.40
20110411;50.70
20110412;50.25
20110413;51.30When I use FillSeriesFromFile with aboce data, the dataseries shows zero for the last bar. However, there is
no value at all for that date. I´d like to check that when executing the script, since this would cause unintended behaviour for my trading signals. And since the dataseries can have zero values, scanning for zeros is not an option.
Size:
Color:
That's by design: all DataSeries contain the same number of values as bars in the chart.
If zeros are not an option, in the body of your
FillSeriesFromFile analog you can initialize the DataSeries as you like e.g.
CODE:
Please log in to see this code.
Size:
Color:
Where do you mean I should insert that? I cannot figure it out.
CODE:
Please log in to see this code.
Size:
Color:
Hope this helps:
CODE:
Please log in to see this code.
Size:
Color:
Think I can work with that. Thank you.
Size:
Color: