How is working SetContext?
Author: mikhmv
Creation Date: 8/17/2008 9:51 AM
profile picture

mikhmv

#1
Hi,
I have some problem with SetContext.
I am using strategy with cycling in dataset. Something like this:
CODE:
Please log in to see this code.

Problem is, when i using different starting symbols for dataset I received different trading results. When i use same starting symbol results every time same. I didn't find yet where is error yet but i guess the problem in the synchronization for series.

I have several questions about SetContext(NewSymbol , true):
1) What do WL5 when in newSeries more bars than in original? Is it remove bars from new series?
2) What do WL5 when in newSeries less bars than in original? Is it add bars to new series? if yes what kind of bars will be added?

For my strategy i am need to have QQQQ series synchronized with NewSymbol.
When i used:
CODE:
Please log in to see this code.

QQQQ sometimes wasn't synchronized(depend from symbol).

Could you like to give advice how can i use SetContext(NewSymbol , false) and receive QQQQmin and QQQQDaily which will be sinchronized with "NewSymbol " (not with original symbol).

Thanks advance.
profile picture

Cone

#2
QUOTE:
Problem is, when i using different starting symbols for dataset I received different trading results. When i use same starting symbol results every time same.

That's because GetExternalSeries synchronizes to the original (clicked) symbol always. So you're changing the synchronization if you start with different symbols.

1) and 2)
See the WealthScript Programming Guide: DataSeries > Accessing Secondary Symbols > Secondary Series Synchronization


QUOTE:
For my strategy i am need to have QQQQ series synchronized with NewSymbol.

Two options:
1- Don't loop through the symbols trying to synch to each one. Create the Strategy for the primary symbol only and then run a Multi-Symbol Backtest.

2 - Use Synchronize() to synch to the current primary Bars object.

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

mikhmv

#3
Thanks Robert.

I guess i found another way. Add QQQQ stock to dataset and everytime start from QQQQ. in this case all series will be synchronized with QQQQ.
profile picture

mikhmv

#4
1) What do WL5 when in newSeries more bars than in original? Is it remove bars from new series?
2) What do WL5 when in newSeries less bars than in original? Is it add bars to new series? if yes what kind of bars will be added?
profile picture

Eugene

#5
In WealthScript Guide (5.1), the answer could be found under DataSeries > Accessing Secondary Symbols > Secondary Series Synchronization. [There should be a similar chapter in WS Guide for 5.0.]
profile picture

mikhmv

#6
Thanks Eugene.
You right, i found this.