execution of limit orders creating problems

Questions about MultiCharts and user contributed studies.
janus
Posts: 754
Joined: 25 May 2009
Has thanked: 41 times
Been thanked: 84 times

execution of limit orders creating problems

Postby janus » 29 Mar 2012

I have a major problem when my limit orders are filled. A test scenario is as follows:

1. Send a buy order for 2 contracts and wait for them to be filled.
2. When filled I then send a sell limit order for 1 contract and wait for it to be filled.
3. When filled I then turn off automatic execution of the strategy via the chart window.

The strategy stops but it doesn't give the warning there's still one contract open and give me the option to close it. So, it leaves 1 contract open at the broker and I have to close it manually via IB's TWS application.

If I change the code so that the limit order is not filled so easily, everything works fine only if I turn off automatic execution before it's filled, and I do get the message. What am I missing here? See sample code to demonstrate this strange behaviour. I discovered this issue when I was trying to cover all open positions (see code that's commented out at the end). The "cover all" didn't work after my limit orders were filled.

<< updated code posted below >>
Last edited by janus on 01 Apr 2012, edited 1 time in total.

janus
Posts: 754
Joined: 25 May 2009
Has thanked: 41 times
Been thanked: 84 times

Re: execution of limit orders creating problems

Postby janus » 30 Mar 2012

I just tried it on my older PC running 7.0 instead of the latest 7.4, and it worked fine. I'll upgrade the older one and see if it still works. The only other difference is the older one is running W7 32-bit instead of W7 64-bit.

janus
Posts: 754
Joined: 25 May 2009
Has thanked: 41 times
Been thanked: 84 times

Re: execution of limit orders creating problems

Postby janus » 01 Apr 2012

Well, I upgraded my test PC from 7.0 to 7.4 (latest build) and the problem is now there too, same as on my production PC. Next, I removed MC on the test PC but kept the studies, database, etc. After re-installing it the problem was still there. Next, I removed MC completely, studies, database, etc. After re-installing it the problem still remained.

Surely I'm not the only one experiencing this so I'm very surprised no one else has discovered what I consider is a major bug in MC. Unless I'm doing something wrong in my code (and I challenge anyone to fault it - see updated code below) I can't come to any other conclusion. I'll be contacting support live ASAP.
Update: I replaced the code with a far more simplified version...

Code: Select all

[IntrabarOrderGeneration = True]

variables:
   intrabarpersist n(0), intrabarpersist entry.price(0);


if LastBarOnChart_s and barstatus >= 0
and GetAppInfo(airealtimecalc) = 1
and GetAppInfo(aiStrategyAuto) = 1
then begin

   print ("n=",n:0:0,"  MarketPosition_at_Broker=",MarketPosition_at_Broker:0:0);
   if n = 1 then buy 2 contracts next bar at market;
   if MarketPosition_at_Broker = 2 then entry.price = avgentryprice;
   
   // lower limit forces fill immediately
   if MarketPosition_at_Broker = 2 then sell 1 contracts total next bar at entry.price-10 limit;

   // cover reamining contract (doesn't work)
   if MarketPosition_at_Broker = 1 then sell all contracts next bar at market;

   // this works if the sell limit order is commented out
   //if MarketPosition_at_Broker = 2 then sell all contracts next bar at market;

   RecalcLastBarAfter(2);
   n = n + 1;
end;
Last edited by janus on 02 Apr 2012, edited 2 times in total.

User avatar
JoshM
Posts: 2084
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1525 times
Been thanked: 1483 times
Contact:

Re: execution of limit orders creating problems

Postby JoshM » 02 Apr 2012

What is the problem here?

Is it this..

janus wrote:I have a major problem when my limit orders are filled. A test scenario is as follows:

1. Send a buy order for 2 contracts and wait for them to be filled.
2. When filled I then send a sell limit order for 1 contract and wait for it to be filled.
3. When filled I then turn off automatic execution of the strategy via the chart window.

The strategy stops but it doesn't give the warning there's still one contract open and give me the option to close it.


or (from your last post)..

