Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to access Tradings Hours picker?

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

  • Sim22
    replied
    I remade it like this since I had to put a condition in here if in case the default template is ETH when RTH bars are used:

    PHP Code:
     
    if (value == TradingHours.UseInstrumentSettings && Instrument != null)
    {
         
    // in case the default template is ETH when RTH bars are used
         
    if (Bars != null && Instrument.MasterInstrument.TradingHours.Name.Contains   ("ETH") && Bars.TradingHours.Name.Contains("RTH"))
                    
    tradingHours Bars.TradingHours;
         else
                
    tradingHours Instrument.MasterInstrument.TradingHours;
    }
    else if (
    value != null)
           
    tradingHours TradingHours.Get(value);
    else
          
    tradingHours TradingHours.Get("Default 24 x 7"); 
    Thanks again.

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello Sim22,

    The TradingHours.Get() is returning a null when using '<Use instrument settings>'.

    Try adding:
    if (value == TradingHours.UseInstrumentSettings && Instrument != null)
    value = Instrument.MasterInstrument.TradingHours.Name;

    To have this return the default trading hours template for the primary instrument.

    Regarding use the Bar object in the setter, you have a check for null so this should be fine.

    Leave a comment:


  • Sim22
    replied
    This is not documented code, but should achieve your goal
    Thank you Chelsea

    Edit:

    I did have an exception in this raw form if selecting "<Use instrument settings> so I did this:

    PHP Code:
     
    [NinjaScriptProperty]
    [
    Display(Name "Trading Hours"GroupName "Parameters"Order 0)]
    [
    TypeConverter(typeof(TradingHoursDataConverter))]
    public 
    string TradingHoursString
    {
        
    get
        
    {
           return 
    tradingHours.ToString();
        }
        
    set
        
    {
             try
             {
     
                  if (
    value != "<Use instrument settings>")
                      
    tradingHours TradingHours.Get(value);
                  else if (
    Bars != null)
                      
    tradingHours Bars.TradingHours;
                  else
                      
    tradingHours Instrument.MasterInstrument.TradingHours;
             }
             catch(
    Exception)
             {}
        }

    Referring to Bars or Instrument within the properties section.....will that cause any issues do you think?

    Thanks again, you've saved me many hours writing a custom enum.
    Last edited by Sim22; 09-07-2016, 11:29 PM.

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello Sim22,

    This is not documented code, but should achieve your goal:

    Code:
    private TradingHours tradingHours;
    
    [NinjaScriptProperty]
    [Display(Name = "Trading Hours", GroupName = "Parameters", Order = 0)]
    [TypeConverter(typeof(TradingHoursDataConverter))]
    public string TradingHoursString
    {
    	get
    	{
    		return tradingHours.ToString();
    	}
    	set
    	{
    		tradingHours = TradingHours.Get(value);
    	}
    }
    In State.SetDefaults you can set a default string:
    TradingHoursString = "Default 24 x 7";

    Leave a comment:


  • Sim22
    started a topic How to access Tradings Hours picker?

    How to access Tradings Hours picker?

    Hi there,

    is it possible to use a picker for trading hours templates similar to Gui.Tools.InstrumentSelector ?

    I can't see one available and yet it is available within the DataSeries UI.

    If it is not publically available, then would you please consider making it so.

    Thank you.

Latest Posts

Collapse

Topics Statistics Last Post
Started by bortz, 11-06-2023, 08:04 AM
47 responses
1,606 views
0 likes
Last Post aligator  
Started by jaybedreamin, Today, 05:56 PM
0 responses
8 views
0 likes
Last Post jaybedreamin  
Started by DJ888, 04-16-2024, 06:09 PM
6 responses
18 views
0 likes
Last Post DJ888
by DJ888
 
Started by Jon17, Today, 04:33 PM
0 responses
4 views
0 likes
Last Post Jon17
by Jon17
 
Started by Javierw.ok, Today, 04:12 PM
0 responses
13 views
0 likes
Last Post Javierw.ok  
Working...
X