Conditional trading (OCO, OTO)?
Author: BigReturns
Creation Date: 12/17/2008 5:17 PM
profile picture

BigReturns

#1
Has anyone (is there) found a way to simulate conditional trading? One cancels the other, one executes another?
profile picture

Cone

#2
Can you be more specific?

In a simulation, the code just does what you tell it to do, and, it does it in the order you specify. Generally, you should write code so that market orders occur first, and then stops (worst-case condition), and then limit targets. Here's an example:

CODE:
Please log in to see this code.

Note that in a simulation, the stop order is executed before the limit, which only executes if the stop does not occur. In live trading both orders would be sent to market as Alerts.
profile picture

BigReturns

#3
I'm thinking more along the lines of using a strategy for trading purposes
rather than back-testing.

For example:

After an order executes, it triggers another order to be executed. (OTO Orders)
-or-
After an order executes, it cancels other orders that have already been placed. (OCO Orders)

-D

profile picture

Cone

#4
It's not possible to implement that in a Strategy. First, remember that strategies execute only after a new bars is added to the chart, once. Stop and Limit Orders can be filled at any time "between bars", and the order status is not available to the script anyway.

If you're using WL Pro, then you can enter bracketed exits (like in the code above), which is an OCO controlled by the Orders tool.
profile picture

BigReturns

#5
Okay... here is a simpler one, how about a being able to graph profit by entry or exit indicator?
profile picture

Eugene

#6
Is it the same as your request here?
profile picture

BigReturns

#7
Eugene, sorry for the delay (I've been out for a while) -->

Nope... its not the same request.

I am thinking in more of automated trading in this scenario:

1) Setup WLP with conditions to generate for generating an alert (I looking at hundreds of stocks)
2) Execute automated trading
3) When An alert is generated a order is placed
QUOTE:
- Buy orders, only if funds are available)

QUOTE:
- Sell Orders, Sell anytime alert is generated. I would also like to place trailing stops orders


My strategy works - I just want automate all or parts of it.

How might one approach this....?

P.S.-- I still don't fully get the automated trading with WL, it's confusing as heck to me! Is there better documentation out there since last fall on this?

Thanks,
-BR
profile picture

Cone

#8
There's no built-in way to filter orders based on funds available. If you enter multiple orders, they'll continue to execute until Fidelity's back-end trading subsystem determines you don't have any buying power left. It's my understanding (but I don't know for sure, so you should call Fidelity about trading questions) that if you enter many simultaneous orders, there's potential for a margin call. (Which is really no big deal at that moment since you can liquidate new positions immediately at virtually no cost, though a call may require adding funds anyway depending on trading agreements.)

So with the exception of "only if funds are available", that's how every Strategy works. You run the strategy, it generates Alerts, and you enter the orders manually or automatically (immediately).

Automated Trading in a Nutshell:

1. Strategy generates Alerts
2a. Assuming that you're logged in and you're trading a Daily (non Streaming) Strategy, you have 2 options:
You can Place or Stage selected order(s) directly from the Alert-generating tool. "Place" places the order directly, whereas "Stage" puts it in the Orders queue where you can Place it at any time thereafter.

2b. Assuming that you're logged in and you're trading a Streaming Intraday Strategy, you have 4 options:
i. You can Place, or,
ii. Stage manually as before.
iii. You can select Auto-Stage in the Alerts view if the Orders tool is not enabled for Auto-Trading, or,
iv. You can select Auto-Place in the Alerts view if the Orders tool is enabled for Auto-Trading.

Clearly the "Auto" in these last two options mean that as soon as a new Alert occurs, the orders is automatically Staged or Placed.

Does that help?
profile picture

BigReturns

#9
It sort of helps.

I have understood the "high-level" functionality which you are describing. Where I get confused is in the implementation.

I'll read through the instructions again and see if its any clearer now.

FYI -- I would like to use 2B- IV. Streaming data & Auto-Place after some serious testing! :)
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).