Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Capture UI Setting

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

    Capture UI Setting

    Can I capture the UI setting in a Strategy for the Trading Hours? If so, how?

    I am attempting to AddSataSeries but only if the TRading Hours is ETH.

    This code will not work because the Bars Object is not available in State.Configure. So I though about capturing the Trading Selection to test for ETH.

    PHP Code:
                else if (State == State.Configure)
                {
                    if(Bars.TradingHours.Name.Contains(" ETH"))
                    {
                        //    tajBar == 159753
                        AddDataSeries(null, new BarsPeriod(){ BarsPeriodType  = (BarsPeriodType) 159753, Value  = BarsPeriod.Value, Value2 = BarsPeriod.Value2},"CME US Index Futures RTH", true);                
                    }
    
                }
    
                else if (State == State.DataLoaded)
                {
                        //    ETH Chart
                        if(Bars.TradingHours.Name.Contains(" ETH"))
                        {
                            DayType = tajBarDayType(BarsArray[1]);
                        }
    
                        //    RTH Chart
                        else
                        {
                            DayType = tajBarDayType();
                            AddChartIndicator(DayType);    
                        }
                }            
    ​ 
    


    The item I am trying to capture in the UI is Trading Hours.
    then use it in State.Configure instead of the Bars Object.



    #2
    Hello TAJTrades,

    Thank you for your post.

    Unfortunately, it's not possible to do this since the trading hours information is not available until State is State.DataLoaded:

    "Warning: The properties in this class should NOT be accessed within the OnStateChange() method before the State has reached State.DataLoaded​"



    And all calls to AddDataSeries() must be made when State is State.Configure:

    "This method should ONLY be called from the OnStateChange() method during State.Configure​"

    Comment


      #3
      I am familiar with all that replied.

      They question is can I somehow get the "Trading hours" parameter from the UI from within State.Configure? This question is NOT about using the Bars Object in State.Configure.

      Comment


        #4
        Hello TAJTrades,

        Unfortunately, it is not possible to get this information before State.DataLoaded. As stated in the Help Guide link in my previous reply:

        "Warning: The properties in this class should NOT be accessed within the OnStateChange() method before the State has reached State.DataLoaded​"



        There is no workaround to obtain the trading hours info another way before State.DataLoaded.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        43 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        21 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        30 views
        1 like
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        50 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        40 views
        0 likes
        Last Post CarlTrading  
        Working...
        X