NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 12-05-2007, 08:54 PM   #1
zoltran
Senior Member
 
Join Date: Nov 2005
Location: , Ontario, Canada
Posts: 400
Thanks: 0
Thanked 0 times in 0 posts
Default String form of Period Type

I'd like to form a string with the current period type and interval
Such as 'YM 1207 Volume 500'

I can get the interval with BarsPeriod.Value
What's the best way to get the Period type . in a form that can be printed?

tia
zoltran is offline  
Reply With Quote
Old 12-05-2007, 09:03 PM   #2
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

Print(BarsPeriod.Id.ToString());
NinjaTrader_Ray is offline  
Reply With Quote
Old 12-05-2007, 10:18 PM   #3
zoltran
Senior Member
 
Join Date: Nov 2005
Location: , Ontario, Canada
Posts: 400
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks Ray
Unfortunately, that returns a "BarsPeriod does not exist in the current context" error.

NT 6.5 B4
zoltran is offline  
Reply With Quote
Old 12-05-2007, 10:26 PM   #4
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Default

It's always to a good idea to mention the context in which you are raising your question:
- strategy: Rays' post applies
- indicator: try Bars.Period.Id (does not work in Initialize)
NinjaTrader_Dierk is offline  
Reply With Quote
Old 12-05-2007, 10:40 PM   #5
zoltran
Senior Member
 
Join Date: Nov 2005
Location: , Ontario, Canada
Posts: 400
Thanks: 0
Thanked 0 times in 0 posts
Default

Arg.. My apologies. I will do that in the future.

For others, here is the complete code to form the string "Instrument Type Period"

This is very useful in alerts, where you have an alerting indicator applied to different charts.

string iname = Instrument.FullName+ " " + Bars.Period.Id.ToString() + " " + Bars.Period.Value.ToString() ;

Produces output like this -> " YM 12-07 Range 10 "
zoltran 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
Using windows Form instead of file io Folls Strategy Development 49 11-08-2011 08:38 AM
Period 14 crossing Period Linear Regression 25 Viper3 Strategy Development 8 10-21-2007 10:51 AM
Formatting string number MAX General Programming 6 10-13-2007 11:20 AM
How to increment string? Richard Von Indicator Development 1 07-30-2007 07:16 AM
Cannot convert method group 'ToString' to non-delegate type 'string'. Did you intend MindSabre General Programming 2 07-11-2007 07:13 AM


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