Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Accessing the currently used Instrument and Time frame

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Accessing the currently used Instrument and Time frame

    Hello,

    I know that this probably have been answered before, but I searched a lot and I didn't find any answers. So here's my question:

    When testing a strategy withing Strategy Analyzer, we first click on the desired instrument and then we'll set the time frame and then run the test. How can I access the name of instrument and the time frame that I'm currently testing from within my script?
    Last edited by arian_gh; 02-19-2015, 09:12 AM.

    #2
    Hello,

    Thank you for the question.

    While this is technically not supported here are the answers.

    For the Name you would need to get the full name from the instrument or the following:

    Code:
    Instrument.FullName
    There is also Instrument.Name but this does not get the contract for a futures so FullName will get the contract as well.


    For the chart type and time frame you can access the Bars information by doing the following:

    Code:
    Print(Bars.BarsType.Period.Value.ToString() + " " + Bars.BarsType.PeriodType.ToString());
    This would print 1 minute on a 1 minute chart.

    The period type can be used as such as well:

    Code:
    if(Bars.BarsType.PeriodType == PeriodType.Day) 
    {
    	//do something if day bars	
    }
    Please let me know if I may be of additional assistance.

    Comment


      #3
      Thank you so much for your help Jesse. Your reply fully answered my question.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      66 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      149 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      162 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      99 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      286 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Working...
      X