Input a date?
Author: novendeh
Creation Date: 6/5/2011 8:03 PM
profile picture

novendeh

#1
I am having trouble figuring out how to input one constant (string variable), ymd. Any help would be appreciated. See code below.

Also, if ymd is a string variable, is this the correct way to turn it into an interger

int.Parse(ymd.

I think some of this is basic C# programing, which I am still trying to learn. Thanks.

EARL

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

Eugene

#2
While it's the biggest error, returning the ymd variable in the constructor might not be the only one here. (The trade processing block conditioned by date suggests it could be so.)

So if you describe the actual trading rules of the screener you are trying to implement, we'll help produce a correctly working version of the code.
profile picture

novendeh

#3
I'm trying to NOT execute any trades before the input date (ymd). This script worked fine when I just typed the date that trades started in the actual script, and now I'm trying to automate it with a dialog box popping up.

Thanks.
profile picture

Eugene

#4
Of course I know that, but was asking you about the entry/exit rules.
profile picture

novendeh

#5
Sorry - I misunderstood, as exit and entry rules work OK for me in another version of code. Basically, they are:

EXIT - sell on the third Friday of each month each holding.

ENTRY - If after date yyyymmdd that I enter in the dialogue box and Price greater than SMA, buy security, based on priority (ROC). If date before, remain in cash. I am trying to do a date to compare results to ETFScreen.com which only gives data fro 3 years (thus I am constantly changing start date).

Let me know if you need more. Many thanks.
profile picture

Eugene

#6
Thanks, this is going to help.

Here's my take at it:
CODE:
Please log in to see this code.
profile picture

novendeh

#7
Eugene - you code looks much better, but we are not quite there. If I run a simulation on 5 stocks, the dialogue box comes up five times. I want it to display only once.

Any suggestions? Thanks.
profile picture

Eugene

#8
This is simple: define the "ymd" as a class level variable and call Utility.Input in the constructor:
CODE:
Please log in to see this code.


It's going to be called just once when the strategy isn't recompiled i.e. every time the "Go" button is being clicked. The opposite holds true i.e. will be called every time you click "Execute".
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).