Here is a code example I tested on WLP 6.4.
CODE:
Please log in to see this code.
Size:
Color:
Run this strategy code in streaming window under 1-minute scale symbols below and observe the last five logs in the debug log.
Make sure you have both 1-minute and daily scale .VIX datasets before running the strategy.
[.VIX / 1-minute scale] (looks good)
VIX_1 / VIX_SMA = 13.7 / 17.4589000000001
VIX_1 / VIX_SMA = 13.45 / 17.4485500000001
VIX_1 / VIX_SMA = 13.52 / 17.4392000000001
VIX_1 / VIX_SMA = 13.28 / 17.4229000000001
VIX_1 / VIX_SMA = 12.67 / 17.4067000000001
[SPY / 1-minute scale] (looks wrong!!!)
VIX_1 / VIX_SMA = 13.41 / 13.5633
VIX_1 / VIX_SMA = 13.37 / 13.2969499999999
VIX_1 / VIX_SMA = 13.61 / 13.3884
VIX_1 / VIX_SMA = 12.33 / 12.53595
VIX_1 / VIX_SMA = 12.55 / 12.6255
Size:
Color:
Notice that VIX_SMA is not based on daily scale data if it is run under symbols other than .VIX.
1) Is this a known issue being fixed in 6.5 or later?
2) Is there a workaround for this issue so that I can access both 1-minute and daily external symbols?
Size:
Color:
SetScaleDaily works on the Context Bars, not just any series that you reference. So, if you access another series unsynchronized (as you did here), you are working with data from the base timeframe.
To fix it, you can get VIX_D by passing
true. Or, if you really want to create the moving average of the unsynchronized .VIX daily series first...
CODE:
Please log in to see this code.
Size:
Color:
That "SetContext" fixed the problem. Thank you.
However, I found another issue.
[.VIX / 1-minute scale] VIX_1 looks good.
VIX_1 / VIX_SMA = 13.7 / 17.4589000000001
VIX_1 / VIX_SMA = 13.45 / 17.4485500000001
VIX_1 / VIX_SMA = 13.52 / 17.4392000000001
VIX_1 / VIX_SMA = 13.28 / 17.4229000000001
VIX_1 / VIX_SMA = 12.67 / 17.4067000000001
[SPY / 1-minute scale] VIX_1 looks wrong and it is one bar behind than the primary symbol.
VIX_1 / VIX_SMA = 13.41 / 17.4589
VIX_1 / VIX_SMA = 13.37 / 17.44855
VIX_1 / VIX_SMA = 13.61 / 17.4392
VIX_1 / VIX_SMA = 12.33 / 17.4229
VIX_1 / VIX_SMA = 12.55 / 17.4067
If i replace VIX_1.Open[bar].ToString() with VIX_1.Open[bar+1].ToString(), I get correct open value.
Any idea?
Size:
Color:
I updated the code slightly to print the date/time of the bar.
CODE:
Please log in to see this code.
The result is interesting.
[.VIX / 1-minute scale]
2013/01/22 09:32:00 / 2013/01/22 09:32:00 : VIX_1 / VIX_SMA = 13.28 / 17.4229000000001
2013/01/23 09:32:00 / 2013/01/23 09:32:00 : VIX_1 / VIX_SMA = 12.67 / 17.4067000000001
2013/01/24 09:32:00 / 2013/01/24 09:32:00 : VIX_1 / VIX_SMA = 12.73 / 17.3871000000001
[SPY / 1-minute scale]
2013/01/22 09:31:00 / 2013/01/18 16:00:00 : VIX_1 / VIX_SMA = 12.33 / 17.4229
2013/01/23 09:31:00 / 2013/01/22 16:00:00 : VIX_1 / VIX_SMA = 12.55 / 17.4067
2013/01/24 09:31:00 / 2013/01/23 16:00:00 : VIX_1 / VIX_SMA = 12.49 / 17.3871
So it looks like .VIX is special and it does not have a bar at 09:31 probably because it is calculated based on the data at 09:31.
Because GetExternalSymbol(true) filling the bar with the previous available bar data, it is filling the bar with the data at 16:00?
Size:
Color:
That is correct and precisely how secondary symbol synchronization is supposed to work.
Size:
Color: