Partial Execution: Unexpected Profit Target

Questions about MultiCharts and user contributed studies.
TraderJ
Posts: 46
Joined: 14 Jul 2009
Location: Germany
Has thanked: 4 times

Partial Execution: Unexpected Profit Target

Postby TraderJ » 30 Sep 2009

Consider the following example:
I have a LONG position of 10 lots, opened at price 1000. In my strategy I have defined a PROFIT TARGET of 20. MC now correctly issues a take profit order to SELL 10 lots with LIMIT 1020. Suppose the price reaches this limit, but I get only a partial execution of 3 lots. MC should now have a remaining order to SELL 7 lots at LIMIT 1020.

Unfortunately, it cancels the remaining order and now issues a new order to SELL 7 lots at LIMIT 1040.

My strategy sometimes readjusts its profit target according to the market, so it has to call SetProfitTarget() more than once. The readjustments refer to EntryPrice(0) to calculate the opening price of the current position. I suspect that EntryPrice(0) delivers the price of the last execution (in the example above: 1020) instead of the opening price of the remaining position (in the example above: 1000).

Is this a bug in MC 5.5?
Is there any idea how to avoid this problem?

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

Postby Andrew Kirillov » 02 Oct 2009

Dear TraderJ,

Please, use "Replace To Market Partially Filled Orders" option.

You may find it on AutoTrading tab.

TraderJ
Posts: 46
Joined: 14 Jul 2009
Location: Germany
Has thanked: 4 times

Postby TraderJ » 02 Oct 2009

Hallo Andrew,

I can not accept the risk of slippage.
Therefore a MARKET order is no option for me.

Regards,
TraderJ

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

Postby SUPER » 04 Oct 2009

Hallo Andrew,

I can not accept the risk of slippage.
Therefore a MARKET order is no option for me.

Regards,
TraderJ
There is no guarantee for Limit order getting executed......so how would you propose to handle such a situation

TraderJ
Posts: 46
Joined: 14 Jul 2009
Location: Germany
Has thanked: 4 times

Partial Execution Straightforward

Postby TraderJ » 05 Oct 2009

There is no guarantee for Limit order getting executed......so how would you propose to handle such a situation
Straightforward:
1. The partially filled entry order remains in the market.
2. The newly acquired position is handled by the strategy, e.g. protected by PROFIT TARGET and STOP (i.e. a BRACKET).
3. When more lots of the entry order are filled, the sizes of the BRACKET are adjusted accordingly.
4. When PROFIT TARGET or STOP are hit, all other orders are cancelled (i.e. OCA group).

In order to achieve this, I would suggest to always submit the three orders ENTRY, PROFIT and STOP as an OCA group at the same time. This is a standard feature of Interactive Broker's TWS (and most other brokers as well). Those orders do take care of themselves when you use the default feature to automatically have their sizes adjusted to executions.

That would be a great improvement in MultiCharts and it should be quite simple to implement because IB does most of the work.

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

Re: Partial Execution Straightforward

Postby SUPER » 06 Oct 2009

There is no guarantee for Limit order getting executed......so how would you propose to handle such a situation
Straightforward:
1. The partially filled entry order remains in the market.
2. The newly acquired position is handled by the strategy, e.g. protected by PROFIT TARGET and STOP (i.e. a BRACKET).
3. When more lots of the entry order are filled, the sizes of the BRACKET are adjusted accordingly.
4. When PROFIT TARGET or STOP are hit, all other orders are cancelled (i.e. OCA group).

In order to achieve this, I would suggest to always submit the three orders ENTRY, PROFIT and STOP as an OCA group at the same time. This is a standard feature of Interactive Broker's TWS (and most other brokers as well). Those orders do take care of themselves when you use the default feature to automatically have their sizes adjusted to executions.

That would be a great improvement in MultiCharts and it should be quite simple to implement because IB does most of the work.
OK, I see you are requesting for OCA type of orders feature in MC, which I think they are looking at it for future release.

