Bug-Automation Sync mode

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

Bug-Automation Sync mode

Postby SUPER » 12 Sep 2008

Another automation BUG with Sync mode.

I ran following code with setting as show in attachment and was surprised to find that instead of 1 trade per bar more were observed on regular intervals. Strange this problem was not observed under Async mode.

Thanks to Martin Miller, who showed me a trick to control trades through a code rather then using the standard limit setting which places artficial constraints on code.

Code: Select all

[intrabarordergeneration=true]


Input: Length(5),VarA(2),VarB(2),EndOfDayExit(true);

Var: LowBar(0),HighBar(0),BuyPrice(0),ShortPrice(0);

Var: MP(0), IntrabarPersist MP_prev(0),

CC(0), IntrabarPersist CC_prev(0),

IntrabarPersist TradesThisBar(0),

IntrabarPersist FirstTickOfBar(False);



MP = MarketPosition;
CC = CurrentContracts;


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



LowBar= Lowest(Low,Length)[1];

HIghBar= Highest(High,Length)[1];

BuyPrice= LowBar + Range[1] * VarA;

ShortPrice=HighBar - Range[1] * VarB;

If TradesThisBar = 0 and MP<> 1 then buy next bar at BuyPrice stop;

If TradesThisBar = 0 and MP<>-1 then sellshort next bar at ShortPrice stop;


if EndOfDayExit then setexitonclose;

FirstTickOfBar = BarStatus(1) = 2;

MP_prev = MP;

CC_prev = CC;
Attachments
settings.jpg
(64.78 KiB) Downloaded 711 times
mc3.jpg
(74.96 KiB) Downloaded 719 times

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

Postby danilo » 13 Sep 2008

SUPER,

I think that you should define as IntrabarPersist also MP and CC.

Regards,
Danilo

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

Postby SUPER » 13 Sep 2008

SUPER,

I think that you should define as IntrabarPersist also MP and CC.

Regards,
Danilo
Danilo,

Thanks for your suggestion, MarketPosition and Current contract update every tick so there is no need to declare them as IntrabarPersist.

If there was an issue with the code it would have produced similar relsults with Async mode.

Regards
Super

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

Postby danilo » 13 Sep 2008

SUPER,

If MP and CC aren't defined IntrabarPersist the value will be updated only at the close of the bar even if MarketPosition and Current contract are updated every tick, this is my understanding of IntrabarPersist keyword.

Regards,
Danilo

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

Postby SUPER » 13 Sep 2008

SUPER,

If MP and CC aren't defined IntrabarPersist the value will be updated only at the close of the bar even if MarketPosition and Current contract are updated every tick, this is my understanding of IntrabarPersist keyword.

Regards,
Danilo
Danilo,

Thanks for your interest, I will try out your suggestion on Monday when market open and will post results.

On historical data the system work same with your suggestion and my original code ( one trade per bar), problems are only seen on live trading.

You have a good weekend.

Regards
Super

2haerim
Posts: 502
Joined: 01 Sep 2006
Been thanked: 2 times

Postby 2haerim » 14 Sep 2008

Can you explain what this code does and how it works?

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

Postby SUPER » 14 Sep 2008

Can you explain what this code does and how it works?
2hareim,

This just a simple test code that I use testing the automation features of MC with IB.

It is an intrbarordergeneration code and I am selecting setting within intrabar order which allow maximum freedom in terms of number of trades it can take place per giver bar. I am controlling the number of trades it should take (1 for example in this case) through powerlanguage code. As stated earlier on historical and without automaiton it works as desired, one trade per bar, however, when I turn on the Sync Mode in Automated trading setting it generates more than one trade as you can see in the screen shot-which should not happen. The same code when run under Asyn mode in Automated trading works well-one trade per bar....which clearly points to problem with Sync Mode.

I hope above explanation is what your are looking for.

Regards
Super

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

Postby SUPER » 15 Sep 2008

SUPER,

If MP and CC aren't defined IntrabarPersist the value will be updated only at the close of the bar even if MarketPosition and Current contract are updated every tick, this is my understanding of IntrabarPersist keyword.

Regards,
Danilo
Danilo,

Thanks for your interest, I will try out your suggestion on Monday when market open and will post results.

On historical data the system work same with your suggestion and my original code ( one trade per bar), problems are only seen on live trading.

You have a good weekend.

Regards
Super
danilo,

Just as much as I suspected, tried our your suggestion and there is no difference-still getting multiple trades per bar-"Sync" mode is not working to expectation.

Lets wait and see what MC has to say about this issue.

Regards
Super


Return to “MultiCharts”