Hello
How can I send bracket orders (or OCO) from an Easylanguage strategy?
For example I want to put a Buy stop order at 10000 and, associated to this, a Sell stop order at 9900.
The sell order is activated only when the fist one has been filled.
I need them to be OCO orders because I want to send them to the broker (IB) and forget it. That way if the connection is lost the order will remain at the markets.
I know it can be placed by hand but I need to automatize it.
I don't know if I need to activate the intrabarodernegeration and use orders such as
SetStopLoss . I've read that these orders give fake results when optimizing.
thanks
bracket orders with Easylanguage
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: bracket orders with Easylanguage
Something like this? (found on BMT)
Code: Select all
vars:
setupCondition(false);
if .... mysetup... then
setupCondition = true
else
setupCondition = false;
// Submit entry orders as long as the setupCondition = true *and* there is no market position
if setupCondition = true and MarketPositon = 0 then begin
Buy ("EnterLong") 1 contract next bar at Highest(high, 10)[1] limit; // buy breakout of highest high latest 10 bars
Sellshort ("EnterShort") 1 contract next bar at Lowest(Low, 10)[1] limit; // sell breakout of lowest low of latest 10 bars
end;
if MarketPosition = 1 then begin
// Manage long order here
// For example a stop below the Lowest low of the latest 10 bars
Sell("Stop") next bar at Lowest(Low, 10)[1] stop;
end;
if MarketPosition = -1 then begin
// short orders
end;
Re: bracket orders with Easylanguage
Hello
That's not what I mean,
your code places ordinary stop orders and doesn't change the order till next bar.
These are not bracket nor OSO orders but common stops.
I've been looking around and I've found the way to do it,
with PlaceOrder
The problem is that it doens't allow to backtest it, thus is useless for me.
http://help.TS.com/08_08/trad ... meters.htm
Any other way to do it?
That's not what I mean,
your code places ordinary stop orders and doesn't change the order till next bar.
These are not bracket nor OSO orders but common stops.
I've been looking around and I've found the way to do it,
with PlaceOrder
The problem is that it doens't allow to backtest it, thus is useless for me.
http://help.TS.com/08_08/trad ... meters.htm
Any other way to do it?
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2223 times
Re: bracket orders with Easylanguage
on complex logic, especially on strategy that requires multiple orders,
you will find coding a lot easier if you start with a flow chart.
you will find coding a lot easier if you start with a flow chart.
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: bracket orders with Easylanguage
I know, that why I said 'something like this'. If you change the code by reflecting a stop and limit order, you'll get a bracket order in my opinion. And if you use IOG then orders also can be generated inside bars. (That is, unless you mean something else than I do).That's not what I mean,
your code places ordinary stop orders and doesn't change the order till next bar.
These are not bracket nor OSO orders but common stops.
SourceA BUY order is bracketed by a high-side sell limit order and a low-side sell stop order. A SELL order is bracketed by a high-side buy stop order and a low side buy limit order.
Re: bracket orders with Easylanguage
Hello
I'm already coding using flowcharts, on a traditional way.
But I'd like to step forward coding with bracket orders in order to get faster responses in choppy markets. The other advantage of using bracket orders is that I'm protected against data connection losses.
I can even send all my bracket orders and switch my computer off.
Do you think bracket or OSO orders are not needed?
If not, why do they exist?
I'm already coding using flowcharts, on a traditional way.
But I'd like to step forward coding with bracket orders in order to get faster responses in choppy markets. The other advantage of using bracket orders is that I'm protected against data connection losses.
I can even send all my bracket orders and switch my computer off.
Do you think bracket or OSO orders are not needed?
If not, why do they exist?
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2223 times
Re: bracket orders with Easylanguage
do you have your bracket logic in the flowchart?Hello
I'm already coding using flowcharts, on a traditional way.
But I'd like to step forward coding with bracket orders in order to get faster responses in choppy markets. The other advantage of using bracket orders is that I'm protected against data connection losses.
I can even send all my bracket orders and switch my computer off.
Do you think bracket or OSO orders are not needed?
If not, why do they exist?
can you post it?
Re: bracket orders with Easylanguage
Have you succeeded to use the .PlaceOrder function? If so, could you share an exempleI've been looking around and I've found the way to do it,
with PlaceOrder
http://help.TS.com/08_08/trad ... meters.htm
Martin