Emulating old-style Limit orders

Questions about MultiCharts and user contributed studies.
User avatar
danilo
Posts: 170
Joined: 02 Jan 2007
Location: Italy
Has thanked: 4 times
Been thanked: 9 times

Emulating old-style Limit orders

Postby danilo » 21 Apr 2008

I'd like emulate the old-style limit orders, to do that I'm using the following piece of code:

[IntrabarOrderGeneration = True]

// old-style: Buy next bar at X limit
if (Close <= X) Then Buy this Bar;

// old-style: SellShort next bar at X limit
if (Close >= X) Then SellShort this Bar;

Since the close is checked at every tick, I would expect that the order is filled as soon as the condition is met, insted of the order is executed only at the close of the Bar, why ?

SUPER
Posts: 629
Joined: 03 Mar 2007
Has thanked: 101 times
Been thanked: 81 times

Postby SUPER » 22 Apr 2008

Have you tried Next Bar at Market, I belive with IntrbarOrderGeneration one should use Next Bar at Market Orders.

if (Close <= X) Then Buy Next Bar at Market;
if (Close >= X) Then SellShort Next Bar at Market;

User avatar
danilo
Posts: 170
Joined: 02 Jan 2007
Location: Italy
Has thanked: 4 times
Been thanked: 9 times

Postby danilo » 22 Apr 2008

SUPER,

"Next Bar at Market" is working !, I don't understand why in IOG mode "Buy this Bar" doesn't work since I believe that should send the order early.

thanks,
Danilo

wullenweber helmut
Posts: 57
Joined: 21 Dec 2007
Has thanked: 2 times
Been thanked: 9 times

Postby wullenweber helmut » 23 Apr 2008

@danilo

Some of the rare words about intrabarorders from "Easy Language Essentials", Page 82:

Setting Intra-bar Order Generation Within your Code

You can programmatically turn on or off intra-bar order generation using an attribute at the beginning of your code. Attributes are switches set at the start of your code. Usage Example:

[IntraBarOrderGeneration = TRUE]
if Close > Close[1] then
Buy next bar at Market;

Here the strategy will generate a market order on the first tick that is higher than the previous bar close. When intra-bar order generation turned on, next bar really means next tick.

User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Postby Marina Pashkova » 23 Apr 2008

SUPER,

"Next Bar at Market" is working !, I don't understand why in IOG mode "Buy this Bar" doesn't work since I believe that should send the order early.


Hi Danilo,

In MultiCharts "Next Bar at Market" works and "Buy/Sell this Bar" (which is the same as "Buy/Sess this Bar at Close") does not work in IOG mode because this is the way such orders work in TS.

We do agree that logically this behavior is not perfectly correct, but for now we have decided to follow TS's logic - to make sure that TS native strategies work in MC in exactly the same way.

User avatar
danilo
Posts: 170
Joined: 02 Jan 2007
Location: Italy
Has thanked: 4 times
Been thanked: 9 times

Postby danilo » 23 Apr 2008

Marina,

It's OK, now that I have the old-style limit orders that are solid like a rock, I'm less worried regarding the back-compatibility. I have already "tested" HyperOrder for IB and I had the same problems that there are now on MC regarding the RELIABILITY of the TRUE limit orders, that it's so LOW that it's impossible to use the autotrading on a REAL accounts.

Kind Regards,
Danilo

User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Postby Marina Pashkova » 29 Apr 2008

Danilo,

Could you please specify what problems make limit orders unreliable? It is not quite clear from your previous posts. Because the problems described in this thread were related to the wrong syntax.

User avatar
danilo
Posts: 170
Joined: 02 Jan 2007
Location: Italy
Has thanked: 4 times
Been thanked: 9 times

Postby danilo » 29 Apr 2008

Dear Marina,

the following post contains the main issues regarding the NEW market limit orders:

1) http://forum.tssupport.com/viewtopic.php?t=5019
2) http://forum.tssupport.com/viewtopic.php?t=5042

In Summary is known that the TRUE market limit orders aren't guarantee that are filled and this can change some strategy behaviour and results, this is not a real bug but it's hard to do a reliable back-testing (see 1). To avoid this side-effect the possibility to convert the limit order to market order has been added but as new side-effect could happen (very often) that duplicated order are executed (see 2) since could happen that TWS dosn't send the confirmation that the limit order has been filled. Marina, I'm not asking the moon, even HyperOrder and NT offer the kind of option that I'm asking for and for me the "emulation" of market limit order is the best compromise between strategy's reliability and broker's execution reliability.

Best Regards,
Danilo

User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Postby Marina Pashkova » 07 May 2008

Hi danilo,

Once we fix the bug (the fix will be available in the service pack due by the end of the next week), all you'll need to do to emulate the old-style market orders is set 0 seconds for the timeout for the conversion of limit/stop orders into market orders.

User avatar
danilo
Posts: 170
Joined: 02 Jan 2007
Location: Italy
Has thanked: 4 times
Been thanked: 9 times

Postby danilo » 08 May 2008

Marina,

could you tell me if the functions SetProfitTarget and SetStopLoss, that are a special type of limit/stop order, setting the timeout=0 will behave in the same way ?

Regards,
Danilo

User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Postby Marina Pashkova » 13 May 2008

Marina,

could you tell me if the functions SetProfitTarget and SetStopLoss, that are a special type of limit/stop order, setting the timeout=0 will behave in the same way ?

Regards,
Danilo


Yes, Danilo. As soon as the bug with the 0 timeout is fixed the bahavior will be practically the same.


Return to “MultiCharts”