Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Bug: OnBarUpdate processing historical bars with State.Realtime
Collapse
X
-
Synchronization errors with minimized charts
I have now modified the indicators to work with historical bars which carry the state "realtime" and also used separate session iterators for OnBarUpdate() and OnRender(). While this fixes some of the errors, there are a lot of other problems that I cannot fix. I can only guess what is happening.
These are the steps one by one:
(1) Add an indicator to a chart, while being disconnected.
Everything works as expected.
(2) Minimize the chart.
With the introduction of chart tabs, lots of NinjaTrader 8 users now have minimized charts. For NinjaTrader 7 users this was rare. The charts on all non-active charts behave in the same way as minimized charts.
(3) Connect to a data feed.
For the minimized chart OnStateChange() will be called. I have checked that it runs through the states State.Configure, State.DataLoaded and State.Historical. However, OnBarUpdate() is not called.
(4) Reopen the minimized chart.
This is now where lots of synchronization errors happen:
-> OnRender() is being executed and terminated before OnBarUpdate() has been completed (I have checked this via the condition Values[0].IsValidDataPointAt(lastBarIndex) which often returns "false" showing that OnRender cannot access the plot values).
-> The completion of OnBarUpdate() takes longer for multi-timeframe indicators as the secondary bars need to be loaded.
-> Depending on the indicator all or some plots will not be shown.
-> Also there is the problem that all the historical bars are handled by OnBarUpdate() as realtime bars.
-> Only the first real-time tick which is detected after the chart has been opened the indicators will display correctly again.
Charts on other tabs and minimized charts are currently a mess.
Would somebody please confirm my findings?
Comment
-
Hello Harry,
I've tested for the behavior and I am able to reproduce the behavior where the State is Realtime while historical data is being processed when the chart is restored after disconnecting and reconnecting.
I have reported this behavior and once I have a tracking ID I will post this in this thread.
However, I was not able to reproduce an issue with the SessionIterator.
Free online storage and sharing with Screencast.com. 2 GB of storage and 2 GB of bandwidth per month for free. We won't compress, alter or take ownership of your content.
May I confirm I have taken the correct steps to test?Attached FilesChelsea B.NinjaTrader Customer Service
Comment
-
Hello Chelsea,
Thank you for your quick response.
I have tested your little indicator and it is easy to replicate both errors.
In OnBarUpdate() it definitely calculates a false session for the first bar. The input time is June 5 2017, 00:15, for which the ActualSessionBegin is calculated as August 7 2017 00:00. This is the bug!
I have attached a screenshot below from the output file generated by your indicator.
Comment
-
I have checked your video again. You performed the test in a slightly different fashion. Please try again:
(1) Add an indicator to a chart, while being disconnected.
You were connected when you added the indicator. Please disconnect prior to starting the test.
-> add the indicator when disconnected
-> alternatively refresh the chart via F5 when being disconnected
(2) Minimize the chart, while being disconnected.
-> must be done when disconnected
(3) Connect to a data feed.
Please wait for 15-30 seconds after connecting. It is important that data loading was completed and that OnStateChange() has been executed prior to reopening the minimized chart.
(4) Reopen the minimized chart.
You should now see the false session begin after "OBU".
Comment
-
Hello Harry,
What was the value ActualSessionBegin returned without minimizing the chart when it displayed Historical?
Did this change?
Is the issue with minimizing the chart or is the issue with ActualSessionBegin and unrelated to minimizing the chart?
(I ask because in the video I have created, the value appears to remain the same before and after the chart is minimized)Chelsea B.NinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_ChelseaB View PostHello Harry,
What was the value ActualSessionBegin returned without minimizing the chart when it displayed Historical?
Did this change?
Is the issue with minimizing the chart or is the issue with ActualSessionBegin and unrelated to minimizing the chart?
(I ask because in the video I have created, the value appears to remain the same before and after the chart is minimized)
A customer of mine opens a workspace. Then connects to a datafeed. In his workspaces he has different charts that he likes to access with tabs. Tabs are basically the same as the minimized charts.
When he opens these charts the indicators are not working, because the historical bars are treated as realtime bars, and because the session iterator returns false values.
Please do the test the way I have described it, and the session iterator bug will appear. Usually the indicators work as expected and there is no problem with the session iterators. The session iterator problem comes up, when the chart is minimized when disconnected.Last edited by Harry; 08-08-2017, 01:44 AM.
Comment
-
Chelsea,
The false session begin only appears after the chart has been minimized (when disconnected) and after reconnecting and then reopening the chart.
Could you reproduce the session iterator problem with the test indicator that you have coded?
The problem shows well with your indicator.Last edited by Harry; 08-08-2017, 01:43 AM.
Comment
-
Comment
-
Originally posted by NinjaTrader_ChelseaB View Post
Your video does not even show the result for the session iterator in OnBarUpdate(). That would be the line marked with "OBU". This is the one that is not correctly calculated.
The video only shows the results for the session iterator in OnRender(), which are marked with "OR".
You need to look at the false calculation done by the session iterator in OnBarUpdate().
Comment
-
Hello Harry,
You mentioned that the value is wrong after OnBarUpdate so I was showing the most recent value from OnRender which comes after OnBarUpdate.
However, I have created a new video to scroll up and show the exact same value printed in OnBarUpdate instead of after it.
Chelsea B.NinjaTrader Customer Service
Comment
-
Hello Chelsea,
Here is my video. Basically I have done the same thing as you, but in the end I have scrolled up the output window and you will notice that it reads
05.06.2017 00:15:00 | State: Realtime
OR | sessionIterator ActualSessionBegin: 08.08.2017 00:00:00
which shows that the session iterator calculates August 8 as the session begin for the first bar. The first bar has a time stamp of June 5, 00:15. This shows that the session iterator does not work here.
Here is the link to the video:
Free online storage and sharing with Screencast.com. 2 GB of storage and 2 GB of bandwidth per month for free. We won't compress, alter or take ownership of your content.
The flawed result appears in the end.
The session iterator will calculate correctly under normal conditions, but it does not work when the chart is minimized and when it is used in OnRender() as well.Last edited by Harry; 08-08-2017, 09:12 AM.
Comment
-
Hello Harry,
The session begin time does not appear to change in your video.
It is showing 08.08.2017 00:00:00 before the chart is minimized when the State is showing Historical.
Are you certain you are wanting to report that the session iterator is showing the wrong time because the chart was minimized?Chelsea B.NinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_ChelseaB View PostHello Harry,
You mentioned that the value is wrong after OnBarUpdate so I was showing the most recent value from OnRender which comes after OnBarUpdate.
However, I have created a new video to scroll up and show the exact same value printed in OnBarUpdate instead of after it.
https://www.screencast.com/t/npgDO06NCgI
Hi Chelsea,
In the code for your test indicator, you calculate the session begin for the bar #1 by applying the session iterator.
The time stamp for this bar is August 2, 2017 6:02 PM.
The ActualSessionBegin calculated from that bar is August 8 6:00 PM.
This is totally false and is clearly shown on your video.
When you calculate the ActualSessionBegin for the bar #1 with the time stamp August 2, 2017 6:02 PM, the correct session begin would be August 2, 2017 6:00 PM and not August 8, 2017, 6:00PM.
Although you have called the session iterator in OnBarUpdate(), it takes the value from the session iterator when called in OnRender(), which it should not.
Comment
-
Here is your code:
Code:Print(string.Format("{0} | State: {1}", Time[0], State)); if (CurrentBar == 1) { sessionIterator.CalculateTradingDay(Time[0], true); Print(string.Format("OBU | sessionIterator ActualSessionBegin: {0}", sessionIterator.ActualSessionBegin)); }
Actually, the session iterator returns the same session for all bars on the chart. This is dead wrong.
The problem here is that it is being called in parallel from OBU and OR and there is some sort of interference which leads to false results.
This interference only is there when charts are minimized. Minimizing charts causes a general disorder as OnStateChange, OnRender and OnBarUpdate are not being called in the proper order.
Even with workarounds for the real-time trap and the session iterator trap my indicators do not work correctly when the chart was minimized because some of the plots have not been loaded before OnRender() is being executed.
It is a general mess and I want to report it.Last edited by Harry; 08-08-2017, 09:30 AM.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by hazylizard, Today, 08:38 AM
|
1 response
7 views
0 likes
|
Last Post Today, 08:53 AM | ||
Started by geddyisodin, Today, 05:20 AM
|
2 responses
16 views
0 likes
|
Last Post
by geddyisodin
Today, 08:44 AM
|
||
Started by Max238, Today, 01:28 AM
|
5 responses
43 views
0 likes
|
Last Post
by Max238
Today, 08:30 AM
|
||
Started by giulyko00, Yesterday, 12:03 PM
|
3 responses
13 views
0 likes
|
Last Post Today, 08:26 AM | ||
Started by habeebft, Today, 07:27 AM
|
1 response
16 views
0 likes
|
Last Post Today, 08:08 AM |
Comment