Best practice at placing orders

Questions about MultiCharts and user contributed studies.
janus
Posts: 835
Joined: 25 May 2009
Has thanked: 63 times
Been thanked: 104 times

Best practice at placing orders

Postby janus » 08 Mar 2011

Which of the following is the preferred approach when placing orders in a study with IOG turned on using any of buy, sell, buytocover or sellshort tradesize or all contracts next bar at market?

1. It places the order on each update tick until the position size (MarketPosition_at_Broker) equals the targeted value, or

2. it places the order once only, or

3. it places the order once only but skipping past update ticks when barstatus <= 0 , or

4. it places the order once only but skipping past update ticks when volume did not change , or

5. it places the order indefinitely until a different order is placed, or

6. some other approach?

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

Re: Best practice at placing orders

Postby Dave Masalov » 11 Mar 2011

Dear janus,

When you submit exactly the same orders on the next bar, orders sent on the previous bars are not cancelled but stay at broker and so MC does not send the new ones (if the quiantity of orders, contracts and price is exactly the same). So, in IOG, once the condition has been met, it is better to place exactly the same order on every tick until the condition is valid.

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

Re: Best practice at placing orders

Postby janus » 11 Mar 2011

Dear janus,
When you submit exactly the same orders on the next bar, orders sent on the previous bars are not cancelled but stay at broker and so MC does not send the new ones (if the quiantity of orders, contracts and price is exactly the same). So, in IOG, once the condition has been met, it is better to place exactly the same order on every tick until the condition is valid.
Hi Dave.
Currently I only place the exact same order on every tick. With my current strategy I never generate a new order until the previous order has been filled. I like to keep things simple (KISS principle). I may cancel the order by stop placing it. When you say until the condition is valid do you mean until the order is filled? In any case, is it best to use MarketPosition_at_Broker or MarketPosition_at_Broker_for_The_Strategy to determine when the order is filled? I've noticed that MarketPosition_at_Broker_for_The_Strategy returns the updated value at least one tick earlier.

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

Re: Best practice at placing orders

Postby Dave Masalov » 14 Mar 2011

Dear janus,

MarketPosition_at_Broker - shows market position at broker (sent by broker).
MarketPosition_at_Broker_for_The_Strategy - internal market position at trading mechanism for this particular strategy (monitored using order statuses).
They return different values. If you do not need the absolute market position, you can use MarketPosition_at_Broker_for_The_Strategy. But there is no guarantee that it will came earlier. These are different and independent information channels.

Triage
Posts: 28
Joined: 12 Mar 2012
Has thanked: 2 times
Been thanked: 3 times

Re: Best practice at placing orders

Postby Triage » 17 Aug 2012

Hello Dave,

Sorry for opening an old post, but I think it might be clearer if I ask the question here than in a new post.

1) Does MarketPosition_at_Broker_for_The_Strategy give the market position of the strategy in the MC order engine?

2) If I have multiple strategies in a single chart, then does MarketPosition_at_Broker_for_The_Strategy keep track of each strategy separately for that chart symbol? Or is it supposed to return the total position of all strategies for the chart?

3) Will there be situations when marketposition * current contracts = MarketPosition_at_Broker, but MarketPosition_at_Broker does NOT match MarketPosition_at_Broker_for_The_Strategy?

Thanks in advance for the guidance on the expected behavior of these keywords.
Dear janus,

MarketPosition_at_Broker - shows market position at broker (sent by broker).
MarketPosition_at_Broker_for_The_Strategy - internal market position at trading mechanism for this particular strategy (monitored using order statuses).
They return different values. If you do not need the absolute market position, you can use MarketPosition_at_Broker_for_The_Strategy. But there is no guarantee that it will came earlier. These are different and independent information channels.

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

Re: Best practice at placing orders

Postby Andrew Kirillov » 17 Aug 2012

