TIme of day condition in Rules?
Author: appressman
Creation Date: 2/24/2009 8:06 AM
profile picture

appressman

#1
Hi y'all,
Pardon the hopefully easy question by a noobe. I saw a strategy in Active Trader that employs a time of day requirement for entering a position after 1PM. While I see date specific conditions in the rules available I don't see how to check for a specific time of day.

1. Go long at 1 p.m. ET if the market’s current price is
above its opening price.
2. Sell short at 1 p.m. ET if the market’s current price is
below its opening price.
3. Exit with a profit of 10 points
($2,500) or with a stop-loss of
10 points. If the profit target or
stop-loss isn’t reached, exit the
trade when the S&P 500 pit
closes at 4:15 p.m.

Thanks in advance
profile picture

Eugene

#2
Time-of-day conditions are not available in rule-based strategies. Here's the strategy (untested):
CODE:
Please log in to see this code.
profile picture

appressman

#3
Thanks Eugene. I appreciate your coding an example for me. I notice, unlike other snippets that indent nicely when I cut from the forum and paste into WL, the code here all appeared on one line of the editor. It still compiled fine but I wonder if that's an issue with WL latest update as that's the only change since last time I tried it.
profile picture

appressman

#4
Another NOOBE question... I suspect it's in the programming reference but is there a rule condition that I can set to a given percentage or dollar amount above/below the price of entry?

I can see that I set a condition for a certain value above/below the close but I'd like to use the price actually paid for a position to set stops.

Thanks in advance again.
profile picture

Cone

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

TrendCatcher

#6
What if we use this for SPY. except the closing time would be at 4 pm.
profile picture

Eugene

#7
There's no fixed closing time in the strategy code:
CODE:
Please log in to see this code.

Also see IsLastBarOfDay in the QuickRef.
profile picture

DartboardTrader

#8
CODE:
Please log in to see this code.


The above code triggers a "Runtime error: Index was out of range. Must be non-negative and less than the size of the collection."

Which brings up a good question, how can we inspect 'future' trading dates for seasonal or trading week cyclical strategies?

The article on "Peeking" and "Valid Peeking #1" punts on the fact they generate false-positive alerts.

AddCalendarDays adds the whole calendar. I am interested only in valid trading days, including intraday bars for short-session trading days. Any ideas?
profile picture

Cone

#9
See Markets.xml in the Data folder.