Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Indicator Sets Session Template

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

    Indicator Sets Session Template

    Is it possible to set the session template in an indicator? I have an indicator that requires different 24 hour sessions for ES, CL, ZN, ect...but I don't want to change the default instrument session template, which is the regular RTH hours. Only when I call this indicator do I want to use the 24 hour template.

    #2
    Originally posted by habibalex View Post
    Is it possible to set the session template in an indicator? I have an indicator that requires different 24 hour sessions for ES, CL, ZN, ect...but I don't want to change the default instrument session template, which is the regular RTH hours. Only when I call this indicator do I want to use the 24 hour template.

    You can select the session template for each bar series that has been added when you open a chart. The session template configures the bars, as the last bar of each session is cut off at the session break.

    If you add an indicator, this indicator will always use the session template of the bar series that is selected as input series for this indicator via the indicator dialogue box. The indicator cannot run on a different session template.

    A special case are multi-instrument indicators. If for an instrument no bar series has been added to the chart and if such a bar series for the instrument is loaded by the indicator itself, the session template stored under <instrument settings> will be used.

    For example it is impossible to calculate indicator values from an ETH session template and display those value on a chart that uses a RTH session template.
    Last edited by Harry; 01-01-2014, 03:40 PM.

    Comment


      #3
      NinjaTrader 8 Indicator using different Session Template to instrument's chart?

      Hi,

      Is it possible for an instrument's (e.g. ES) chart to be using a CME US Index Futures ETH session template but for an indicator to calculate the prior sessions OHLC based on the CME US Index Futures RTH session template? If so could someone kindly point me in the right direction please?

      Many Thanks.
      dowtrader

      Comment


        #4
        Hello dowtrader,

        Thank you for your post.

        It is possible to do this through NinjaTrader 8. You can add a bar series to the script of the instrument with the desired Trading Hours Template but you would need to hard code the instrument name and would not be able to dynamically apply the Trading Hours Template to any instrument without it being hard coded in the indicator. Please visit the following link for more information: https://ninjatrader.com/support/help...dataseries.htm

        In NinjaTrader 7 there is no option for this through the Add() function.

        Another alternative that would work in NinjaTrader 7 and NinjaTrader 8 is to use a time filter and assign the opening price to a variable, the closing price to a variable, and then calculate the highest high through the time range and the lowest low through the time range.

        For example:
        Code:
        		private double myTimeRangeOpen = 0;
        		private double myTimeRangeClose = 0;
        		private double myTimeRangeHigh = double.MinValue;
        		private double myTimeRangeLow = double.MaxValue;
        		protected override void OnBarUpdate()
        		{
        			if (ToTime(Time[0]) >= ToTime(9,0,0)
        				&& ToTime(Time[0]) <= ToTime(17,0,0))
        			{
        				if (myTimeRangeOpen == 0)
        					myTimeRangeOpen = Open[0];
        				
        				if (High[0] > myTimeRangeHigh)
        					myTimeRangeHigh = High[0];
        				
        				if (Low[0] < myTimeRangeLow)
        					myTimeRangeLow = Low[0];
        			}
        			if (ToTime(Time[0]) >= ToTime(17,0,0)
        				&& myTimeRangeClose == 0)
        				myTimeRangeClose = Close[0];
        		}
        Please let me know if you have any questions.

        Comment


          #5
          You don't need to hard code the FullName of the instrument on the chart which is Instrument.FullName. The trading hours argument of the method can be ANY valid session name from the list of available Trading Hours Templates but make sure you get all the characters exactly right. Refer to the documentation for the AddDataSeries method in the help guide. Have a nice Current Day, and Prior Day, too!

          Code:
                   ~ variable declarations ~
          
                   private string sessionStringE
          
                   ~ State.Configure ~
          
                   sessionStringE="CME US Index Futures ETH";
          			
          	 AddDataSeries
          		 (     Instrument.FullName,
          			new BarsPeriod() {BarsPeriodType = BarsPeriodType.Tick, Value = 1},					
          			sessionStringE				 
          		  );
          Attached Files
          Last edited by Ricam; 02-14-2018, 09:09 AM.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Radano, 06-10-2021, 01:40 AM
          20 responses
          616 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by Mizzouman1, Today, 07:35 AM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by i019945nj, 12-14-2023, 06:41 AM
          6 responses
          67 views
          0 likes
          Last Post i019945nj  
          Started by aa731, Today, 02:54 AM
          1 response
          8 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by BarzTrading, Today, 07:25 AM
          0 responses
          3 views
          0 likes
          Last Post BarzTrading  
          Working...
          X