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 02-22-2012, 12:52 PM   #1
Zapzap
Member
 
Join Date: Aug 2008
Posts: 81
Thanks: 3
Thanked 10 times in 7 posts
Default Time of bar open and close

Is there a way to get the open and close time of a tick-chart bar?

I would like to make a small indicator that shows how much time was needed for eg. a 200 tick bar to get created.
Zapzap is offline  
Reply With Quote
Old 02-22-2012, 01:00 PM   #2
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 553 times in 545 posts
Default

Hello Zapzap,
Thanks for writing in and I am happy to assist you.

Unlike minute based bars where the end time can be predetermined, the end time of the tick bars cannot be predetermined. As such you cannot make an indicator which determines the end time of a tick bar.

I look forward to assist you further.
NinjaTrader_Joydeep is offline  
Reply With Quote
Old 02-22-2012, 01:18 PM   #3
koganam
Senior Member
 
Join Date: Feb 2008
Location: http://omegasigmaindicators.com
Posts: 4,774
Thanks: 31
Thanked 1,977 times in 1,616 posts
Send a message via Skype™ to koganam
Default

Quote:
Originally Posted by Zapzap View Post
Is there a way to get the open and close time of a tick-chart bar?

I would like to make a small indicator that shows how much time was needed for eg. a 200 tick bar to get created.
The time taken to build the last bar is:
Code:
TimeSpan timeElapsed = Time[2] - Time[1];
regardless of the type of bar you are using. If you want that in seconds, you will have to cast it correctly, thus
Code:
timeElapsed.TotalSeconds
By the same token, the time that has elapsed since the last bar, provided you have COBC = false, is Time[0] - Time[1].

That having been said, you sound like you are reinventing the wheel: NT ships with an indicator called BarTimer that does what you want.
Last edited by koganam; 02-22-2012 at 01:22 PM.
koganam is offline  
Reply With Quote
The following 3 users say thank you to koganam for this post:
Old 02-22-2012, 01:38 PM   #4
Zapzap
Member
 
Join Date: Aug 2008
Posts: 81
Thanks: 3
Thanked 10 times in 7 posts
Default

Joydeep: I don't want to predetermine anything. I'd like to know "how much time was needed for a bar"

koganam: Thanks a lot I knew it was easy, I haven't programmed NT for 3 years though.

BTW: BarTimer is an indicator for minute based charts showing how much time is left. So I needed the new wheels.
Last edited by Zapzap; 02-22-2012 at 01:42 PM.
Zapzap is offline  
Reply With Quote
Old 02-22-2012, 02:58 PM   #5
koganam
Senior Member
 
Join Date: Feb 2008
Location: http://omegasigmaindicators.com
Posts: 4,774
Thanks: 31
Thanked 1,977 times in 1,616 posts
Send a message via Skype™ to koganam
Default

Quote:
Originally Posted by Zapzap View Post
...BTW: BarTimer is an indicator for minute based charts showing how much time is left. So I needed the new wheels.
Drat! Now why did I think that it was the other way round, and would only work on non-fixed timeframe charts? I must be going bonkers.
koganam 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
Calculate On Bar Close/Open-Low-High-Close relationship jkmott59 Indicator Development 6 04-10-2012 10:47 AM
Current Bar Open Equals Previous Bar Close ramacan Charting 6 05-23-2009 11:07 AM
Backtest vs real-time Chart orders placed at Open of next bar vs Close of curr bar? tomace Strategy Analyzer 3 03-18-2009 07:06 AM
Open and Close from same Bar RJay Strategy Development 3 03-04-2009 05:25 PM
Does NT simulator place orders at the Close of current bar, or Open of next bar? tomace Strategy Development 1 03-02-2009 01:43 PM


All times are GMT -6. The time now is 05:59 AM.

FULL RISK DISCLOSURE: Futures trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing ones financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View Full Risk Disclosure.