OCO Trailing Stop strategy
Author: karasaj
Creation Date: 5/19/2009 10:50 PM
profile picture

karasaj

#1
I am new to Wealth Lab Pro & I'm trying to create a strategy using Trailing Stops to open positions. However, on the drag & drop feature I only see Trailing Stops being used as closing transactions. Let me describe my strategy & maybe someone can tell me the script for it…

Beginning of the day, before market opens---place a contingent "one cancels the other" trailing stop to buy if stock rises 1% from the open OR sell short if stock drops 1% from the open.

If buy to open triggers--immediately place a trailing stop sell to close at 1% interval.
If sell to open triggers--immediately place a trailing stop buy to close at 1% interval.

If or when the position closes, then the strategy immediately starts over--the OCO trailing stops are placed again at the same 1% intervals to buy at the ask OR sell short at bid (instead of based 'at the open' like the very first trade of the day.)

I want this strategy to continue throughout the day, and if I have an open position within 1 minute of market close, I want to place a sell/buy to close "at the close" order to make sure I have no open positions when market closes.

I of course may need to tweak the trailing stop % intervals, so if you could also explain how to do that I would appreciate it.

Thank you to whomever can help!
profile picture

Eugene

#2
What if the initial entry condition never happens, would you be still looking for trades that day?
profile picture

Cone

#3
QUOTE:
before market opens---place a contingent "one cancels the other" trailing stop to buy if stock rises 1% from the open
It's not possible to place an order before the market open that is based on the opening price, since that price is not known yet. A script will know the opening price at the close of the first 1-min interval, i.e., at 09:31:00.

Question - is the 1% bracket always around the open of the most-recent bar, or just the opening price of the day?

QUOTE:
"one cancels the other" trailing stop
Fidelity doesn't support OCO entries from WLP. You can enter simultateous BuyAtStop and ShortAtStop orders, but if one fills, the other won't be canceled until the end of the interval. While an intraday move of 1% and then 2% in the other direction wuold be rare, it could happen. If it did, I think the Fidelity trading backend may error out the order anyway, but you'd have to check with Fidelity Wealth-Lab support to be sure.


profile picture

karasaj

#4
Thank you both for your resonses.

In response to Eugene--if the inital order doesn't execute then I suppose there are no trades that day...I haven't really thought of anything else just yet.

In response to Cone--I didn't know the script couldn't handle an an order based on the open before the market opens..that seems like a huge limitation and strange that it doesn't know the open until a minute later..but anyways if that's the way it works then I guess I'll just simplify the strategy--Can you base the trails off the ask/bid (for buy/sell short respectively) instead? Before the market opens? This can then continue throughout the day, so each time a position is closed, then the new OCO trailing stops are placed on the current bid/ask, not the open. Fidelity's simple website allows for OCO trailing stops, so I don't understand why they wouldn't support these order types on Wealth-Lab.
profile picture

Cone

#5
QUOTE:
I didn't know the script couldn't handle an an order based on the open before the market opens..that seems like a huge limitation
Come again? Let's look at it from another perspective. How do YOU place an order based on the opening price before the open, i.e., before you know what the opening price is? Do you have a crystal ball that actually works? (If you do, please contact me in support, and don't tell anyone else.)

QUOTE:
Can you base the trails off the ask/bid (for buy/sell short respectively) instead? Before the market opens?
That's a possibility if that data were actually provided to WLP in some manner. Issues:
1. Fidelity does not provide pre/post market data to WLP
2. Bid/ask data is not available to the script even during market hours.
3. Bid/ask data is not available for backtesting.
4. Have you ever really watched how listed stocks (NYSE) open relative to the somewhat illusional premarket bid/ask?

I don't know how long you've been trading, but let me tell you that if you're making discretionary trading decisions based on the bid/ask without have some methodology behind it (like knowing the tricks of the "axe" for the particular market), then you're not likely going to make any money trading. In the end, the only thing that counts are the ticks on the chart, and that data is avaialble for testing and trading with WLP.

