Clearing some cache (data from SQL not updated in my strategy)
Author: ewessely
Creation Date: 12/2/2011 10:28 AM
profile picture

ewessely

#1
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
profile picture

Eugene

#2
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.
profile picture

ewessely

#3
Hi Eugene,
CODE:
Please log in to see this code.
profile picture

Eugene

#4
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.
profile picture

ewessely

#5
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
profile picture

Eugene

#6
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 open

Re: 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.
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).