auto trading overfilling orders problem

Questions about MultiCharts and user contributed studies.
florianp3
Posts: 20
Joined: 10 Jun 2014
Has thanked: 4 times

auto trading overfilling orders problem

Postby florianp3 » 14 Dec 2014

I am using MC 9.0 build 10360.
My strategy:
vars: LE(c);
if condition1 then begin
if marketposition_at_Broker <1 then buy next bar at LE limit;
end;
In strategy properties, I have not allowed more than 1 contract at a time.
I autotrading properties I have chosen Sync for entries/exits.

While autotrading with Rithmic, applied to a 2 tick chart of CL, I have seen in DOM that at times there were 2 or even 3 contract orders !

I suppose that when condition1 is met for the first time a limit order is sent to the broker, but if the confirmation from the broker that the order has been filled (an thus market position has changed) does not arrive before the next tick comes, then the script recalculates, see that condition1 is true and MarketPosition_at_Broker is 0 and then sends a second limit order to the broker.

I do not want to have a position of more than 1 contract at a time.

Now the question:
Is there a possibility to write code that will make the script wait for the confirmation of the execution of the sent order and so prevent sending the second order?

Maybe if I use both marketposition words like for example:

if condition1 then begin
if marketposition_at_Broker <1 and marketposition_at_broker_foir strategy<1 then buy next bar at LE limit;
end;

Am I not undestanding this correctly? Am I missing something?

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

Re: auto trading overfilling orders problem

Postby TJ » 14 Dec 2014

[FAQ] How to Post Codes (that people can read)
viewtopic.php?f=16&t=11713

User avatar
Smoky
Posts: 507
Joined: 03 Dec 2010
Location: Thailand
Has thanked: 97 times
Been thanked: 115 times

Re: auto trading overfilling orders problem

Postby Smoky » 15 Dec 2014

hi florianp3,

in very high speed computer and small study, (with Intrabar Order Generation next bar is next tick ! )

MarketPosition possible not refresh so rapidly, setup a binary flag to wait broker answer about your order filling !

Code: Select all

if marketposition_at_Broker <1 and sendbuy = false then
begin
buy next bar at LE limit;
sendbuy = true;
end;
reset sendbuy flag when marketposition_at_Broker change !

in your case marketposition_at_Broker and marketposition_at_broker_for strategy is the same with only one stategy runing on this broker ;)

florianp3
Posts: 20
Joined: 10 Jun 2014
Has thanked: 4 times

Re: auto trading overfilling orders problem

Postby florianp3 » 15 Dec 2014

Thanks Smoky, I'll try that


Return to “MultiCharts”