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 > Application Technical Support > Miscellaneous Support

Miscellaneous Support Miscellaneous support issues.

Reply
 
Thread Tools Display Modes
Old 10-01-2009, 02:41 AM   #1
dave1992
Senior Member
 
Join Date: Nov 2008
Location: UK
Posts: 637
Thanks: 0
Thanked 1 time in 1 post
Default Detecting the last tick of the day

Hi,

I'm sure there'll be something about this in the forums already, but I didn't find it (searching on end, day, bar etc is difficult)

I have a one minute strategy, calculating on bar close only. I have an instrument (Z) with end of day at 9pm, UK time.

The problem is that the strategy runs constantly, but I need somehow, within a reasonable amount of time, to detect the last tick of the day and do something in the strategy. Currently, the strategy will not call onbarupdate until the first tick of the next bar, which is 8am the following day.

Does anyone have any workarounds or solutions for this issue?

One thing that occured to me was to add another bar series for daily timeframe. At least then I could get the strategy to execute some code.

Related to this, could I have some info about how calling update() works? Can you set the barsinprogress for the call? If so, could I call update from the daily onbarsupdate and set barsinprogress to the minute bars series?

Lastly, I want to try and come up with a solution that doesn't require setting calculateonbarclose to false!

thanks for any ideas
Dave
dave1992 is offline  
Reply With Quote
Old 10-01-2009, 06:03 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
Default

Dave, the Update() would only be used to ensure certain internal indicator calculations are updated prior to the OnBarUpdate() call.

In your situation I would suggest using a time filter to do your end of day calculations, would that work for you?

http://www.ninjatrader-support2.com/...ead.php?t=3226
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 10-01-2009, 06:11 AM   #3
dave1992
Senior Member
 
Join Date: Nov 2008
Location: UK
Posts: 637
Thanks: 0
Thanked 1 time in 1 post
Default

Thanks for the reply. So Update() doesn't really call OnBarUpdate() ?

By time filter, do mean take all ticks in and reject all those not with a particular time? If so, that doesn't really work for me, as I really want to avoid having OnBarUpdate() fire for every tick of the day.
dave1992 is offline  
Reply With Quote
Old 10-01-2009, 07:29 AM   #4
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
Default

You would force an OnBarUpdate() call of the indicator with this, but you can't force a new bar to be started, this is event based, so the tick of the new bar has to come in to close the old one.

With time filter I just meant to process your 'last tick of the day logic' very close to the expected closing of the Z market (for example at 20:59:30).
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 10-01-2009, 07:33 AM   #5
dave1992
Senior Member
 
Join Date: Nov 2008
Location: UK
Posts: 637
Thanks: 0
Thanked 1 time in 1 post
Default

I don't really see how that works, since there will be no code executed at 20:59:30 since there will be no onbarupdate until 8am. Unless you mean take in all ticks, but I've already covered that.

thanks
Dave
dave1992 is offline  
Reply With Quote
Old 10-01-2009, 07:37 AM   #6
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
Default

You could add a finer granularity to achieve this, for example a 30 second chart.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 10-01-2009, 07:48 AM   #7
dave1992
Senior Member
 
Join Date: Nov 2008
Location: UK
Posts: 637
Thanks: 0
Thanked 1 time in 1 post
Default

But I'd still miss the last 30 secs worth of ticks, meaning closing price and volume would be incorrect. And I'd get twice as many updates, and I don't want more than 1min ones.
dave1992 is offline  
Reply With Quote
Old 10-01-2009, 07:54 AM   #8
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
Default

This depends on in which context you run your main code, the added 30 sec chart would just give you access to lower then 1min timestamps.
NinjaTrader_Bertrand 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
Detecting live or non live mode (replay/back testing) BillCh General Programming 2 06-18-2009 07:43 AM
Detecting a Posting Exit netjms Strategy Development 1 05-07-2009 08:12 AM
Detecting double entry... ninjaq Strategy Development 1 04-06-2009 04:33 PM
detecting backtest or real time simulation dave1992 Strategy Analyzer 9 11-22-2008 06:09 AM
How to call an ATM when detecting signals ? jed77 Strategy Development 2 03-28-2008 01:23 AM


All times are GMT -6. The time now is 03:56 AM.