RecalcLastBarAfter and submitting orders  [SOLVED]

Questions about MultiCharts and user contributed studies.
janus
Posts: 765
Joined: 25 May 2009
Has thanked: 43 times
Been thanked: 88 times

RecalcLastBarAfter and submitting orders

Postby janus » 11 Jun 2013

Has anyone found a way to submit orders successfully when the study uses RecalcLastBarAfter(1) and barstatus = -1 (meaning there was no update tick but the study executes 1 second after the previous run)? At the moment the orders are ignored when barstatus = -1 (at least with version 8.0).

User avatar
TJ
Posts: 7235
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 991 times
Been thanked: 2058 times

Re: RecalcLastBarAfter and submitting orders

Postby TJ » 11 Jun 2013

Has anyone found a way to submit orders successfully when the study uses RecalcLastBarAfter(1) and barstatus = -1 (meaning there was no update tick but the study executes 1 second after the previous run)? At the moment the orders are ignored when barstatus = -1 (at least with version 8.0).
What is "barstatus = -1" ?
Why do you need it?

janus
Posts: 765
Joined: 25 May 2009
Has thanked: 43 times
Been thanked: 88 times

Re: RecalcLastBarAfter and submitting orders

Postby janus » 11 Jun 2013

Has anyone found a way to submit orders successfully when the study uses RecalcLastBarAfter(1) and barstatus = -1 (meaning there was no update tick but the study executes 1 second after the previous run)? At the moment the orders are ignored when barstatus = -1 (at least with version 8.0).
What is "barstatus = -1" ?
Why do you need it?
barstatus = -1 is when a study runs and the value of barstatus is -1. Usually it's 0, 1 or 2 for a normal update tick. As for the reason why I need it I thought it was obvious. I need to send orders at any time, not just when there is an update tick. Is that too much to ask? I would have thought any trading platform could do that.

User avatar
TJ
Posts: 7235
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 991 times
Been thanked: 2058 times

Re: RecalcLastBarAfter and submitting orders

Postby TJ » 11 Jun 2013

Has anyone found a way to submit orders successfully when the study uses RecalcLastBarAfter(1) and barstatus = -1 (meaning there was no update tick but the study executes 1 second after the previous run)? At the moment the orders are ignored when barstatus = -1 (at least with version 8.0).
What is "barstatus = -1" ?
Why do you need it?
barstatus = -1 is when a study runs and the value of barstatus is -1. Usually it's 0, 1 or 2 for a normal update tick. As for the reason why I need it I thought it was obvious. I need to send orders at any time, not just when there is an update tick. Is that too much to ask? I would have thought any trading platform could do that.
You get -1 only if there is an error while executing the reserved word.
Have you tried it without the -1?

janus
Posts: 765
Joined: 25 May 2009
Has thanked: 43 times
Been thanked: 88 times

Re: RecalcLastBarAfter and submitting orders

Postby janus » 11 Jun 2013

Don't you get barstatus = -1 with RecalcLastBarAfter(1) and the execution of the study was not the result of a real update tick but the timeout of RecalcLastBarAfter (1 second in this case)?

User avatar
TJ
Posts: 7235
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 991 times
Been thanked: 2058 times

Re: RecalcLastBarAfter and submitting orders

Postby TJ » 11 Jun 2013

Don't you get barstatus = -1 with RecalcLastBarAfter(1) and the execution of the study was not the result of a real update tick but the timeout of RecalcLastBarAfter (1 second in this case)?
-1 is an error code.
You might not get a new tick, but there is no error on barstatus.
You will get the latest status, most likely barstatus=1.

You can use PRINT to check out the return codes.

janus
Posts: 765
Joined: 25 May 2009
Has thanked: 43 times
Been thanked: 88 times

Re: RecalcLastBarAfter and submitting orders

Postby janus » 11 Jun 2013

I am already using print. How do you think I knew it was -1? What I have found out though is TWS is out of date despite running the update checker daily. I upgraded to the latest one (Build 938.1h, May 1, 2013) and it now works. I no longer get -1 for barstatus. That was odd since I could still manually place orders OK using Chart Trading or DOM Window, which is what I've been doing for so long now. Anyway, all fixed now. Odd too that the TWS updater wasn't working (on both computers). I should have suspected something was wrong there since it didn't tell me there was an update for TWS for a couple of months! I thought IB finally settled down to a stable version and stopped adding features to it. I was wrong on both accounts.

janus
Posts: 765
Joined: 25 May 2009
Has thanked: 43 times
Been thanked: 88 times

Re: RecalcLastBarAfter and submitting orders

