Strategy Monitor does not generate sell alerts
Author: rickraphael
Creation Date: 9/1/2009 3:30 PM
profile picture

rickraphael

#1
I have been using the Strategy Monitor with auto-trade initiated for paper trading since 6/8/09. With one important exception auto-trade works as expected, alerting, staging and executing paper buy orders. However, the strategy monitor never signals or executes a sell alert. Several sell signals hae ben missed during this period as confirmed with backtesting. When I run the code in a code window as a backtest, all of the correct buy and sell signals appear in the trades and alerts windows. This has occured with other strategies run in the same manner.

My workspace has the strategy window, orders window and acounts window open. The strategy is activated, auto-stage is selected and the orders window is set to auto-trade: paper accounts.

Why do I get the sell signals in the code window but not in the strategy window? To see an example, run the code below with settings Daily, start date 3/27/2008 (to account for the 300 bar look back) thru 8/28/09 using 2.5% of equity on the symbol PALM. You should see 6 entries all of which should have exited on 8/26/09. Those sell alerts never appear in the Strategy Monitor and obviously never execute.

The rules based strategy is as follows:

CODE:
Please log in to see this code.


Thanks
profile picture

Cone

#2
When I run this in the S. Monitor per your specifications, it shows that 6 trades occurred. Of course no Alerts are listed because these trades occurred in the past.

Make sure that you've specified the correct dates and have selected the Daily scale.
profile picture

rickraphael

#3
Yes, I can see that and that is what happens when I run it from a code window.

Are my SM settings correct? The SM settings are as follows:
Account: PaperAccount1
Data Range 302 Bars
Position Size: 2.5% Equity
Scale: Daily
The correct data set is selected (991 stocks)
The strategy has no sliders so "Use Preferred Strategy Parameter Values" is unchecked
Automatically stage orders from strategy alerts is checked.

I'm wondering if the Data Range is the problem. Should it be set to 302 bars, or something else for auto-trade?
profile picture

rickraphael

#4
Also, another quirk. The program was open and strategy monitor ran at 4:30 as it should showing no alerts. I ran it again at 5:18 and got 13 alerts (all buys). Any idea what could be causing it to miss alerts the first time it ran? I notice this happens from time to time.
profile picture

Cone

#5
QUOTE:
I'm wondering if the Data Range is the problem. Should it be set to 302 bars, or something else for auto-trade?
The Strategy uses a 300-Period moving average. If you use 302 bars, then you will never see an exit Alert because the Strategy won't have any entries to work with - only 2 bars are processed! Make sense? You should use at least 600 bars, whatever is enough to include the entries that you're trying to exit.

If you're only entering long Positions now (probably not a good time to do that), then you could set a Start Date such that the data is valid for trading starting now - like 6/17/2008. Leave that date set.

Re: another quirk
4:30 might be too soon to schedule updates for Fidelity data since Fidelity EOD updates are probably not available that quickly. Also note that EOD corrections don't come in until early morning. So if you want to run with the "official" data, you should turn off the S. Monitor at the close, do a Fidelity update after 6am (maybe 6:30am), and then open the S Monitor for the Alerts. I recommend doing this, otherwise if you apply data corrections, the Strategy could get out-of-synch with what you're really doing.
profile picture

rickraphael

#6
QUOTE:
If you use 302 bars, then you will never see an exit Alert because the Strategy won't have any entries to work with - only 2 bars are processed!


That's the problem right there. The working assumption that I got from FI was to set it at 302 bars. That way SM would look back to today's data and tell me what to do tomorrow. The assumption was also that, for existing positions, it would automatically test open account positions for the exit! Apparently the SM looks at the complete data set of stocks for exits, not not just the open positions in the account.

It's an interesting problem because it makes sense intuitively that the "auto-trading" system would look directly at the open positions for an exit decision. But that's not thinking like a programmer. The code does not explicitly say "monitor open positions and exit as required".

When I trade I look at the universe of potential entries that meet my criteria to open, Once I have that sub-set of open positions, I only test at that set for exits, not the the entire data set.

In backtesting, does WL create one data base of entries and another data base of exits and then merge them to create dated performance metrics?. (That's what I thought the SM in auto-stage would do.)

QUOTE:
You should use at least 600 bars, whatever is enough to include the entries that you're trying to exit.

I want to pursue this in another topic since I will only be doing manual trading of strategies, using entries and exits in "backtesting" mode and I need to make sure I understand how the date range affects the outcome. But before I start that topic, are there any areas of the User Manual I should check first?

Also, s there a PDF version of the user manual that can be printed?

I've run into the EOD problem with other software. Thanks for the heads up. One of them claims to have "corrected" data by 7:00 pm Funny how easy it is to get side tracked by "reality" in the markets.

Again, thanks. You guys are great at what you do.

PS
QUOTE:
(probably not a good time to do that)

Not!
profile picture

Eugene

#7
QUOTE:
Also, s there a PDF version of the user manual that can be printed?

If you don't want to be eco-friendly and don't mind to kill that tree, :) then:

1) Print all the topics under the heading when printing the built-in CHM help section by section, or
2) Download a CHM to HTML/PDF/Word Converter
profile picture

Cone

#8
CODE:
Please log in to see this code.
STrategies don't know anything about your account positions. This is explained in the User Guide (and many times here), but in V5 the Strategy doesn't have to actually create your account Position to exit it, but it can generate exit signals only on theoretical positions that it creates.

QUOTE:
Also, s there a PDF version of the user manual that can be printed?
Yes, on the Fidelity site. But keep in mind that if you have a question about something you're seeing, if you hit F1, the topic for the tool in focus appear in the chm manual.
profile picture

xingguochen

#9
Can we synthetically create a Position object and set its properties at Bars.Count-1, and then call SellAtLimit(bar+1, syntheticPosition, 10 ) to generate an auto order from strategy monitor?

Thanks
profile picture

Cone

#10
Yes you can. It's one of the reasons why the design is the way it is in Version 5 - to simplify selling discretionary positions. To help in this, make sure to select the option in the Trading Preferences (F12) for the exit order to automatically exit all shares held in the account.
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).