Set expiry for a strategy
Author: dansmo
Creation Date: 6/10/2010 4:31 AM
profile picture

dansmo

#1
Hi,

I´d like to protect my strategies and set an expiration date.
If today´s date is less then 10 days from the expiration date, I want a messagebox to warn the user.
Moreover, if today´s date is greater then the expiry date, I want a messagebox to inform the user that he can no longer use the strategy and the strategy should not be executed.

This is my code, but it does not work:
CODE:
Please log in to see this code.


What am I doing wrong here?
profile picture

Eugene

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

dansmo

#3
Thank you Eugene for your help.
Re-thinking this one...I would like to insert the possibilty to enter a password if expiry date is reached so that the user can run the script in urgent cases. So, if the password is correct the script should run anyway.
How to do this?
profile picture

Eugene

#4
I leave the actual password check procedure up to you, here's just an example how to enhance that code w/o altering its structure:
CODE:
Please log in to see this code.
profile picture

dansmo

#5
Hmm. When clicking yes on the dialog it aborts anyway.
profile picture

Eugene

#6
I changed the date to today's.
profile picture

dansmo

#7
Sorry, I was a bit unclear. I thought your example will run the strategy anyway in case the dialog is responded with "yes"?
When I press yes the code should be run, although the strategy expired. Responding with yes would then be replaced with entering a correct password.
profile picture

Eugene

#8
Thanks, what you found is an error, please see the fixed code above.
profile picture

dansmo

#9
Good work, thank you.
profile picture

dansmo

#10
When I use above code in a strategy that executes on a large dataset I get the messagebox for all symbols in the dataset. What do I need to change to make it run only once, notice that it expired, and abort it for all other symbols, too?
profile picture

Eugene

#11
Use global memory or a class level variable.
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).