Set some variables only on the first symbol in a dataset and use it on subsequent symbols
Author: sedelstein
Creation Date: 11/9/2018 1:05 AM
profile picture

sedelstein

#1
I'd like to set a variable(s) (or generate some lists) to be used on other symbols in a dataset when it is the first run. I'd like it not to be computed each time.
I thought this (or something like it would be the way to do it but the variable x only changes for the first symbol and not on the others although I thought it would be global in scope. I recall seeing something like this in the forums before but I was unable to find it in a search.'

Thanks for the help

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

Panache

#2
Wealth-Lab calls Execute() for each symbol in the DataSet, so every symbol is a firstRun. I think you would be better off just using
CODE:
Please log in to see this code.

The other option, which I use is
CODE:
Please log in to see this code.

Just make sure you only run this against ONE symbol in the data set, not the entire data set.

In my very limited experience with SetGlobal() and GetGlobal(), the strategy runs slower than if I just redid everything for each symbol
profile picture

sedelstein

#3
Hello Panache

I do only click on one symbol in the dataset as you suggest

In my simplified example, i set the variable x = 3 within "Insert what you want to do on your firstRun"

but then it doesnt take. I will try your example but at first blush I thought I was doing essentially the same

Thank you for the suggestion
profile picture

Eugene

#4
QUOTE:
In my very limited experience with SetGlobal() and GetGlobal(), the strategy runs slower than if I just redid everything for each symbol

There may be some overhead from casting to/from objects (done by *Global) but it shouldn't be very expensive performance-wise.
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).