In addition to above you will still require replace to Market Partially filled orders, because at some point you will have to syncronise your chart and broker.

TraderJ
Posts: 46
Joined: 14 Jul 2009
Location: Germany
Has thanked: 4 times

Postby TraderJ » 06 Oct 2009

In addition to above you will still require replace to Market Partially filled orders, because at some point you will have to syncronise your chart and broker.
No, never. The chart should show what is being traded at the broker, not the other way round. I do not want to lose money just because of an insufficient trading platform.

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

Postby SUPER » 06 Oct 2009

In addition to above you will still require replace to Market Partially filled orders, because at some point you will have to syncronise your chart and broker.
No, never. The chart should show what is being traded at the broker, not the other way round. I do not want to lose money just because of an insufficient trading platform.
Sync mode in Multichart shows on chart what is being traded at the broker, it will, for sure get better once OCA type of orders are incorporated in to MC.

It would be interesting to know about any other trading platform that you may know of which works on the principles you have just described.

TraderJ
Posts: 46
Joined: 14 Jul 2009
Location: Germany
Has thanked: 4 times

Postby TraderJ » 06 Oct 2009

It would be interesting to know about any other trading platform that you may know of which works on the principles you have just described.
I do not know of anything better than MC, but as a professional programmer I am considering to write my own trading tool. Nothing nearly as powerful as MC but a trading workhorse which submits orders with all details and controls executions and positions. I guess this would cost me about six months to do.

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

Postby TJ » 06 Oct 2009

you might have to build some routines with these new keywords
Power Language

• Information on the market position can now be received directly from a broker.
Four keywords to request and receive the market position from a broker have been added.

a) Market_Position_at_Broker_for_the_Strategy returns the market position at the broker for a given symbol and a particular strategy. Changes in the values returned by the word are based on the events at the broker. The word can only be used in signals and functions.

b) Market_Position_at_Broker returns the market position at the broker for a given symbol (irrespective of whether the position has resulted from orders submitted through a strategy or manually). Changes in the values returned by the word are based on the events at the broker. The word can only be used in signals and functions.

c) I_Market_Position_at_Broker_for_the_Strategy is similar to Market_Position_at_Broker_for_the_Strategy, the difference being that the former can be used in all types of studies (including indicators).

d) I_Market_Position_at_Broker is similar to Market_Position_at_Broker, the difference being that the former can be used in all types of studies (including indicators).

marekj
Posts: 51
Joined: 07 Aug 2009

Postby marekj » 07 Oct 2009

Does Market_Position_at_Broker_for_the_Strategy and Market_Position_at_Broker return values 0, 1 -1 or real number of shares/contracts ('+' for long position, '-' for short position)?

If not...how to get contracts/shares at broker?

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

Postby TJ » 07 Oct 2009

MarketPosition_at_Broker

Returns a numerical value, indicating the type of the specified position at the broker for the symbol.

A value of 1 indicates a long position, -1 indicates a short position, and 0 is returned only if the current position is specified and indicates that the current position is flat.


Usage

MarketPosition_at_Broker


Notes

This function can only be used in signals and functions.

This function differs from the marketposition keyword in that it cannot take an argument to reference past values.

This function can only be used with Interactive Brokers, Patsystems, and Zen-Fire.


Example

MarketPosition_at_Broker will return a 1 if the current position at the broker for the strategy is long.

MarketPosition_at_Broker will return a -1 if the current position at the broker for the strategy is short.

MarketPosition_at_Broker will return a 0 if the current position at the broker for the strategy is flat.

click Help at your MultiCharts program,
or at the View Navigation Bar window of your PowerLanguageEditor,
you will find the explanations in the PowerLanguage dictionary.

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

Postby SUPER » 08 Oct 2009

Thanks TJ for your input on Market_at_broker,

It would be nice to have an ability to have information on actual contracts, filled, remaining etc, then one can manage some of the routines within the code.


Return to “MultiCharts”