Code: Select all

   if MarketPosition_at_Broker = 1 then sell all contracts next bar at market;            // cover reamining contract (doesn't work)


I'm asking because they are two different things, one where you manually shut down a strategy and don't get a pop-up about remaining open orders, and the other where the code isn't working as it should.

-----

Regarding the second problem:

Code: Select all

   if MarketPosition_at_Broker = 1 then sell all contracts next bar at market;            // cover reamining contract (doesn't work)


The cover remaining contract does work here.

For example:
screenshot.536.png
screenshot.536.png (1.92 KiB) Viewed 394 times

screenshot.537.png
screenshot.537.png (5.21 KiB) Viewed 383 times


Generated with the code (the same version as from your post, but set my formatting preferences so I could better "read" it):

Code: Select all

[IntrabarOrderGeneration = True]

variables:
   intrabarpersist n(0), intrabarpersist entry.price(0),
   mpAtBroker(0);


if (LastBarOnChart_s = True) and (GetAppInfo(aiRealTimeCalc) = 1) and
   (GetAppInfo(aiStrategyAuto) = 1) then begin
   
   Print(margin);
   mpAtBroker = MarketPosition_at_Broker;
   
   print(FormatTime("HH:mm:ss", ComputerDateTime), Spaces(3),
      "n = ", NumToStr(n, 0),"  MarketPosition_at_Broker = ", NumToStr(mpAtBroker, 0));
   
   if (n = 1) then
      buy ("EL LmtTest") 2 contracts next bar at market;
   
   if (mpAtBroker = 2) then
      entry.price = AvgEntryPrice;
   
   if (mpAtBroker = 2) then
      sell ("XL #1 LmtTest") 1 contracts next bar at entry.price - 10 limit;   
   // lower limit forces fill immediately
   
   if (mpAtBroker = 1) then
      sell ("XL #2 LmtTest") all contracts next bar at market;
   // cover reamining contract (doesn't work)
   
   //if MarketPosition_at_Broker = 2 then sell all contracts next bar at market; // this works if the sell limit order is commented out
 
   RecalcLastBarAfter(2);
   n = n + 1;
end;

User avatar
JoshM
Posts: 2084
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1525 times
Been thanked: 1483 times
Contact:

Re: execution of limit orders creating problems

Postby JoshM » 02 Apr 2012

Original post removed since it was indeed a "Monday morning"-error.

----
Explanation:
Because if the 2 contracts for the position aren't filled directly (but partially filled), the condition that submits this order...

Code: Select all

 if (mpAtBroker = 1) then
      Sell ("XL #3 LmtTest") 1 contracts next bar at entry.price + 5 limit; 


.. becomes true for one or two ticks, and is then cancelled since, when the whole position is filled, the mpAtBroker = 1 condition becomes false.

----

Sorry for this monitarily off-topic part. :)
Last edited by JoshM on 02 Apr 2012, edited 2 times in total.

janus
Posts: 754
Joined: 25 May 2009
Has thanked: 41 times
Been thanked: 84 times

Re: execution of limit orders creating problems

Postby janus » 02 Apr 2012

JoshM wrote:What is the problem here?

It's both but I'm now focusing on the cover not working. The odd thing is I see it on both of my computers. It worked on version 7.0 yesterday. Clearly I need to get support to look at it. Something is really odd.

janus
Posts: 754
Joined: 25 May 2009
Has thanked: 41 times
Been thanked: 84 times

Re: execution of limit orders creating problems

Postby janus » 02 Apr 2012

JoshM wrote:I tried to replicate this behavior, and something weird happened: the submitting of a second limit order failed, and the strategy could not close the open position.

Please see attached screenshot for my strategy properties. I can't go past the first cover so I can't tests subsequent orders. In my case the position tracker window didn't log a thing when mine sent out the cover order.
Attachments
strategy properties.png
strategy properties.png (49.09 KiB) Viewed 399 times

User avatar
Henry MultiСharts
Posts: 8479
Joined: 25 Aug 2011
Has thanked: 1211 times
Been thanked: 2719 times