Most novice traders get their first look at the Level 2 bid/ask and think they've got the key to the market. Nothing is further from the truth, and they probably don't know that the big guys have Level 3 that shows the incoming order flow, allowing them to move their bid and offers to scare the little guys into going where they want them. Imho, most traders should use Level 2 for nothing more than order routing to hit the ECNs with maximum precision and timeliness. And if you're making money doing that, then you don't need Wealth-Lab to trade for you.

QUOTE:
then the new OCO trailing stops are placed on the current bid/ask, not the open.
Forget about the bid/ask. The script doesn't have access to that data. During the day, think "close". The difference between the close of an intraday interval and the open of a new one is just 1 tick, and most often they're the same price. Lesson: Espeically fo intraday strategies, never try to use the opening price to create a trade on the same bar (it's not possible), and just use the close of the most-recent bar for trades on the next bar. The difference is 1 tick (and maybe 1 msec), and your script actually has the data.

QUOTE:
Fidelity's simple website allows for OCO trailing stops, so I don't understand why they wouldn't support these order types on Wealth-Lab.
OCO trailing stops are possible - for exits, just not for entries. Most strategies have a good idea whether they want to go long or short before placing the order.
profile picture

karasaj

#6
Ok I understand that basing orders on bid & ask is not really possible to program & backtest...I'm just paranoid to base trailing stops on "last" because I'm paranoid by rare huge spikes that occur because of some strange private trade far from the market. I don't want those to falsely activate the trade. But I suppose the trails can just be based on the "last" trade, unless you have other suggestions.

When I spoke about "at the open" orders I wasn't trying to predict the future, I was referring to the Time In Force option which is defined by Fidelity as when "the order is executed as close as possible to the opening price for a security. All or part of the order can be executed. Any part of the order that cannot be executed at the opening price is canceled." We'll just forget about this part of the strategy.

So I guess to simplify what I need assistance with, do you mind just telling me what the script for a "trailing stop to buy to open" and "sell short to open" is? That's all I really need right now. If OCO orders for entries is not possible in Wealth Lab then that's very disappointing since Fid.com can do it, but I guess I'll figure something else out.

Thanks again
profile picture

Cone

#7
CODE:
Please log in to see this code.
In a streaming chart (but not in the S. Monitor), turn on the spike filter in preferences.

That said, spikes have a much larger chance of occurring for the high/low values, simply because only one trade can be the opening trade and only one can be the close. For 1 minute strategies, you can write a reasonableness test, but when the market gets volatile, almost anything you code will give you plenty of "false positives".

QUOTE:
the order is executed as close as possible to the opening price for a security.
If you want to enter/exit as close the opening price, then use a Market order.

QUOTE:
trailing stop to buy to open" and "sell short to open"
Not specific enough. For exits, trailing stops move in a racheting fashion with price in the direction that favors a profitable trade. So what do you mean by trailing stop for entry orders? Give a specific example.
profile picture

karasaj

#8
For example let's say ABC opens at $100 and I immediately put in an order for a "trailing stop buy" at 1% based on $100 (or as close as possible--the trail should automatically set on the first tick it sees) and I simultaneously place a "trailing stop short to open" (hence the OCO, but if it's not possible then I guess I can do 2 separate orders). So the stock rises to $101 and I'm now long the position. I immediately then place a "trailing stop sell to close" order at 1%. So let's say the stock goes straight up to $110 and then it falls 1% to $108.90 so my sell order executes. Now I start over--immediately place another trailing stop buy & trailing stop sell short at 1% for $108.90 (or close to it). So now let's say the stock drops 1% to $107.81 so now I've opened a short position. I then immediately place a "trailing stop buy to cover" at 1%. Let's say the stock drops quickly back to $100, and then rises 1% to $101 so now I've closed the position and I start over.

Is this specific enough?
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).