Context switching issue
Author: kazuna
Creation Date: 1/24/2013 6:17 AM
profile picture

kazuna

#1
Here is two code examples. The only difference is a GetExternalSymbol(true) call.
CODE:
Please log in to see this code.

CODE:
Please log in to see this code.

Running these code in streaming window under 1-minute SPY symbol, I get the results below.

[CODE #1]
.VIX
.VIX

[CODE #2]
.VIX
SPY

If I set false to GetExternalSymbol in [CODE #1], I get the same result as [CODE #2].
Looks like an issue in the context switching.
profile picture

kazuna

#2
Another variant.
CODE:
Please log in to see this code.

And the result is the same as [CODE #1].

[CODE #3]
.VIX
.VIX

It looks to me if the followings are happening inside WLP synchronization logic:
- GetExternalSymbol(true) sets an internal synchronization state to true.
- The next SetContext(false) ignores the false parameter and enables synchronization.
- SetScaleDaily switches back to primary symbol unless the context is synchronized.
profile picture

Cone

#3
Thanks for the analysis. We will have to look into this more closely.

That said, I disagree with your observation that SetContext() ignores the synch parameter. As long as you do not use fixed bars, just check Bars.Count before and after SetContext(). When false, the number of bars will be different before and after, but when true the count is the same.
profile picture

kazuna

#4
Yes, you are correct regarding SetContext() ignoring the synch parameter.

It looks like to me if SetScaleDaily() is doing something wrong.
SetScaleDaily() seems enabling the synch all the time regardless of the synch parameter to SetContext().
Also SetScaleDaily() seems switching back to the primary symbol if nether GetExternalSymbol() nor SetContext() has synch enabled.
profile picture

Eugene

#5
Here`s what a little bird told me.

kazuna is right, SetScaleDaily is enabling the synch all the time - though not by itself but by virtue of calling RestoreScale before anything else is done in the code.
profile picture

kazuna

#6
Now I got to figure out how to mimic longer daily external symbol into shorter intraday primary symbol.
profile picture

Eugene

#7
Making no promises (untested), but you could try replacing SetScaleDaily with this method from Community Components for this purpose:

GetAllDataForSymbol
profile picture

kazuna

#8
Thanks Eugene! GetAllDataForSymbol works great!
I wonder why it is not included in WLP by default.

By the way I have a question about GetAllDataForSymbol.

What is different than using SetContext(false)/SetScale*() combo?
What does GetAllDataForSymbol do with the bars that are not updated to the datasets (e.g. intraday bars when on-deman update is disabled)?
profile picture

Cone

#9
Another way to get a Daily series into an intraday chart is by accessing the symbol by specifying its daily DataSet with synch false. After that, synch it to the intraday chart. For example:

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

kazuna

#10
Thanks Cone. GetExternalSymbol with daily DataSet works great as well.

Which one would you recommend? GetAllDataForSymbol or GetExternalSymbol?

I am particularly concerned with GetExternalSymbol due to the exception issue while updating the chart in the streaming window.
Is the exception also applicable to GetAllDataForSymbol?
Or is the exception only applicable to the external symbol in intraday DataSet?

This is related to the question to Eugene in my #8 post.
profile picture

Eugene

#11
GetAllDataForSymbol is a wrapper for Wealth-Lab`s core method for loading an external symbol`s data (internal and therefore unsupported).
profile picture

kazuna

#12
So GetExternalSymbol and GetAllDataForSymbol use the same internal method for loading an external symbol.
Therefore, an issue with GetExternalSymbol is applicable to GetAllDataForSymbol as well.
Correct?
profile picture

Eugene

#13
No, they don`t share the same internal method. It`s my speculation but GetAllDataForSymbol is based on a different method used primarily for charting.
profile picture

kazuna

#14
GetAllDataForSymbol also has the same exception issue as GetExternalSymbol.
According to Cone, this is by design and in order to prevent a crash while updating the chart.
CODE:
Please log in to see this code.

CODE:
Please log in to see this code.
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).