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 > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 10-04-2011, 11:29 AM   #1
Turtle Trader
Senior Member
 
Join Date: May 2009
Posts: 343
Thanks: 0
Thanked 0 times in 0 posts
Default Minute timer on Range or Tick Period?

Is it possible to have a timer that triggers every new clock minute on an instrument that is set up for Range or Tick Periods
Turtle Trader is offline  
Reply With Quote
Old 10-04-2011, 11:40 AM   #2
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Hi Turtle Trader,

Sure, maybe try something like:

DrawTextFixed("myText", (60 - DateTime.Now.Second).ToString(), TextPosition.BottomRight);
NinjaTrader_RyanM is offline  
Reply With Quote
Old 10-04-2011, 12:06 PM   #3
Turtle Trader
Senior Member
 
Join Date: May 2009
Posts: 343
Thanks: 0
Thanked 0 times in 0 posts
Default reply

Would that be dependent on CalculateOnBarClose = False??

In other words, the trigger of the timer would be dependent on the data feed in order to be triggered?

If yes, then is there another way that is not dependent on the data feed?
Turtle Trader is offline  
Reply With Quote
Old 10-04-2011, 12:34 PM   #4
Turtle Trader
Senior Member
 
Join Date: May 2009
Posts: 343
Thanks: 0
Thanked 0 times in 0 posts
Default reply

I think what I need is a timer object...

http://www.ninjatrader.com/support/f...ead.php?t=5965
Turtle Trader is offline  
Reply With Quote
Old 10-04-2011, 01:20 PM   #5
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Yes, timer object would be one aspect of it. And if you need to draw on chart at a different frequency than bar updates, will also have to override the Plot() method. We do not provide support for this but there is a sample available in all installations. Tools > Edit NinjaScript > Indicator > CustomPlotSample.
NinjaTrader_RyanM is offline  
Reply With Quote
Old 10-05-2011, 01:07 PM   #6
Turtle Trader
Senior Member
 
Join Date: May 2009
Posts: 343
Thanks: 0
Thanked 0 times in 0 posts
Default start on minute boundary

Hi Ryan,


OK, the pieces are coming together...now the last part...


I would like to start the timer exactly on a minute boundary, not on a bar event... so that it triggers exactly one minute later, and so on...


(remember that these are tick or range bars...it would be easy if it were a 1 minute chart..)



any suggestions?


Thanks
Turtle Trader is offline  
Reply With Quote
Old 10-05-2011, 01:16 PM   #7
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

My first reply offered this. Did you get a chance to apply it to a chart? It doesn't override plot so apply it to a liquid market and run with CalculateOnBarClose = false. DateTime.Now is your computer clock so not connected to bar updates.
Last edited by NinjaTrader_RyanM; 10-05-2011 at 01:51 PM.
NinjaTrader_RyanM is offline  
Reply With Quote
Old 10-05-2011, 05:14 PM   #8
Turtle Trader
Senior Member
 
Join Date: May 2009
Posts: 343
Thanks: 0
Thanked 0 times in 0 posts
Default reply

OK, yes I tried that....however, it only updates when there is a tick....after hours and even during the day some slow moving instruments may not have a tick in a minute.

I just tested this on CL (oil) around 7pm New York and it actually has dropped below a tick a minute at some times and the time didn't update when the clock turned over a minute.

DrawTextFixed("myText", (DateTime.Now.Minute).ToString(), TextPosition.BottomRight);

It might be OK to use it like this..." close enough", but I was hoping to set up the timer exactly on a minute boundary then just let it fire.
Turtle Trader is offline  
Reply With Quote
Old 10-06-2011, 08:16 AM   #9
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

It's not the value DateTime.Now.Second that needs to be changed here. It's that all the plotting and drawing logic is tied to OnBarUpdate. If you need to draw on chart at a different frequency than bar updates, you have to override plot method.
Last edited by NinjaTrader_RyanM; 10-06-2011 at 10:48 AM.
NinjaTrader_RyanM 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
Range chart bar timer jtradr Indicator Development 2 12-02-2010 03:41 PM
Minute Bars not updating w/ bar timer rangerdoc Version 7 Beta General Questions & Bug Reports 3 07-06-2010 10:41 AM
Range Bar Timer marker NinjaScript File Sharing Discussion 7 01-04-2010 06:23 AM
Timer for Constant Range Bars laocoon General Programming 6 11-02-2007 01:13 PM
Catch the end of a minute bar on a tick by tick OnBarUpdate event Fabrice Automated Trading 5 07-06-2007 12:28 PM


All times are GMT -6. The time now is 11:20 AM.