Hello Triage,
1) Does MarketPosition_at_Broker_for_The_Strategy give the market position of the strategy in the MC order engine?
Yes.
2) If I have multiple strategies in a single chart, then does MarketPosition_at_Broker_for_The_Strategy keep track of each strategy separately for that chart symbol? Or is it supposed to return the total position of all strategies for the chart?
MarketPosition_at_Broker_for_The_Strategy keeps track of each strategy separately.
3) Will there be situations when marketposition * current contracts = MarketPosition_at_Broker, but MarketPosition_at_Broker does NOT match MarketPosition_at_Broker_for_The_Strategy?
It's possible in AA (asynchronous) auto trading mode.

Triage
Posts: 28
Joined: 12 Mar 2012
Has thanked: 2 times
Been thanked: 3 times

Re: Best practice at placing orders

Postby Triage » 17 Aug 2012

Thanks Andrew for the information.

As a follow-up...

It's possible in AA (asynchronous) auto trading mode.

1) In SA (synchronous) mode, an order is sent to the broker from the MC order engine.

The order engine gets back the broker market position for that symbol. Does the MC order engine match the order fill with the right strategy in the chart?

For example:

In SA mode, this will always be true, but not in AA mode:

Strat A:

currentcontracts * marketposition = MarketPosition_at_Broker_for_The_Strategy = MarketPosition_at_Broker

Strat B:

currentcontracts * marketposition = MarketPosition_at_Broker_for_The_Strategy = MarketPosition_at_Broker
Is this correct?
In SA mode, all these calculations should always be true.
In AA mode, all three can be different values.
And this is because SA mode sends the order when the MC order engine sees the strategy marketposition * currentcontracts has changed.

2) In SA mode, once the order is filled, the MC order engine tells the chart to change the position to match the executed trade at the broker. But it does not change the strategy's own marketposition * currentcontracts to what is at the broker.

Is this correct?

Is there a difference in what is shown on the chart and what is calculated in the strategy?

3) So in SA mode, if before the strategy's order is filled at the broker, I create a manual error in the symbol's true brokerage position, then what happens?
a) The chart (and strategy) is updated with the true brokerage position (including my manual error).

b) The chart (and strategy) is updated with only the fill that was sent from the strategy, and not my manual brokerage position error.
4) Any differences with IOG turned on or off?

When does the marketposition and currentcontracts change in SA mode when IOG is turned off if a fill is delayed or reporting is late (say 2 minutes) in a 30 minute chart?

How about in the same situation, but using a 1 minute chart for the strategy?

Triage
Posts: 28
Joined: 12 Mar 2012
Has thanked: 2 times
Been thanked: 3 times

Re: Best practice at placing orders

Postby Triage » 17 Aug 2012

Dear janus,
When you submit exactly the same orders on the next bar, orders sent on the previous bars are not cancelled but stay at broker and so MC does not send the new ones (if the quiantity of orders, contracts and price is exactly the same). So, in IOG, once the condition has been met, it is better to place exactly the same order on every tick until the condition is valid.
Hi Dave.
Currently I only place the exact same order on every tick. With my current strategy I never generate a new order until the previous order has been filled. I like to keep things simple (KISS principle). I may cancel the order by stop placing it. When you say until the condition is valid do you mean until the order is filled? In any case, is it best to use MarketPosition_at_Broker or MarketPosition_at_Broker_for_The_Strategy to determine when the order is filled? I've noticed that MarketPosition_at_Broker_for_The_Strategy returns the updated value at least one tick earlier.
I have the same question, too.

It seems, if I did interpret Dave's answer correctly, that we need to keep running on every tick the same order command until a new condition.

Something like this below will produce very different results. Is this correct?

Code: Select all

if somecondition=true then begin
buy ("ordertype-A") numcontracts contracts next bar at market;
end;

if somecondition=true and barstatus (1) = 2 then begin
buy ("ordertype-B") numcontracts contracts next bar at market;
end;


Return to “MultiCharts”