NinjaTrader Support Forum  
X

Attention!

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


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 07-01-2012, 02:16 PM   #1
aslane
Senior Member
 
Join Date: May 2006
Location: Madison
Posts: 234
Thanks: 1
Thanked 2 times in 2 posts
Default Historical keyword in Replay mode

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?
aslane is offline  
Reply With Quote
Old 07-02-2012, 07:51 AM   #2
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
Default

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.
NinjaTrader_AdamP is offline  
Reply With Quote
Old 07-02-2012, 08:20 AM   #3
aslane
Senior Member
 
Join Date: May 2006
Location: Madison
Posts: 234
Thanks: 1
Thanked 2 times in 2 posts
Default

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.
aslane is offline  
Reply With Quote
Old 07-02-2012, 10:22 AM   #4
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
Default

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;
                  }
            }
Specifically look here :

Code:
Bars.MarketData.Connection.Options.Provider == Cbi.Provider.Replay
NinjaTrader_AdamP is offline  
Reply With Quote
Old 07-02-2012, 10:40 AM   #5
aslane
Senior Member
 
Join Date: May 2006
Location: Madison
Posts: 234
Thanks: 1
Thanked 2 times in 2 posts
Default

While unsupported, this is good in the short term.
aslane is offline  
Reply With Quote
Old 07-02-2012, 09:19 PM   #6
sledge
Senior Member
 
Join Date: Aug 2010
Location: Washington, D.C.
Posts: 1,184
Thanks: 178
Thanked 301 times in 259 posts
Default

I'm lost on this one.

I've used:

Code:
protected override void OnBarUpdate()
{

      if (Historical) return;
....
}
previous "trades" on the chart are ignored, and market replay works going forward, my code works, so therefore, it was false...

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:
Originally Posted by aslane View Post
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?
sledge is offline  
Reply With Quote
Old 07-02-2012, 09:54 PM   #7
Radical
Senior Member
 
Join Date: Sep 2008
Posts: 543
Thanks: 80
Thanked 187 times in 131 posts
Default

Quote:
Originally Posted by sledge View Post
I'm lost on this one. [...]
I'm with sledge, I've used 'if (Historical) {return;}' in both strategies and indicators in market replay, and I haven't run into any problems.
Radical is offline  
Reply With Quote
Old 07-02-2012, 11:00 PM   #8
aslane
Senior Member
 
Join Date: May 2006
Location: Madison
Posts: 234
Thanks: 1
Thanked 2 times in 2 posts
Default

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.
aslane is offline  
Reply With Quote
Old 07-03-2012, 05:15 AM   #9
sledge
Senior Member
 
Join Date: Aug 2010
Location: Washington, D.C.
Posts: 1,184
Thanks: 178
Thanked 301 times in 259 posts
Default

Quote:
Originally Posted by aslane View Post
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.
Would your "complex code" have anything to do with "short circuit evaluation"?

I am out of guesses without seeing some code that isolates and is reproduceable.
sledge is offline  
Reply With Quote
Old 09-22-2012, 05:07 AM   #10
poseidon_sthlm
Senior Member
 
Join Date: Aug 2009
Posts: 153
Thanks: 11
Thanked 5 times in 4 posts
Default

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.
poseidon_sthlm is offline  
Reply With Quote
Old 10-08-2012, 02:30 PM   #11
sh_daggett
Member
 
Join Date: Feb 2011
Location: Georgia, USA
Posts: 32
Thanks: 17
Thanked 15 times in 9 posts
Default

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
sh_daggett is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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


All times are GMT -6. The time now is 07:57 AM.