Hi,
I'm using a database provider to access tables on my SQL server. The data are used in my strategy as signal line (via GetExternalSymbol).
My problem: when changing the data on the SQL and just looking on a chart of a symbol of these data as source everything is ok. But in my strategy the data will not be updated. I have to close the strategy and reopen it to get the updated data. I also tried to work with ClearExternalSymbols (it correctly tells that 1 symbol has been cleared) but there will always be shown the old (I think cached) data till I close and reopen the strategy.
I also tried to clear the cache for a specific symbol (e.g ClearExternalSymbols("MSFT")), but this seems to be an incorrect entry in the WealthScriptQuickRef (error message on compiling)
Greeting
Erich
Size:
Color:
Hi Erich,
Sounds like your code is improperly operating a class level variable or sort of that. To avoid guesswork please paste the skeleton code here for our review.
Size:
Color:
Hi Eugene,
CODE:
Please log in to see this code.
Size:
Color:
Here's it, your improperly operated class variable that is not reset:
CODE:
Please log in to see this code.
Move it inside the Execute() method body.
Size:
Color:
Hi Eugene,
it's working now - but from the view of programming not clear: Should not ClearExternalSymbols(); clear the cache?
In my oppinion if the cache would be cleared properly declaring the class variable inside the Execute() consumes extra memory (garbage collection in .net <4.0 is not the best...). This could be a problem when dealing with large count of symbols.
Greetings
Erich
Size:
Color:
Hi Erich,
The question has nothing to do with some "cache" or
ClearExternalSymbols. From programming standpoint, your class level variable causes the behavior you described -- something reminding of this pattern which also uses a class level variable:
WealthScript Techniques | Don't execute Strategy on openRe: memory usage, don't optimize before the code cries for optimization. It's safe to not be creative where it's not needed e.g. don't PrintDebug from constructor, don't create a class level variable where nobody else is doing it.
Size:
Color: