![]() |
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
|
|||||||
| Indicator Development Support for the development of custom indicators using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: May 2006
Location: Madison
Posts: 234
Thanks: 1
Thanked 2 times in 2 posts
|
The Historical keyword does not seem to work correctly in Replay mode. It returns true for all bars. I would expect it to work as if you were in live mode, and be set to true for all but the last bar. What is the best way to tell if you are running on the last bar in all modes? Also, from an indicator, how can you tell if Replay is running?
|
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
|
aslane,
Yes, "Historical" only is true when real-time data is being received. Unfortunately there is no supported way to check if replay is running. You could however setup some override flag that you set manually which tells the strategy you are in replay.
Adam P.
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: May 2006
Location: Madison
Posts: 234
Thanks: 1
Thanked 2 times in 2 posts
|
Ok, then please chalk that up to bug to be fixed in next rev, and feature to add in next rev, and let me know what the tracking numbers are.
|
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
|
aslane,
This is unsupported, but you could try something like this – that’s in our Bartimer indicator. Code:
private DateTime Now
{
get
{
DateTime now = (Bars.MarketData.Connection.Options.Provider == Cbi.Provider.Replay ? Bars.MarketData.Connection.Now : DateTime.Now);
if (now.Millisecond > 0)
now = Cbi.Globals.MinDate.AddSeconds((long) System.Math.Floor(now.Subtract(Cbi.Globals.MinDate).TotalSeconds));
return now;
}
}
Code:
Bars.MarketData.Connection.Options.Provider == Cbi.Provider.Replay
Adam P.
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: May 2006
Location: Madison
Posts: 234
Thanks: 1
Thanked 2 times in 2 posts
|
While unsupported, this is good in the short term.
|
|
|
|
|
|
#6 | |
|
Senior Member
Join Date: Aug 2010
Location: Washington, D.C.
Posts: 1,184
Thanks: 178
Thanked 301 times in 259 posts
|
I'm lost on this one.
I've used: Code:
protected override void OnBarUpdate()
{
if (Historical) return;
....
}
What am I not understanding about this post? NT 7.0.1000.8... 32 bit.Edit: I'm referring my usage for Strategies. Not indicators. Maybe that is the difference you speak of Quote:
|
|
|
|
|
|
|
#7 |
|
Senior Member
Join Date: Sep 2008
Posts: 543
Thanks: 80
Thanked 187 times in 131 posts
|
|
|
|
|
|
|
#8 |
|
Senior Member
Join Date: May 2006
Location: Madison
Posts: 234
Thanks: 1
Thanked 2 times in 2 posts
|
I have written a simple test for Historical, and it does seem to work in a trivial indi in replay mode. Unfortunately, it does not always work in complex code. I must be doing something to cause the issue, but I find it strange that I could cause the issue from my side of the fence. I'll try to isolate more.
|
|
|
|
|
|
#9 | |
|
Senior Member
Join Date: Aug 2010
Location: Washington, D.C.
Posts: 1,184
Thanks: 178
Thanked 301 times in 259 posts
|
Quote:
I am out of guesses without seeing some code that isolates and is reproduceable. |
|
|
|
|
|
|
#10 |
|
Senior Member
Join Date: Aug 2009
Posts: 153
Thanks: 11
Thanked 5 times in 4 posts
|
I found that the property "Historical" is not correctly passed to a referenced indicator in Market Replay. See this thread:
http://www.ninjatrader.com/support/f...ad.php?t=43635 Unfortunately I'm not sure if this issue is on any bug list to be fixed since I didn't ask for a tracking number. |
|
|
|
|
|
#11 |
|
Member
Join Date: Feb 2011
Location: Georgia, USA
Posts: 32
Thanks: 17
Thanked 15 times in 9 posts
|
Please take a look at my post in this older thread and provide your comments about it as a possible solution. I have a similar need. Do you think it is viable? It's certainly not optimal, but can you think of any reason why it would fail?
Thanks. Scott
Scott Daggett
NinjaLaunchPad.com NinjaScript Programmer's Launch Pad Tutorial ebook at ninjalaunchpad.com |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Many bugs in Market Replay mode | andrius | Miscellaneous Support | 2 | 01-06-2011 05:00 AM |
| Data will not load in replay mode | ladytrader | Miscellaneous Support | 10 | 09-25-2010 02:44 PM |
| Forex replay mode changes 1 to 0.1M.. | newbouldm | Miscellaneous Support | 3 | 05-11-2010 08:52 AM |
| ExitOnClose not executing in Replay mode | sharpie | Strategy Development | 2 | 08-19-2009 06:47 AM |
| Charts in replay mode | ladytrader | Miscellaneous Support | 4 | 11-15-2008 04:14 PM |