Orders per bar issue?

Questions about MultiCharts and user contributed studies.
SUPER
Posts: 646
Joined: 03 Mar 2007
Has thanked: 106 times
Been thanked: 84 times

Orders per bar issue?

Postby SUPER » 18 May 2010

I am trying to limit one entry or exit per bar and somehow it does not work, On many occasions I get entry and exit on same bar. After trying out the built in format setting without much success, I attempted to accomplish it through a simple code which restricts one trade irrespective off the usual format setting which has not helped. ( see attached image).


Will appreciate help.

Code: Select all


[IntrabarOrderGeneration = True]


Var: IntrabarPersist Mp(0), IntrabarPersist MP_prev(0),IntrabarPersist TradesThisBar(0),IntrabarPersist FirstTickOfBar(False);



MP = MarketPosition;


If MP <> MP_prev then TradesThisBar = TradesThisBar + 1;
If FirstTickOfBar then TradesThisBar = 0;


if BarStatus(1)=2 then Value1=Random(10);

if TradesThisBar = 0 and Mp<>1 and Value1 > 5 then Buy next bar Open Limit;
if TradesThisBar = 0 and Mp<>-1 and Value1 < 5 then SellShort next bar Open Limit;

if TradesThisBar = 0 and Mp=1 and BarsSinceEntry > 1 then Sell next bar at Market;
if TradesThisBar = 0 and Mp=-1 and BarsSinceEntry > 1 then BuyToCover next bar at Market;


FirstTickOfBar = BarStatus(1) = 2;

MP_prev = MP;
Attachments
MC -1.jpg
(449.61 KiB) Downloaded 777 times

SUPER
Posts: 646
Joined: 03 Mar 2007
Has thanked: 106 times
Been thanked: 84 times

Postby SUPER » 18 May 2010

Some more confusion, I changed order type from "Open Limit" to "Open" or "Market" and it seems to work as expected....one order entry or exit per bar.

"Limit" and "Stop" orders seems to have problem from my observations.

Maybe someone from TSSupport can provide some clue?

Code: Select all

[IntrabarOrderGeneration = True]


Var: IntrabarPersist Mp(0), IntrabarPersist MP_prev(0),IntrabarPersist TradesThisBar(0),IntrabarPersist FirstTickOfBar(False);



MP = MarketPosition;


If MP <> MP_prev then TradesThisBar = TradesThisBar + 1;
If FirstTickOfBar then TradesThisBar = 0;


if BarStatus(1)=2 then Value1=Random(10);

if TradesThisBar = 0 and Mp<>1 and Value1 > 5 then Buy next bar Open;//Market;
if TradesThisBar = 0 and Mp<>-1 and Value1 < 5 then SellShort next bar Open;//Market;

if TradesThisBar = 0 and Mp=1 and BarsSinceEntry > 1 then Sell next bar at Market;
if TradesThisBar = 0 and Mp=-1 and BarsSinceEntry > 1 then BuyToCover next bar at Market;


FirstTickOfBar = BarStatus(1) = 2;

MP_prev = MP;

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Postby TJ » 18 May 2010

you should tag your orders

e.g.

Buy ("E1") next bar Open;

SUPER
Posts: 646
Joined: 03 Mar 2007
Has thanked: 106 times
Been thanked: 84 times

Postby SUPER » 19 May 2010

Thanks TJ for your advice-it does help to visualise orders on charts. Unfortunately, it would not make any difference to the core issue of more than one order per bar with order type "Stop" or "Limit"
Last edited by SUPER on 19 May 2010, edited 1 time in total.

janus
Posts: 835
Joined: 25 May 2009
Has thanked: 63 times
Been thanked: 104 times

Re: Orders per bar issue?

Postby janus » 19 May 2010

That's odd. I'm sure I noticed in the past that if you execute multiple orders in a single bar (or even tick if IOG is on and update on each tick is enabled) MC simplifies them into one resultant order. I could be wrong though.

SUPER
Posts: 646
Joined: 03 Mar 2007
Has thanked: 106 times
Been thanked: 84 times

Postby SUPER » 27 May 2010

Bumpup: Awaiting feedback from TSSupport

User avatar
Andrew Kirillov
Posts: 1589
Joined: 28 Jul 2005
Has thanked: 2 times
Been thanked: 31 times
Contact:

Postby Andrew Kirillov » 04 Jun 2010

Super,
Thank you for the report.
Although you sent a lot of logs they don’t contain Trading Server log folder. It is not possible to say that happened without it.

Our assumption looks as following:
1. You sent a market order.
2. We haven’t got an execution status from IB for 30 seconds.
3. We sent a cancel command and assumed the order will be never executed.
4. It executed later and updated the tracking window, but we didn’t reflect it on the chart/strategy logic.

Basically speaking we don’t consider this situation as normal, but to be sure that our assumption is correct we need Trading Server log folder.
If you didn’t restart MC and can send this folder please do. Otherwise we will have to wait for this issue.

SUPER
Posts: 646
Joined: 03 Mar 2007
Has thanked: 106 times
Been thanked: 84 times

Postby SUPER » 05 Jun 2010

Hi Andrew,

Many thanks for your reply, I think it is to do with my other post:
http://forum.tssupport.com/viewtopic.php?t=7462

I tried to send you requested log file some how it is bouncing back, it seems the file is too large (15mb) for your servervice provider to accept.

I will contact your Live help desk on Monday and I hope they can upload it.

Regards
Super

User avatar
Dave Masalov
Posts: 1712
Joined: 16 Apr 2010
Has thanked: 51 times
Been thanked: 489 times

Postby Dave Masalov » 08 Jun 2010

Dear SUPER,

Andrew's answer is to do with your other post, indeed(http://forum.tssupport.com/viewtopic.php?t=7462)

Regarding this one:

1) Everything happens according to the rules of EasyLanguage.

2) The IOG limitations won't help you to do one order on a bar in this case, because you have one entry and one exit. T It does not go against your settings: http://forum.tssupport.com/download.php?id=2790

3) Signal withLimit Entry.
When Limit Entry and Market Exit orders are executed on the same bar, both of them may be filled. Firstly, the market orders are processed and the exit is executed. Then, the price orders are processed, and, because the entry is possible, it is also executed.

4) Signal with Market Entry.
When the Market Entry and Market Exit orders are executed on the same bar, only one of them may be filled.
All mareket orders are processed together in the priority sequence
In your case the Market Entry is the reverse order (sometimes), which has the higher priority than the Market Exit. That is why you see the execution of only one Market Entry, when the reverse happens. Indeed, there is no need to execute Market Exit, and then Market Entry in the opposite position, when the execution of only one Market Entry leads to the same result.

5) We have deleted Limit Entry and Market Exit as well as the function Random from your signal and compared its behavior in MultiChatrs and TS. The calculations are the same.

Please find attached the screen shot.
Attachments
TS&MC.PNG
(61.9 KiB) Downloaded 764 times

SUPER
Posts: 646
Joined: 03 Mar 2007
Has thanked: 106 times
Been thanked: 84 times

Postby SUPER » 09 Jun 2010

Dave,

Thanks for your detailed explanation on inner working of order placement which are outside our script control, I wish there was a way around to control entry and exit orders per bar.

I know TS has similar issues but I thought that MC would not carry same weakness.

Regards
Super


Return to “MultiCharts”