stop loss not submitted  [SOLVED]

Questions about MultiCharts and user contributed studies.
User avatar
fbertram
Posts: 166
Joined: 16 Oct 2014
Location: Seattle, USA
Has thanked: 37 times
Been thanked: 73 times
Contact:

stop loss not submitted

Postby fbertram » 14 Jan 2015

Dear MultiCharts fans,

today, I was seeing an issue with a stop loss order not submitted to the broker. Here is the string of events:
* a stop-order is triggered, surprisingly far away from the market price
* because of that, the signal wasn't aware the order filled
* this seems to have caused the stop-loss order to not being submitted

What I would have liked to see:
* submission of the stop-loss order the moment the order was filled - pretty much regardless if my signal agrees with the position being opened or not

Further info:
* I am working with daily data in Portfolio Trader
* the signal is set to recalculate on order filled, but not on market position change
* mode is set to Sync

What am I missing?


Thank you,
best regards, Felix

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 558 times

Re: stop loss not submitted

Postby Andrew MultiCharts » 15 Jan 2015

Hello fbertram,
* a stop-order is triggered, surprisingly far away from the market price
Stop order price is determined by your code. Most likely you need to re-configure the inputs or check the price calculation in the code itself.
* because of that, the signal wasn't aware the order filled
* this seems to have caused the stop-loss order to not being submitted
...
* the signal is set to recalculate on order filled, but not on market position change
* mode is set to Sync
Judging by what you have described, the strategy must have been synced. I see the only possible reason of this - the order status was not received from the broker.
Is there any particular reason why the 'recalculate on position change" is not used?
These users thanked the author Andrew MultiCharts for the post:
fbertram

orion
Posts: 250
Joined: 01 Oct 2014
Has thanked: 65 times
Been thanked: 104 times

Re: stop loss not submitted

Postby orion » 15 Jan 2015

Is there any particular reason why the 'recalculate on position change" is not used?
Andrew, there are two options for recalculate setting: (a) market position change, and (b) order filled. I understand these correspond to different response messages received from broker.

1. Is one more responsive than the other and are you recommending that setting recalculate on market position change is to be preferred?

2. What exact broker responses do these correspond to? Take IB as example for answering the question.

Thanks.

User avatar
fbertram
Posts: 166
Joined: 16 Oct 2014
Location: Seattle, USA
Has thanked: 37 times
Been thanked: 73 times
Contact:

Re: stop loss not submitted

Postby fbertram » 15 Jan 2015

Hi Andrew,

thanks a lot for your response. The only reason why I didn't use 'recalculate on position change' is because MultiCharts has it disabled by default...

I was able to understand a little better what happened. Actually MultiCharts didn't fail to place the stop-loss order. Instead, IB was executing the order after the regular trading session ended - which is why MultiCharts didn't see it. See my other thread.


Thank you,
best regards, Felix

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 558 times

Re: stop loss not submitted  [SOLVED]

Postby Andrew MultiCharts » 16 Jan 2015

Andrew, there are two options for recalculate setting: (a) market position change, and (b) order filled. I understand these correspond to different response messages received from broker.
That is correct.
1. Is one more responsive than the other and are you recommending that setting recalculate on market position change is to be preferred?
2. What exact broker responses do these correspond to? Take IB as example for answering the question.
The point is: those message can come asynchronically and also sometimes some of them may even get lost. This is why there are 2 options.
The only reason why I didn't use 'recalculate on position change' is because MultiCharts has it disabled by default...
You actually did the right thing. It is not accidential that the "market position change" is not checked there. Otherwise it would trigger recalculation on every market position change for the whole portfolio.
These users thanked the author Andrew MultiCharts for the post (total 2):
fbertramorion

orion
Posts: 250
Joined: 01 Oct 2014
Has thanked: 65 times
Been thanked: 104 times

Re: stop loss not submitted

Postby orion » 16 Jan 2015

The point is: those message can come asynchronically and also sometimes some of them may even get lost. This is why there are 2 options.
You actually did the right thing. It is not accidential that the "market position change" is not checked there. Otherwise it would trigger recalculation on every market position chnage for the whole portfolio.
Andrew, thanks for clarifying. Two more questions to clear my confusion on this topic:
1. I should leave the "market position change" unchecked to not trigger frequent recalculation?
2. What exactly is meant by "recalculation" since any order action in PL code has a "next bar" clause and orders will not fire until next bar. So how does immediate recalculation on order fill help? What is being recalculated?

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 558 times

Re: stop loss not submitted

Postby Andrew MultiCharts » 16 Jan 2015

1. I should leave the "market position change" unchecked to not trigger frequent recalculation?
Yes.
2. What exactly is meant by "recalculation" since any order action in PL code has a "next bar" clause and orders will not fire until next bar. So how does immediate recalculation on order fill help? What is being recalculated?
Example 1:

Code: Select all

Buy next bar market;
SetStopLoss(50);
SetProfitTarget(100);
Recalculate on market position change + order filled.

On close of bar 51 all 3 orders are generated.
On open of bar 52 the market order is triggered.
When bar 52 is not yet closed the order is filled.
The stop loss and profit target orders are sent even though the IOG is not used/allowed.

Example 2:

Code: Select all

Buy next bar market;
SetStopLoss(50);
SetProfitTarget(100);
No recalculations on market position change + order filled.

The same as above.

Example 3:

Code: Select all

[IntrabarOrderGeneration=true]
Buy next bar market;
SetStopLoss(50);
SetProfitTarget(100);
Recalculate on market position change + order filled.

On close of bar 51 all 3 orders are generated.
On open of bar 52 the market order is triggered.
If before the second tick of bar 52 the order is filled, the code is recalculated before the second tick.
The stop loss and profit target orders are sent at the second tick of the bar 52.

Example 4:

Code: Select all

[IntrabarOrderGeneration=true]
Buy next bar market;
SetStopLoss(50);
SetProfitTarget(100);
No recalculations on market position change + order filled.

On close of bar 51 all 3 orders are generated.
On open of bar 52 the market order is triggered.
If before the second tick of bar 52 the order is filled, the code is NOT recalculated before the second tick.
The code is recalculated at the second tick of the bar 52.
The stop loss and profit target orders are sent at the third tick of the bar 52.
These users thanked the author Andrew MultiCharts for the post:
orion


Return to “MultiCharts”