Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Get current time frame from chart

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

    Get current time frame from chart

    Dear friends.
    How can I get information about current time frame from the chart and convert this value into string? Because I need to read some special information from files for each times frames, and users can choose time frame on the chart.

    #2
    Hi daglas,

    You can use BarsPeriod.Id and BarsPeriod.Value for this.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by daglas View Post
      Dear friends.
      How can I get information about current time frame from the chart and convert this value into string? Because I need to read some special information from files for each times frames, and users can choose time frame on the chart.

      Comment


        #4
        public string TF_TO_STR_PARSER(BarsPeriodType _tf_type, int _tf_magnitude)
        {
        /*

        BarsPeriodType.Second --- 3
        BarsPeriodType.Minute --- 4
        BarsPeriodType.Day --- 5
        BarsPeriodType.Week --- 6
        BarsPeriodType.Month --- 7
        BarsPeriodType.Year --- 8
        */
        string tf_str = "";
        if(_tf_type == BarsPeriodType.Tick)
        {
        tf_str = "TICK";
        }
        else if(_tf_type == BarsPeriodType.Second)
        {
        tf_str = "SEC";
        }
        else if(_tf_type == BarsPeriodType.Minute)
        {
        tf_str = "MIN";
        }
        else if(_tf_type == BarsPeriodType.Day)
        {
        tf_str = "DAY";
        }
        else if(_tf_type == BarsPeriodType.Week)
        {
        tf_str = "WEEK";
        }
        else if(_tf_type == BarsPeriodType.Month)
        {
        tf_str = "MONTH";
        }
        else if(_tf_type == BarsPeriodType.Year)
        {
        tf_str = "YEAR";
        }
        else
        {
        tf_str = "ERR";
        }
        return _tf_magnitude.ToString() + " " + tf_str;
        }​

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        547 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        323 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        99 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        543 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        545 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X