Run strategy on pre-defined symbol list through coding?
Author: ct1231
Creation Date: 10/12/2020 8:00 PM
profile picture

ct1231

#1
folks,
one of the goal to use the software is to "automatically" pick symbol for day-trading;

I want to use C# code in 'wealth-lab developer' to execute the strategies on pre-defined symbol list and finish the trade if condition satisfied for each of the symbols. Is this possible? how and any references can be shared?


profile picture

Eugene

#2
Hi Xin,

What do you mean by the "pre-defined symbol list"? How is this different from a Wealth-Lab DataSet? Please clarify your goal.
profile picture

Cone

#3
The short answer is that if you run the strategy on a list of symbols, it will "automatically pick" the ones to trade per the strategy's rules.

It would be better if you gave a precise example of what you want to do, what interval you'd like to trade at (daily, 1-min bars, 30-minute bars, etc.), and how many symbols are involved. But generally speaking "anything is possible".
profile picture

ct1231

#4
is that possible to pick symbols in C# code for the "execution()" ?

sample code:
CODE:
Please log in to see this code.


or I can only run strategy on one symbol per click on "Run the strategy"?

Thanks for any input.
profile picture

Eugene

#5
You can simply filter out stocks not on the list like this:
CODE:
Please log in to see this code.
profile picture

ct1231

#6
@Eugene, thanks for the demo code;
I'm wondering how can get
CODE:
Please log in to see this code.
run on each symbol? after all, the trading judgment is based on the moving average on each symbol.

so the question is: how can I make sure
CODE:
Please log in to see this code.
will be run all the symbol I defined?

thanks.
profile picture

Eugene

#7
Another way is to skip processing of a symbol not on your list:
CODE:
Please log in to see this code.
profile picture

Cone

#8
I have a feeling that ct1231 is familiar with another analysis software that defines symbols in the script to access their data in a primary series.
Wealth-Lab doesn't really work that way (although you can access and trade a secondary series from the script, but it has to be syncrhonized with the primary series).

Let's make sure we're all on the same page. Do you understand that when you click a symbol in the Data Tree, its data is loaded into the Bars object and this becomes the primary series on which the script runs?

If you click on the name of the DataSet and then "Backtest on all Symbols in [DataSet]", the script is run on all the symbols in the DataSet, one by one, and the results are combined. This is called a Multi-Symbol Backtest (MSB). In this case, it *might* make sense to abort executing on symbols that you're not interested in, but it would probably be easier to just have a DataSet of the symbols that you want to run.

In short, you don't have to define the symbols in the script. Does this make sense?
profile picture

ct1231

#9
Hi @Cone, the above clarification is helpful.
Thanks a lot!

Still, is there a way to "inherit" from existed [DataSet] so developers can through code to easily "load" necessary data into Bars.
profile picture

superticker

#10
By default, the Wealth-Lab Execute() loop (or block) analyzes each stock individually within a dataset without regard to other stock results/trades.

QUOTE:
is there a way to "inherit" from existed [DataSet] so developers can through code to easily "load" necessary data into Bars.
So what are you trying to inherit here? Are you trying to inherit trade results from other (external) stocks or bar data from other stocks? The Bars for the "current" stock being modeled are automatically set for you by the default Execute() behavior.

You can use GetExternalSymbol() (see QuickRef guide) to grab bars from another (external) stock that's not the current stock being analyzed in the current iteration of the Execute() block.

DataSetSymbols is a collection (of type List<string>) that holds all the symbols within the dataset the Execute() block is cycling through. For example, DataSetSymbols[4] would return the fifth stock in the dataset. Why would you want to know that?
profile picture

Eugene

#11
QUOTE:
Still, is there a way to "inherit" from existed [DataSet] so developers can through code to easily "load" necessary data into Bars.

No, you have to create a DataSet manually, not dynamically. It's not possible to create custom DataSets on-the-fly (as this is what you're probably after). At least not without having to restart WL before they appear.
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).