GenerateStopLoss issue with its STP Orders with IB in IOG !

Questions about MultiCharts .NET and user contributed studies.
sylfvdk
Posts: 57
Joined: 06 Dec 2005

GenerateStopLoss issue with its STP Orders with IB in IOG !

Postby sylfvdk » 15 Aug 2016

Hi,
I have simple Signal where I have 2 lines of code on CalcBar():
- Unconditional GENERATESTOPLOSS,
- and Buy at Market after 11. That's it.


In IB, I see orders:
- Bought at 11, which is OK, Right after that I see:
- STP Order with correct share amount, which I expect as well. BUT AFTER THAT I HAVE:
- after several seconds - My STP order is canceled and New STP order issued.

It happens ONLY in IOG = true. Issue is 100% reproducible.

The only way I could get rid of this CANCEL / Re-SUBMIT of STP orders is after:
- Unchecked Broker events (both on Position change and on Position Filled)
- Put GENERATESTOPLOSS under condition if MarketPosition <> 0

Dear Support. This issue means for me that either I don't understand how it works or it is bug with MC / IB communication.

Why I have STP orders Cancelled and re-created.
No change in position, I always sell /buy the same number of shares.

Please, Investigate my request.

User avatar
Kristina MultiCharts
Posts: 63
Joined: 04 Sep 2014
Has thanked: 5 times
Been thanked: 34 times

Re: GenerateStopLoss issue with its STP Orders with IB in IO

Postby Kristina MultiCharts » 17 Aug 2016

Hello,

We are currently looking into this case on our end. I'll get in touch with you via email as soon as I have some feedback from the engineers.

User avatar
Kristina MultiCharts
Posts: 63
Joined: 04 Sep 2014
Has thanked: 5 times
Been thanked: 34 times

Re: GenerateStopLoss issue with its STP Orders with IB in IO

Postby Kristina MultiCharts » 22 Aug 2016

Hello,

The issue was confirmed by our engineers. We are working on the fix. As soon as we have some updates on the ETA we'll let you know.

User avatar
Kristina MultiCharts
Posts: 63
Joined: 04 Sep 2014
Has thanked: 5 times
Been thanked: 34 times

Re: GenerateStopLoss issue with its STP Orders with IB in IO

Postby Kristina MultiCharts » 15 Sep 2016

Hello,

Upon further analysis of the case, the engineers confirmed that everything is working as expected
in accordance with your workspace settings.

You selected options for strategy recalculation on "Market Position Change" and "Order Filled" events in Strategy Properties.

In MultiCharts.Net for calculation on these events you need to override these methods:

protected override void OnBrokerPositionChange() and protected override void OnBrokerStategyOrderFilled(bool is_buy, int quantity, double avg_fill_price)

Otherwise, when the strategy is recalculated on these events no orders will be generated and as a result of such calculation all existing orders will be cancelled.

You can either override the methods or uncheck the options to recalculate on "Market Position Change" and "Order Filled" events in Strategy Properties.

Please add the methods below to your signal code:

Code: Select all

protected override void OnBrokerPositionChange()
{
base.OnBrokerPositionChange();
CalcBar();
}

protected override void OnBrokerStategyOrderFilled(bool is_buy, int quantity, double avg_fill_price)
{
base.OnBrokerStategyOrderFilled(is_buy, quantity, avg_fill_price);
CalcBar();
}

sylfvdk
Posts: 57
Joined: 06 Dec 2005

Re: GenerateStopLoss issue with its STP Orders with IB in IO

Postby sylfvdk » 16 Sep 2016

Hi, Kristina. Thanks for reply.
Very well explained, I am sure those fixes would work.

However, still have minor questions:
- Why CalcBar() call is not included in base OnBrokerPositionChange() and OnBrokerStategyOrderFilled() functions on the first place and left for custom code to extend that;

-Is these 2 functions ever supposed to be used as stand alone with out CalcBar() call?

This is just for my understanding.

Thanks,
Victor

User avatar
Kristina MultiCharts
Posts: 63
Joined: 04 Sep 2014
Has thanked: 5 times
Been thanked: 34 times

Re: GenerateStopLoss issue with its STP Orders with IB in IO

Postby Kristina MultiCharts » 19 Sep 2016

Hello,

CalcBar is not called on "Market Position Change" and "Order Filled" events, OnBrokerPositionChange() and OnBrokerStategyOrderFilled() methods are called on those events. It is up to the user to decide whether to call CalcBar or not. In your case in order for your existing orders not be cancelled and replaced, you need to call CalcBar from those 2 methods. Please use the provided example that I sent you in the previous reply.


Return to “MultiCharts .NET”