Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

trading hours template change via code

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

    trading hours template change via code

    Hello,

    Is there any way to change trading hour template via code in indicator instead of going to data series and changing it there?

    Thanks,
    redduke

    #2
    I think I found the answer: https://ninjatrader.com/support/foru...t-to-indicator

    Comment


      #3
      Hello RedDuke,

      The linked post would be how you can make an input to select trading hours for a custom purpose but does not change the DataSeries value. At this time there is no way to affect the DataSeries menu options directly from code.


      I look forward to being of further assistance.

      Comment


        #4
        Jesse,

        Yep, I realized the same once I implemented it. Is there any unsupported way? It is just a very critical function I need.

        Thanks a lot

        Comment


          #5
          Hello RedDuke,

          Not that I am aware of, you can access the underlying bar information through the BarsArray objects however that does not provide any mechanism to control changing the chart.

          In this situation because the property is within the menu and is not just a chart option/button that can be toggled the ways to change that are fairly limited.

          We have a feature request for this type of option that I have added your vote to: SFT-4619





          I look forward to being of further assistance.

          Comment


            #6
            Originally posted by NinjaTrader_Jesse View Post
            Hello RedDuke,

            Not that I am aware of, you can access the underlying bar information through the BarsArray objects however that does not provide any mechanism to control changing the chart.

            In this situation because the property is within the menu and is not just a chart option/button that can be toggled the ways to change that are fairly limited.

            We have a feature request for this type of option that I have added your vote to: SFT-4619





            I look forward to being of further assistance.

            Thank you. How many votes so far?

            Comment


              #7
              Hello,

              Another question, but similar topic. Can chart template be switched via code, rather than right clicking on the chart and picking it from the list of saved templates?

              Thank you

              Comment


                #8
                Hello RedDuke,

                I am unaware of anyway to do that through code, that would be specifically a user interface option. In regard to the feature request unfortunately I cannot see how many votes however I did get your input added to the request.


                Please let me know if I may be of additional assistance.

                Comment


                  #9
                  Hello

                  I would like to ad an up vote to SFT-4619 also please.

                  Thanks

                  Comment


                    #10
                    RedDuke

                    While technically not changing the Template. You can actually reproduce the desired behaviour by code. By manually configuring the Bars.TradingHours.Sessions.

                    Using:
                    Bars.TradingHours.Sessions[0]
                    https://ninjatrader.com/support/help...eak_at_eod.htm

                    Example: (Indicator) Set chart from what ever template it currently is...
                    to "Default 24 x 5" Trading Hour Template would look like this:

                    Code:
                    protected override void OnStateChange() {
                    
                    if ( State == State.DataLoaded ) { // <- State Important, no earlier.
                    
                    Bars.TradingHours.Sessions[ 0 ].TradingDay = System.DayOfWeek.Monday;
                    Bars.TradingHours.Sessions[ 0 ].BeginDay = System.DayOfWeek.Monday;
                    Bars.TradingHours.Sessions[ 0 ].BeginTime = 0000;
                    Bars.TradingHours.Sessions[ 0 ].EndDay = System.DayOfWeek.Tuesday;
                    Bars.TradingHours.Sessions[ 0 ].EndTime = 0000;
                    
                    Bars.TradingHours.Sessions[ 1 ].TradingDay = System.DayOfWeek.Tuesday;
                    Bars.TradingHours.Sessions[ 1 ].BeginDay = System.DayOfWeek.Tuesday;
                    Bars.TradingHours.Sessions[ 1 ].BeginTime = 0000;
                    Bars.TradingHours.Sessions[ 1 ].EndDay = System.DayOfWeek.Wednesday;
                    Bars.TradingHours.Sessions[ 1 ].EndTime = 0000;
                    
                    Bars.TradingHours.Sessions[ 2 ].TradingDay = System.DayOfWeek.Wednesday;
                    Bars.TradingHours.Sessions[ 2 ].BeginDay = System.DayOfWeek.Wednesday;
                    Bars.TradingHours.Sessions[ 2 ].BeginTime = 0000;
                    Bars.TradingHours.Sessions[ 2 ].EndDay = System.DayOfWeek.Thursday;
                    Bars.TradingHours.Sessions[ 2 ].EndTime = 0000;
                    
                    Bars.TradingHours.Sessions[ 3 ].TradingDay = System.DayOfWeek.Thursday;
                    Bars.TradingHours.Sessions[ 3 ].BeginDay = System.DayOfWeek.Thursday;
                    Bars.TradingHours.Sessions[ 3 ].BeginTime = 0000;
                    Bars.TradingHours.Sessions[ 3 ].EndDay = System.DayOfWeek.Friday;
                    Bars.TradingHours.Sessions[ 3 ].EndTime = 0000;
                    
                    Bars.TradingHours.Sessions[ 4 ].TradingDay = System.DayOfWeek.Friday;
                    Bars.TradingHours.Sessions[ 4 ].BeginDay = System.DayOfWeek.Friday;
                    Bars.TradingHours.Sessions[ 4 ].BeginTime = 0000;
                    Bars.TradingHours.Sessions[ 4 ].EndDay = System.DayOfWeek.Saturday;
                    Bars.TradingHours.Sessions[ 4 ].EndTime = 0000;
                    
                    }
                    }
                    Last edited by SmartArtsStudio; 06-16-2021, 07:08 AM. Reason: Correcting EndDay Day names

                    Comment


                      #11
                      Thanks for the info. We did exactly that a while back

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      626 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      359 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      105 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      562 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      567 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X