NexusFi: Find Your Edge


Home Menu

 





How to reference Session template Price/Time?


Discussion in NinjaTrader

Updated
    1. trending_up 5,363 views
    2. thumb_up 3 thanks given
    3. group 4 followers
    1. forum 8 posts
    2. attach_file 3 attachments




 
Search this Thread

How to reference Session template Price/Time?

  #1 (permalink)
 
forrestang's Avatar
 forrestang 
Chicago IL
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
Posts: 1,329 since Jun 2010
Thanks Given: 354
Thanks Received: 1,047

Simple question.

Say you where using a ETH session template for ES, as you main look of your chart. And then you decide you want to be able to reference the Open/Close price/time of "CME Index Futures RTH" template. How and when do you reference it?

Reference Link

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
NexusFi Journal Challenge - April 2024
Feedback and Announcements
Build trailing stop for micro index(s)
Psychology and Money Management
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
59 thanks
Funded Trader platforms
36 thanks
NexusFi site changelog and issues/problem reporting
25 thanks
GFIs1 1 DAX trade per day journal
19 thanks
The Program
18 thanks
  #3 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102



forrestang View Post
Simple question.

Say you where using a ETH session template for ES, as you main look of your chart. And then you decide you want to be able to reference the Open/Close price/time of "CME Index Futures RTH" template. How and when do you reference it?

Reference Link

You can only reference something that is there. That means that if you want to reference the opening time of the RTH session, then you need to use a session template, which actually includes that time.

I use a session template with two sessions per day, as is attached.

To reference the session start time and the session end time of the current session you can use

 
Code
Bars.Session.GetNextBeginEnd(Bars, 0, out sessionBegin, out sessionEnd);
Now, if you have several sessions per day, you will need to find out whether your current session is the night session or the day session.

There is another NinjaScript method that may help you:

 
Code
Bars.GetTradingDayFromLocal(Time[0])
If this value increase by one day, if you detect a FirstBarOfSession event, then it is the start of the night session. If it does not increase, it is the start of the RTH session. You can then collect the session start time and use it for whatever you need to know.

As a coding example you can have a look at the OpeningRange indicator which uses these NinjaScript methods.

Attached Thumbnails
Click image for larger version

Name:	Session Template ES.PNG
Views:	275
Size:	21.3 KB
ID:	54863  
Reply With Quote
Thanked by:
  #4 (permalink)
 
forrestang's Avatar
 forrestang 
Chicago IL
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
Posts: 1,329 since Jun 2010
Thanks Given: 354
Thanks Received: 1,047

If you have a template with two sessions added into it, how do you reference specifically one and not the other?

I.e. when you use "Bars.Session.GetNextBeginEnd(Bars, 0, out sessionBegin, out sessionEnd);"...... how does it know which template for each day you are trying to point it to?

Started this thread Reply With Quote
  #5 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


forrestang View Post
If you have a template with two sessions added into it, how do you reference specifically one and not the other?

I.e. when you use "Bars.Session.GetNextBeginEnd(Bars, 0, out sessionBegin, out sessionEnd);"...... how does it know which template for each day you are trying to point it to?

This can only be done indirectly. I keep track of the current trading day and then count the sessions. First I check, whether the current trading day changed when a Bars.FirstBarOfSession event occurs. If this is the case, then I label this session as session number 1 and store the session start time and session end time. Then I count the sessions until the next trading day starts.

It is not possible to access the session start and end times of the different sessions directly. The only way to do it is to use Bars.Session.GetNextBeginEnd(Bars, 0, out sessionBegin, out sessionEnd) and store those values along with the intradays session count, if you want to retrieve them later.

Reply With Quote
  #6 (permalink)
 
forrestang's Avatar
 forrestang 
Chicago IL
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
Posts: 1,329 since Jun 2010
Thanks Given: 354
Thanks Received: 1,047

So..... since you can't actually reference an individual session template on a chart.......

Do you just create a template that has all the hours you need, i.e. a 24 hour chart, then just start counters at each session change by comparing it to a time?

see pic for example of what I mean.

Attached Thumbnails
Click image for larger version

Name:	11-13-2011 11-11-07 AM.png
Views:	277
Size:	29.9 KB
ID:	55568  
Started this thread Reply With Quote
  #7 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


forrestang View Post
So..... since you can't actually reference an individual session template on a chart.......

Do you just create a template that has all the hours you need, i.e. a 24 hour chart, then just start counters at each session change by comparing it to a time?

see pic for example of what I mean.

Attached is my session template for FOREX. It has three distinct sessions per day, so every trading day there are three bars for which Bars.FirstBarOfSession returns the value "true". The enitre trading day covers three sessions. NinjaTrader will decide on its own, which of the three sessions starts the trading day. This is a weakness of the product and needs reengineering. The user should decide upon the first session of the day. The heuristics used by NinjaTrader works in 95% of all cases, but not always. In some cases it is impossible to set up the session template that you want.

I just use a counter. When the trading day starts - detected by GetTradingDayFromLocal() - I set the counter to 1.
When the second session of the trading day starts - detected by Bars.FirstBarOfSession - I set the counter to 2, for the third session of the trading day, I set it to 3. This is not difficult to do and the counter will always tell you which is your current trading session.

So I do not need to compare the time of the bar with the opening time of London or New York. I just us Bars.FirstBarOfSession as a trigger to count the intraday sessions.

You can have a look at the SessionPivots indicators - easiest would be anaCurrentDayOHL - to understand how I use it.

Attached Thumbnails
Click image for larger version

Name:	Session Template FOREX.PNG
Views:	232
Size:	20.9 KB
ID:	55571  
Reply With Quote
  #8 (permalink)
 
forrestang's Avatar
 forrestang 
Chicago IL
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
Posts: 1,329 since Jun 2010
Thanks Given: 354
Thanks Received: 1,047


Fat Tails View Post
............ - easiest would be anaCurrentDayOHL - to understand how I use it.

Do you mean THIS one?

Started this thread Reply With Quote
  #9 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


forrestang View Post
Do you mean THIS one?

Yes, that would be the simplest indicator which differeniates between ETH and RTH sessions.

You can have a look at

line 262 -> checks for a new trading day (calls a subroutine which uses GetTradingDayFromLocal())
line 271 -> sessionCount is set to 1 for the first session
line 307 -> sessionCount is increased by 1

Reply With Quote
Thanked by:




Last Updated on November 24, 2011


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts