Hi,
I'm creating an indicator and work with minute data.
The indicator does not create a value for each bar, so I synchronize the resulting dataset.
Everything works fine working with daily data,
But for minute data the dataseries has for the whole day the data for the first bar of the day after synchronizing.
Any idea what I'm doing wrong?
br
Erich
Size:
Color:
Hi Erich,
We've got nothing to work with. Please provide the information necessary for troubleshooting your code:
* Strategy code
* 1) Data provider(s) involved, 2) symbols, 3) bar scale, and 4) data loading settings
* To clarify explanations, send a screen shot by striking the "Print Screen" key and then pasting into Paint or other imaging application. Save as PNG and click "Add attachments" when replying
Thanks.
Size:
Color:
Hi Eugene,
thanks for the very prompt reply :-)
I minimized the code for reproducing the behaviour:
CODE:
Please log in to see this code.
I use two dataset with IQFeed as datasource with VXX as Symbol. One dataset has daily data, the other data in Minute (screen1).
Now start the strategy with the daily data. Everything is correct, the "indicator" Shows as value every third open. (screen2). This is what I expect.
Now use the same strategy with Minute data. as you can see, the synchronize does not work correctly. (screen3)
Any ideas?
br Erich
Size:
Color:
Screenshot was missing
Size:
Color:
Erich, give this a try:
CODE:
Please log in to see this code.
Size:
Color:
Hi Eugene,
CODE:
Please log in to see this code.
initializes a dataseries in the same size as the Bars b with all values 0. So the result will contain the correct value for every third entry, but 0 for all other. (see screen4)
The expected result would be (according to the documentation of synchronization in WL (especially the second condition):
QUOTE:
· Any date times that are outside the range of the Primary Bars are eliminated from the external series.
· Dates that exist in the Primary Series but not in the external series are added to the external series. The values are copied from the previous bar of the external series.
· Dates that exist in the external series but not in the Primary Bars are eliminated from the external series.
Does synchronization not work on other timeframes than daily?
br
Erich
Size:
Color:
QUOTE:
initializes a dataseries in the same size as the Bars b with all values 0. So the result will contain the correct value for every third entry, but 0 for all other. (see screen4)
Instead of 0, you can assign any value like
Double.NaN and handle it in your code accordingly. Note that according to the WS Programming Guide > DataSeries, "
All DataSeries contain the same number of values as bars in the chart."
QUOTE:
Does synchronization not work on other timeframes than daily?
Of course it works correctly. It's just the manner of populating a DataSeries that leads to this result.
Size:
Color:
Hi Eugene,
QUOTE:
"All DataSeries contain the same number of values as bars in the chart."
Of course - otherwise you can't paint the Chart. But isn't that exactly what the synchronize should do - and is doing correctly for daily data but not for minute data?
Populating the dataseries in the indicator with Double.NaN will result in having a DateTime (from the Bars) and a Value of Double.NaN.
When the indicator now put a value to every third element the other will remain Double.NaN.
What now happens in synchronizing is nothing (expected), because for every DateTime in Bars we have a matching DateTime in the dataseries. There are no data to replicate, because we have all matching datetimes.
The expected outcome of the synchronze methode is (like in documentation)
QUOTE:
· Dates that exist in the Primary Series but not in the external series are added to the external series. The values are copied from the previous bar of the external series.
Again: this works correctly for daily data but not for minute data.
If you confirm it's a bug, it's also ok for me - then I'll implement my own synchronization. But if I missunderstood the use of synchronize it would be nice when you modify my posted sample code and explain what I'm doing wrong with the synchronize method.
br
Erich
Size:
Color:
Synchronization to an intraday series from a series created via
CODE:
Please log in to see this code.
does not work because the new DataSeries is assumed daily not an intraday series so synchronization will use a daily to intraday method with undesirable results.
Add this else phrase to Eugene's suggested code and remove the synchronize statement.
CODE:
Please log in to see this code.
Size:
Color:
@KGo, thanks for reply. That's a part of what I meant with "doing synchronization by my own".
QUOTE:
new DataSeries is assumed daily not an intraday series
From where do you have this knowledge? I thought I'll read and understand the whole docu ;-)
As far as I know, there is no property indicating the timescale of the dataseries. When you loop through the series after filling it with intraday data everything looks good.
But maybe Eugene will clarify this behaviour and confirm as bug or post a working / modified sample for synching intraday data which shows all the three cases as written in documentation (eliminate outside, copy from prev. bar, eliminate non existing).
Size:
Color:
The new DataSeries named ret is not intraday because
CODE:
Please log in to see this code.
returns false.
Size:
Color:
@KGo
Thank's for the snippet! This pointed me into the right direction :-) The help of wealthlab is not showing the whole truth!
So I started my VisualStudio and dived a lillte bit deeper with the object browser and - voila:
You can create intraday dataseries and also the syncing will work then as excpected (because the dataseries is intraday)
Example how to create an intraday dataseries:
CODE:
Please log in to see this code.
You can the fill the series by using the "add". And finally also syncing works.
Many thanks KGo to point me into that direction.
@Eugene: would be nice to integrate such things into the docu
Size:
Color:
@ewessely
I'm glad you figured it out, but it's a pretty uncommon use case of an ad-hoc DataSeries. Since in your own example, you're passing the Bars object, Is there a reason why you just can't create a [synchronized] DataSeries by documented methods and then fill it with your values?
Size:
Color:
@Cone
It was only a simplified sample to reconstruct and demonstrate the behaviour, the Bars objectz passed is only a relict from the original code.
The whole story: I wanted to calculate linebreaks (similar to the linebreak chart) for minute data. By definition the breaks do not occure on each bar. As I did not find a matching indicator, I implemented it by myself running into the troubles written above. Of course, creating a synchronized dataset would also be possible way. In my first implementation I used daily bars where the synchronize workes fine but when switching to minute data I run into the problems which I tried to clarify because the synchronize does not work like expected and documented.
But now everything is -thanks to KGo - working as expected.
Size:
Color:
It's a little off topic now, but were you aware of the WealthScript Programming Guide > Backtesting with ChartStyles.Trending?
For a linebreak example, see the strategy
Line Break Basic, Rev A
Size:
Color:
@Cone: Yes, thank you - of course I know this sample. But I want to do the calculation by myself. For example: Some symbols have big gaps overnight and on minute data I've to restart the calculation on the beginning of the new session to avoid including the last values of the prev. session. Also I want to test not only with the Close as Basis for calculation (but this could also be overruled by using a "modified" bars object as input).
Size:
Color: