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!
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
NinjaTrader
Indicator Sets Session Template
Collapse
X
-
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. -
Originally posted by habibalex View PostIs 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.
-
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
-
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]; }
Comment
-
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 );
Last edited by Ricam; 02-14-2018, 09:09 AM.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by samish18, 04-17-2024, 08:57 AM
|
16 responses
55 views
0 likes
|
Last Post
by samish18
Today, 03:30 PM
|
||
Started by arvidvanstaey, Today, 02:19 PM
|
3 responses
9 views
0 likes
|
Last Post Today, 03:23 PM | ||
Started by jordanq2, Today, 03:10 PM
|
2 responses
8 views
0 likes
|
Last Post
by jordanq2
Today, 03:23 PM
|
||
Started by traderqz, Today, 12:06 AM
|
10 responses
18 views
0 likes
|
Last Post
by traderqz
Today, 02:49 PM
|
||
Started by algospoke, 04-17-2024, 06:40 PM
|
5 responses
47 views
0 likes
|
Last Post Today, 02:36 PM |
Comment