Postby janus » 12 Jun 2013

Although the upgrade to the latest TWs has helped, I still get barstatus = -1 on some occasions with RecalcLastBarAfter(1). It appears to be intermittent and mostly happens during a quiet periods. When it does happen and I try to submit an order, it's ignored. So, my original problem remains. Oh well, that's one limitation to MC I hope one will be rectified. Otherwise, the full potential of using RecalcLastBarAfter in strategies will forever be lacking.

User avatar
Henry MultiСharts
Posts: 9136
Joined: 25 Aug 2011
Has thanked: 1260 times
Been thanked: 2929 times

Re: RecalcLastBarAfter and submitting orders

Postby Henry MultiСharts » 13 Jun 2013

Hello janus,

Do you have barstatus = -1 when the bar is still open or when the bar is already closed?
Do you use IOG for your signal?

janus
Posts: 765
Joined: 25 May 2009
Has thanked: 43 times
Been thanked: 88 times

Re: RecalcLastBarAfter and submitting orders

Postby janus » 13 Jun 2013

It's not when the bar is closed since I get a value of 2 when that happens. Yes, I use IOG. I think I know what's happening and I recall a long time ago we had this discussion before, I think. It happens when the market is very quiet, such that it extends over more than one or more bars. In other words, if an update tick is not received inside the period of one or more bars, thereafter barstatus will return -1 each time the study times out with RecalcLastBarAfter. It's normally not an issue since the markets are busy enough even for a 1-minute chart. However, there are times when the markets are very quiet for say a 1-minute chart to cause that to happen. The problem at hand is one can't place and order when that happens. One has to wait for a real update tick to arrive for an order to be submitted. For example, what if one wanted to submit an order to cover positions for whatever reason? It won't work in the situation above until an update tick arrives and barstatus returns back to normal (1 or 2). I consider that a serious limitation, albeit not a frequent one a trader would experience.

User avatar
Henry MultiСharts
Posts: 9136
Joined: 25 Aug 2011
Has thanked: 1260 times
Been thanked: 2929 times

Re: RecalcLastBarAfter and submitting orders

Postby Henry MultiСharts » 14 Jun 2013

Janus, I don't have barstatus=-1 when the bar is open and RecalcLastBarAfter is used in MultiCharts 8.7 beta 2. Please update your MultiCharts.

janus
Posts: 765
Joined: 25 May 2009
Has thanked: 43 times
Been thanked: 88 times

Re: RecalcLastBarAfter and submitting orders

Postby janus » 14 Jun 2013

Janus, I don't have barstatus=-1 when the bar is open and RecalcLastBarAfter is used in MultiCharts 8.7 beta 2. Please update your MultiCharts.
That's good news if "when the bar is open" is the same situation as the one I've described. What about 8.5? I'm still using 8.0 on my main PC but I have 8.5 on my test PC. I'll give it a try on 8.5 first. If the issue is still there I'll install 8.7 beta 2 on my test PC and try again.

User avatar
Henry MultiСharts
Posts: 9136
Joined: 25 Aug 2011
Has thanked: 1260 times
Been thanked: 2929 times

Re: RecalcLastBarAfter and submitting orders  [SOLVED]

Postby Henry MultiСharts » 09 Sep 2014

Since MultiCharts 9.0 Beta 1 autotrading orders can be sent if the barstatus value is -1.
In order to allow that you need to add the following attribute at the top of your code:

Code: Select all

[AllowSendOrdersAlways = true]

User avatar
JoshM
Posts: 2099
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1526 times
Been thanked: 1503 times
Contact:

Re: RecalcLastBarAfter and submitting orders

Postby JoshM » 13 Sep 2014

Since MultiCharts 9.0 Beta 1 autotrading orders can be sent if the barstatus value is -1.
In order to allow that you need to add the following attribute at the top of your code:

Code: Select all

[AllowSendOrdersAlways = true]
What is the MultiCharts .NET equivalent? The changelog for MC .NET 9.0 Beta 1 points to this topic, but it's not mentioned here (or I overlooked it).

User avatar
Henry MultiСharts
Posts: 9136
Joined: 25 Aug 2011
Has thanked: 1260 times
Been thanked: 2929 times

Re: RecalcLastBarAfter and submitting orders

Postby Henry MultiСharts » 15 Sep 2014

What is the MultiCharts .NET equivalent? The changelog for MC .NET 9.0 Beta 1 points to this topic, but it's not mentioned here (or I overlooked it).
It will be added in MultiCharts .NET 9.0 Release


Return to “MultiCharts”