Bracketed trade?
Author: heech
Creation Date: 10/29/2008 5:00 PM
profile picture

heech

#1
The WL user's guide talks about bracketed stop/limit orders, in which if one fills, the "order manager will automatically cancel the opposing order".

In my code, when I do something similar in code:

CODE:
Please log in to see this code.


It looks like I'm ending up with both long positions. What am I doing wrong?
profile picture

heech

#2
Oops, this really doesn't belong in this section. Sorry about that... clicked into the wrong area. Does it need to be moved/reposted?
profile picture

Cone

#3
No worries, it's okay here.

Bracketed OCO orders work for exit orders only.

But, for backtesting purposes, you should know that the first trading signal executed has "priority". Since there's a possibility of limit and stop entries on the same bar, it would be better to write your logic like this, giving the first order "priority".

CODE:
Please log in to see this code.


Because of the lack of resolution in a "bar", you simply have to pick which order has priority for backtesting.
profile picture

heech

#4
Cone,

Appreciate the tip on backtesting.

On the topic of active trading... There's no way to submit a bracketed OCO order for a new position? Is this a Wealth Lab or Fidelity restriction...? It would only work on a sell/cover? Is there any other command I can use to specify OCO order?
profile picture

Cone

#5
Since it's an integration, I guess you can say that it's a Wealth-Lab and a Fidelity issue. OCO just isn't supported for entry orders.
profile picture

heech

#6
Cone,

Any chance that the SetScale time/frame methods will let a strategy dynamically change how often its executed *within* the Strategy Monitor? I'm guessing the answer is a "no".

I ask because I was considering switching "temporarily" to a 1-min data stream, so that I can implement something close to the BuyAtLimit+BuyAtStop behavior intra-bar.

If I can't set the scale dynamically... Is the solution instead to always use 1-min data stream, except wait 59 bars before processing my 1-hour/bar strategy?
profile picture

Eugene

#7
While not possible in WealthScript to switch "down" to a time frame of lower granularity, you're right that you can use 1-minute data and scale up programmatically.
profile picture

Cone

#8
To expand, you can't just arbitrarily "switch" from 60-minute bars to 1-minute bars. Sure, the Strategy may run fine, but the results will be significantly different if your indicators are based on the base scale.

The idea could be to always use 1-minute bars, but rescale to create the 60-min indicators. In this way you could trade on 1-minute intervals. Some logic could be based on the 60-min indicators and simultaneously use other logic that makes decisions more quickly on the 1-minute scale.

Very quick example - run in a 1-min scale and increase your starting data range by a factor of 60. In other words, if you needed 100 60-min bars, you'll now need 6000 1-min bars minimum.
CODE:
Please log in to see this code.
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).