Re: execution of limit orders creating problems

Postby Henry MultiСharts » 02 Apr 2012

Hello Janus,

There has been a confirmed issue in MC 7.4 with partial exits. It is already fixed in MultiCharts 8.0
Please update to the latest version 8.0 beta 2 to fix this issue.

janus
Posts: 754
Joined: 25 May 2009
Has thanked: 41 times
Been thanked: 84 times

Re: execution of limit orders creating problems

Postby janus » 02 Apr 2012

Henry Multicharts wrote:Hello Janus,

There has been a confirmed issue in MC 7.4 with partial exits. It is already fixed in MultiCharts 8.0
Please update to the latest version 8.0 beta 2 to fix this issue.

No, not good enough. I need it in 7.4. I won't use a beta to trade with real money. Please supply a hot fix.

janus
Posts: 754
Joined: 25 May 2009
Has thanked: 41 times
Been thanked: 84 times

Re: execution of limit orders creating problems

Postby janus » 02 Apr 2012

One other point. Am I the only MC user in the world using partial exists? Is this for real? This must goe to show MC is not very popular. Such a major bug would have been picked up almost immediately if it appeared in a new release of say TS or NT Trader. I didn’t pick it up until I started to use the sell limit order again just recently. In the recent past I exited my positions programmatically by checking the current price with my exit targets. Before that I did play around with limit orders with my cover all orders to take profit and it worked. I should have kept doing it so that I would have discovered the problem in 7.4 and reported it a lot sooner. I must be the only MC user in the world using this combination of limit exit order and cover all order, yet it's something so basic I would expect lots of traders would do it, especially those who pyramid their trades.

I'm really horrified at this poor state of affairs. Any new software about to be released should first pass a few basic and simple tests like the one I'm using. I now have to resort to my own sequence of more complicated tests to make sure any new release can be trusted for trading with real money. No one should have to do this but it appears we now need to. I’ve developed 17 steps in my more exhaustive study so far but I can’t test is yet due to this major bug. If anyone is interested I’ll post the code once it works with a fixed version of MC.

I really can't believe this is happening. I am saddend to say I have lost a lot of faith and trust in MC, and I'm not sure if I will keep using it but I probably will since I don't relish the thought of learnig another package. I hope this is a good lesson for MC. They can add all the fancy bells and whistles they and users like but if orders don't work at all then the package is just rubbish, plain and simple.
These users thanked the author janus for the post:
JoshM

User avatar
JoshM
Posts: 2084
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1525 times
Been thanked: 1483 times
Contact:

Re: execution of limit orders creating problems

Postby JoshM » 02 Apr 2012

Henry Multicharts wrote:There has been a confirmed issue in MC 7.4 with partial exits. It is already fixed in MultiCharts 8.0
Please update to the latest version 8.0 beta 2 to fix this issue.

First off, I'm glad it's already fixed. :) But on the other hand, I don't see this issue in the Project Management for MC 8.0. Why is that? And, when was this issue confirmed?

I must admit I'm somewhat annoyed that this wasn't communicated, and it makes me wonder how much other known bugs aren't communicated. I've spend an hour this morning looking and testing, and I assume Janus spend even more time on this. Not to mention the users who don't visit the forum but communicate with MC support directly through email.

Worse yet, we could have lost trading capital or even shut-down a good, viable strategy because we could think "it just doesn't work in MC". If this issue was already confirmed to/by the MC engineers, I think the users should have been informed, because:

  • That would enable us to go over our strategies and make the necessary changes,
  • We could have added a workaround where necessary,
  • We could have saved the time debugging and trying and trying with already known bugs.

I understand that, from a marketing standpoint, you would rather not post the known bugs on the forum or in the Project Management, since that might give potential customers the suggestion that MC is very buggy (which is far from the case).

But it would have been a possibility to send every registered user a email (for example, once a month or bi-weekly) with the latest developments and new insights. Or send the registered users a private message here on the forum. With all these low-cost electronic communications tools at your disposal, there is no good excuse to keep us not informed about important MultiCharts related news.

