![]() |
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Nov 2005
Location: , Ontario, Canada
Posts: 400
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#2 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Print(BarsPeriod.Id.ToString());
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Nov 2005
Location: , Ontario, Canada
Posts: 400
Thanks: 0
Thanked 0 times in 0 posts
|
Thanks Ray
Unfortunately, that returns a "BarsPeriod does not exist in the current context" error. NT 6.5 B4 |
|
|
|
|
|
#4 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
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)
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Nov 2005
Location: , Ontario, Canada
Posts: 400
Thanks: 0
Thanked 0 times in 0 posts
|
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 " |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |