IntrabarOrderGeneration and buy/sell event

Questions about MultiCharts and user contributed studies.
nvitale
Posts: 15
Joined: 04 Jun 2011
Location: London
Has thanked: 1 time
Contact:

IntrabarOrderGeneration and buy/sell event

Postby nvitale » 05 Jul 2011

Hi All,

I am using a multitimeframe strategy. I want to print in output with messagelog the values of a variable at each order. I have intrabar order generation enabled.
So in each If clause where I open an order I print my variable.

However I find 3 times more print than orders. Looking deeper, it seems that intrabar order generation triggers several execution but only once is executed.

If I deactivate intrabar order generation, I get same number of print than the number of orders.

So, is tere a way to print an output only once for any order when intrabarorder generation is activated?

Precision: In IOG config, allowing only once or several orders per bar does not make any difference on this problem.

Many thanks for your help.

User avatar
Stan Bokov
Posts: 963
Joined: 18 Dec 2009
Has thanked: 367 times
Been thanked: 302 times

Re: IntrabarOrderGeneration and buy/sell event

Postby Stan Bokov » 05 Jul 2011

Hi,

It's everything to do with your script. Which orders are you sending? Price orders? They can be modified, cancelled and replaces. Generation of an order and print to an output are guaranteed, but it's execution on the next tick isn't.

Is your question - how do I print only those that executed?

nvitale
Posts: 15
Joined: 04 Jun 2011
Location: London
Has thanked: 1 time
Contact:

Re: IntrabarOrderGeneration and buy/sell event

Postby nvitale » 05 Jul 2011

Hi,

yes exactly. I would like to print only once my indicator value when the order is executed. Apparently the code calling the order is done several time a bar but execution is done only once the bar is closed. That would explained the multiple print.

Would you have a solution to print only once?

Thanks.

User avatar
Stan Bokov
Posts: 963
Joined: 18 Dec 2009
Has thanked: 367 times
Been thanked: 302 times

Re: IntrabarOrderGeneration and buy/sell event

Postby Stan Bokov » 06 Jul 2011

You can print once the marketposition changes. You can print entryprice or exitprice depending on the order. If the MP changed, that means the order just got filled :)

nvitale
Posts: 15
Joined: 04 Jun 2011
Location: London
Has thanked: 1 time
Contact:

Re: IntrabarOrderGeneration and buy/sell event

Postby nvitale » 06 Jul 2011

I already tried that of course but surely not on the good way.
I am a professional developer so I am a bit lost sometimes with EL way of doing things.

To detect a market position change what would be the more logical MC way to do it?
Store previous position in a interabarpersisted variable and compare now position with previous?

User avatar
Stan Bokov
Posts: 963
Joined: 18 Dec 2009
Has thanked: 367 times
Been thanked: 302 times

Re: IntrabarOrderGeneration and buy/sell event

Postby Stan Bokov » 06 Jul 2011

I would assume check marketposition on the current bar and if it doesn't match MP on the last bar then there was a change. I'm not an EL programmer, but I think that's how it's done. You add the check into a condition, and if it changed, then print.

nvitale
Posts: 15
Joined: 04 Jun 2011
Location: London
Has thanked: 1 time
Contact:

Re: IntrabarOrderGeneration and buy/sell event

Postby nvitale » 06 Jul 2011

MarketPosition[1] reports previous position or position of the previous bar?
Thanks

User avatar
Stan Bokov
Posts: 963
Joined: 18 Dec 2009
Has thanked: 367 times
Been thanked: 302 times

Re: IntrabarOrderGeneration and buy/sell event

Postby Stan Bokov » 06 Jul 2011

Code: Select all

var: mp(0);
mp = MarketPosition;
mp[1] //market position for the last bar

nvitale
Posts: 15
Joined: 04 Jun 2011
Location: London
Has thanked: 1 time
Contact:

Re: IntrabarOrderGeneration and buy/sell event

Postby nvitale » 06 Jul 2011

Thanks

User avatar
Stan Bokov
Posts: 963
Joined: 18 Dec 2009
Has thanked: 367 times
Been thanked: 302 times

Re: IntrabarOrderGeneration and buy/sell event

Postby Stan Bokov » 06 Jul 2011

You are welcome.

nvitale
Posts: 15
Joined: 04 Jun 2011
Location: London
Has thanked: 1 time
Contact:

Re: IntrabarOrderGeneration and buy/sell event

Postby nvitale » 06 Jul 2011

Unfortunately, issue is still here...

in my last line of code, after order command I put:

Code: Select all

messagelog(marketposition,marketposition[1] );
With Intrabar Order Generation activated, logs give me:

-1.00 -1.00
-1.00 -1.00
1.00 1.00
1.00 1.00
1.00 1.00

How can this be possible?

It is multi timeframe, I precise.

Thanks

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

Re: IntrabarOrderGeneration and buy/sell event

Postby TJ » 06 Jul 2011

Unfortunately, issue is still here...

in my last line of code, after order command I put:

Code: Select all

messagelog(marketposition,marketposition[1] );
With Intrabar Order Generation activated, logs give me:

-1.00 -1.00
-1.00 -1.00
1.00 1.00
1.00 1.00
1.00 1.00

How can this be possible?

It is multi timeframe, I precise.

Thanks
Please read Stan's example (post #8) carefully.


the square bracket [1] is a bar reference.

the proper syntax for marketposition is the regular bracket

marketposition(1)

nvitale
Posts: 15
Joined: 04 Jun 2011
Location: London
Has thanked: 1 time
Contact:

Re: IntrabarOrderGeneration and buy/sell event

Postby nvitale » 06 Jul 2011

It is what I want. Position from previous bar. Cf explanations above

nvitale
Posts: 15
Joined: 04 Jun 2011
Location: London
Has thanked: 1 time
Contact:

Re: IntrabarOrderGeneration and buy/sell event

Postby nvitale » 07 Jul 2011

Does someone from MC can explain this? Or should I raise it as a bug.


Return to “MultiCharts”