I mean, we (the "quantitative oriented and automated"-MultiCharts user) are generally technically educated enough to know that no software is bug-free, and we are mature enough to understand that not every bug can be fixed quickly or is given a high priority. We get that.

I think that we, as professional retail traders, would be more than happy to know upfront about these confirmed issues. I mean, we are all professionals here -- we (the MultiCharts users) make mistakes, I make (plenty of) mistakes, and you (MC Support) make mistakes. That's life and it's inherent to any work or trading activity. So why not be upfront about it?
Last edited by JoshM on 02 Apr 2012, edited 2 times in total.

janus
Posts: 754
Joined: 25 May 2009
Has thanked: 41 times
Been thanked: 84 times

Re: execution of limit orders creating problems

Postby janus » 02 Apr 2012

Yes, it's not good. I was hoping it was a problem at my end but it now does appear it's a problem with 7.4. For for all intents and purposes 7.4 is dead and should be pulled unless a hot fix can be provided ASAP. The bug is critical. Either go back to 7.0 or take the chance with 8.0 beta. I'm not interested in excuses. I just want to use a release of MC that works with partial exits, something that a typical stock or futures trader would do on a regular basis.

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

Re: execution of limit orders creating problems

Postby Dave Masalov » 02 Apr 2012

But on the other hand, I don't see this issue in the Project Management for MC 8.0. Why is that? And, when was this issue confirmed?


JoshM,

The fix was confirmed in the following post: viewtopic.php?f=1&t=9860#p47074

And in the What's New:

https://www.multicharts.com/traders-blog/?p=540
Stability/Performance
• Assert when doing partial exit of a position in Synchronous Autotrading mode, and no dialog window for closing the position.

Project Management is mainly a tool for our customers to report bugs and submit feature requests and then track the progress. Generally, we do not submit issues ourselves and if the issue has been reported directly to our Support Team it goes right to our internal fix list.

I just want to use a release of MC that works with partial exits, something that a typical stock or futures trader would do on a regular basis.


janus,

The hot fix has been sent to you in a PM. Let us know if it fixes th eissue on your end.
These users thanked the author Dave Masalov for the post:
JoshM

User avatar
JoshM
Posts: 2084
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1525 times
Been thanked: 1483 times
Contact:

Re: execution of limit orders creating problems

Postby JoshM » 02 Apr 2012

Dave Masalov wrote:The fix was confirmed in the following post: viewtopic.php?f=1&t=9860#p47074

And in the What's New:

https://www.multicharts.com/traders-blog/?p=540
Stability/Performance
• Assert when doing partial exit of a position in Synchronous Autotrading mode, and no dialog window for closing the position.

Project Management is mainly a tool for our customers to report bugs and submit feature requests and then track the progress. Generally, we do not submit issues ourselves and if the issue has been reported directly to our Support Team it goes right to our internal fix list.

Thanks Dave. I know that the fixed bugs are mentioned in the blog, but my point was that there might be bugs on the internal fix list that we (MC users) might benefit from by having knowledge of these. That's why I mentioned the Project Management, since there can be seen which things are being targeted for future versions.

I understand it would be tedious and in practice not doable to add everything on the internal fix list to the Project Management, but would you take into consideration the suggestion to make a kind of newsletter, where MC Support can communicate what confirmed bugs (from the internal fix list) are targeted for the next version?

However, it might be that with knowledge of that, all users want a hotfix for the issue that's relevant for them, and if you have to turn them down (since there are also other things the engineers have to attend to), which might not enhance customer satisfaction at all now I come to think of it.

So it might not be such a great idea as I thought recently. I'm still in favour of more communication about this, but do not know how good such a plan in practice would be (with that I 'rest my case' so to speak).

Anyway, thanks for listening. :) And my apologies if I a come across a 'little' bit to strong.

janus
Posts: 754
Joined: 25 May 2009
Has thanked: 41 times
Been thanked: 84 times

Re: execution of limit orders creating problems

Postby janus » 02 Apr 2012

