bracket orders with Easylanguage

Questions about MultiCharts and user contributed studies.
skan
Posts: 36
Joined: 15 Jul 2010

bracket orders with Easylanguage

Postby skan » 12 Aug 2011

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

User avatar
JoshM
Posts: 2084
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1525 times
Been thanked: 1483 times
Contact:

Re: bracket orders with Easylanguage

Postby JoshM » 15 Aug 2011

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;

skan
Posts: 36
Joined: 15 Jul 2010

Re: bracket orders with Easylanguage

Postby skan » 15 Aug 2011

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?

User avatar
TJ
Posts: 6571
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 968 times
Been thanked: 1900 times

Re: bracket orders with Easylanguage

Postby TJ » 15 Aug 2011

on complex logic, especially on strategy that requires multiple orders,
you will find coding a lot easier if you start with a flow chart.

User avatar
JoshM
Posts: 2084
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1525 times
Been thanked: 1483 times
Contact:

Re: bracket orders with Easylanguage

Postby JoshM » 15 Aug 2011

skan wrote: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 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).

A 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.

Source

skan
Posts: 36
Joined: 15 Jul 2010

Re: bracket orders with Easylanguage

Postby skan » 15 Aug 2011

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?

User avatar
TJ
Posts: 6571
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 968 times
Been thanked: 1900 times

Re: bracket orders with Easylanguage

Postby TJ » 15 Aug 2011

skan wrote: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?


do you have your bracket logic in the flowchart?
can you post it?

arjfca
Posts: 1273
Joined: 23 Nov 2010
Has thanked: 720 times
Been thanked: 222 times

Re: bracket orders with Easylanguage

Postby arjfca » 18 Aug 2011

skan wrote:I've been looking around and I've found the way to do it,
with PlaceOrder

http://help.TS.com/08_08/trad ... meters.htm


Have you succeeded to use the .PlaceOrder function? If so, could you share an exemple

Martin


Return to “MultiCharts”