![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Jan 2009
Location: Melbourne
Posts: 178
Thanks: 3
Thanked 0 times in 0 posts
|
NT Team,
I've noticed critical differences in the behavior of a custom indicator between real-time and historical data. To prove I wasn't going crazy I took chart screenshots of the indicator at the end of a realtime trading day and compared them against the chart created one trading day hence (once the trading day historical data). As stated in the NT7 Help Guide the Market Replay Connection provides "market data to all NinjaTrader windows as if it was happening in real-time". I was hoping this facility would help me debug the custom indicator, replicating the indicator output as if it was real-time. However, this is not the case. The Market Reply Connection chart presents as if it were entirely calculated on historical data. Is my understanding of the Market Replay Connection incorrect? Any pearls of wisdom on how I might debug this indicator, outside of composing the indicator to write extensively to the Output window and then comparing the realtime and historical outputs of trading days as time rolls forwards? As always, any insight would be appreciated. Regards Shannon |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,414
Thanks: 252
Thanked 978 times in 961 posts
|
Hi Shannon, did you actually run the indicator calcs in Market Replay going the day forward through the recorded / downloaded dataset or did you calculated the indicator values simply on the historical chart data being connected to Market Replay? This would be a critical difference here.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Jan 2009
Location: Melbourne
Posts: 178
Thanks: 3
Thanked 0 times in 0 posts
|
Bertrand,
Thanks for the reply. I'm not quite sure I understand. The sequence I followed: 1. Load the Workspace containing the 15min chart in question (the chart contains the the offending indicator) 2. Connect to Market Replay Connection 3. Set the start (aka "From") date in the Market Replay Connection window (the End date in the chart data series window is then greyed out to the day immediately prior to the Market Replay Connection start date. 4. Start the Market Replay (and speed up considerably). The chart in question begins to move through time. 5. The indicator calculates like it is based on historical data (where I expect it calculate like it was based on real-time data). As noted previously the indicator behaves differently in real-time vs historical. I am unsure how this process fits into your explanation. Any guidance would be appreciated. Interestingly, in the custom indicator script there is no if(Historical) or similar. I can not think of why it behaves differently. The custom indictor does use if(FirstTickOfBar) but that's about it from an execution perspective. Thanks again Shannon |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,414
Thanks: 252
Thanked 978 times in 961 posts
|
Thanks Shannon, that would be right process wise - I just thought you loaded it on a historical chart being connected to Market Replay but without actually replaying the day at all, so this is out of the way as potential reason for the discrepancies seen here. Are you relying on any logic that would need the realtime pc clock .ticks for subsecond timestamp access? Does it matter at which speed the day is replayed?
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Jan 2009
Posts: 584
Thanks: 2
Thanked 21 times in 12 posts
|
you should read well Bertrands comments.
If your indicator uses some sort of realtime clock (DateTime.Now) then in MarketReplay it will behave differently. @Bertrand: You could expose a ReplayWindow.Now function or similar. Currently I have to read the replay windows title bar to get this information (But it is a slow method) regards Andreas |
|
|
|
|
|
#6 |
|
Senior Member
Join Date: Jan 2009
Location: Melbourne
Posts: 178
Thanks: 3
Thanked 0 times in 0 posts
|
Bertrand & zweistein,
The strategy in question is designed to execute in the last three seconds of each bar (in this case the last three seconds of a 15min ES bar). This is effected via the code: Code:
TimeSpan barTimeLeft = Bars.Get(Bars.Count - 1).Time.Subtract(DateTime.Now); if (!(Historical) && !(barTimeLeft.Minutes <= 0 && barTimeLeft.Seconds < 3)) return; However, the strategy accesses a particular indicator where this anomaly has presented. The indictor which is directly applied to the chart in question on the same input panel as the input series calculates OnBarUpdate. Historical bars and realtime bars are calculated OnBarUpdate, no PC clock reference is made. However, a Time[0] reference (time stamp values) is made to differentiate NYSE cash market hours from night market hours. I expect the strategy (which references PC clock) to be different in Market Replay than realtime. However, I expected the indicator (no PC clock reference) to be the identical in a Market Replay environment. Where is my understanding wrong? Thanks again Shannon |
|
|
|
|
|
#7 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,414
Thanks: 252
Thanked 978 times in 961 posts
|
Shannon, sorry I'm not following you 100% here : is the indicator giving you issues in Market Replay when called from the strategy using the irrelevant PC clock reference or not? If not, then we would need to know what the indicator calcs are doing in order to better understand why you would see discrepancies here in Market Replay vs Realtime.
Bertrand
NinjaTrader Customer Service |
|
|
|
![]() |
| Tags |
| historical data, market replay connection, real-time |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Market Replay Connection | ScottB | Strategy Development | 8 | 05-26-2011 12:42 PM |
| Market Replay Connection | shiva_mohan | Connecting | 1 | 04-25-2011 12:28 PM |
| Market Replay Connection | jefsms1 | Miscellaneous Support | 3 | 04-19-2010 03:31 AM |
| Market replay connection in 6.5 | nicknamed | Miscellaneous Support | 1 | 12-08-2009 10:37 AM |
| Market Replay Connection | chonwayne | Connecting | 10 | 01-14-2009 02:01 PM |