Thanks Dave for letting me know about the hot fix. I'm now even more shocked it wasn't communicated more appropriately. Why isn't a newer version of MC released incorporating the fix? I find this very distributing and puzzling. How many other major problems exist that have hot fixes? Surely at a minimum the download section should list all available hot fixes with descriptions so users can apply them at their own discretion where necessary. This is what just about every other application I use does. For an important application such as an automatic trading system this has to be done to help traders avoid losing money as a result of buggy software. Some applications do it even better by alerting the user via email or when the user starts it. Sifting through a blog, which I rarely use anyway is not the solution. It's ludicrous to expect users to discover such fixes the way I did when there's a fix already available to avoid wasting time. I've wasted many hours of work on this.

Imagine a new user downloading 7.4 trying partial exists and finding it fails. What do you expect that person to think and do? Most would walk away and possibly even discourage others from trying MC. This is not what we need. We wish MC all the success possible.

Sorry, but that's how it is. I hope something is done to improve the situation otherwise the more this sort of thing happens the worse it will get for MC's future. I hope lessons have been learnt and not ignored. A lot of us high power users of MC try our best to support and provide suggestions for significant improvement to the success of MC. Please don't ignore us on this one, not just for our sakes but for yours as well.

Update: I just realised as I was installing the "hot fix" for the partial exit problem, the package is actually a full release, version 7.4 build 5032. So why isn't it placed at the download site for new users to trial instead of leaving 7.4 build 4953 with a critical bug? This is insane!
These users thanked the author janus for the post:
TJ

User avatar
JoshM
Posts: 2084
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1525 times
Been thanked: 1483 times
Contact:

Re: execution of limit orders creating problems

Postby JoshM » 03 Apr 2012

janus wrote:Surely at a minimum the download section should list all available hot fixes with descriptions so users can apply them at their own discretion where necessary.

This is a very good idea: it will provide us with an open and transparent way of getting the hot fixes, and it prevents the 'bad impression' users might get when an internal bug list is communicated without fixes.

Please consider implementing such a download section, because this could have saved all of us (MC users & MC support) a lot of time, frustration and disappointment.

janus wrote:It's ludicrous to expect users to discover such fixes the way I did when there's a fix already available to avoid wasting time. I've wasted many hours of work on this.

Totally agree. It's quite a disappointment that this knowledge is already known to MC Support while the users have to reinvent the wheel.

janus wrote:Imagine a new user downloading 7.4 trying partial exists and finding it fails. What do you expect that person to think and do? Most would walk away and possibly even discourage others from trying MC. This is not what we need. We wish MC all the success possible.

Sorry, but that's how it is. I hope something is done to improve the situation otherwise the more this sort of thing happens the worse it will get for MC's future. I hope lessons have been learnt and not ignored. A lot of us high power users of MC try our best to support and provide suggestions for significant improvement to the success of MC. Please don't ignore us on this one, not just for our sakes but for yours as well.

Agreed. This forum and the Project Management already shows that MC has build a loyal group of customers already eager to offer suggestions to make it even better. And this thread, while critical, is also meant to provide suggestions to make MC even better.

janus wrote:Update: I just realised as I was installing the "hot fix" for the partial exit problem, the package is actually a full release, version 7.4 build 5032. So why isn't it placed at the download site for new users to trial instead of leaving 7.4 build 4953 with a critical bug? This is insane!

I also find this disappointing, also because the release of the build 4953 (to replace build 4906) was communicated through the blog (see here). That difference of that new build was:

The only change from the 4906 build that was the official release is that we added IWBank broker and datafeed.


It's nice that new features are being added, but why wasn't the far more important build 5032 not released and communicated through the blog?

With all respect to the Italian IWBank broker, but I assume the overwhelming majority of the MC users couldn't care less about this broker, and would much rather be given the opportunity to download a new build that fixes multiple / a bug(s) than a build that adds a new broker.

I'm not doubting the commitment of MC to fix bugs (I have no complaints about that), but the communication about bugs and the release of builds that fixes bugs should be given a higher priority in my view than the current priority. :)
These users thanked the author JoshM for the post:
TJ


Return to “MultiCharts”