How to reference Session template Price/Time? - futures io
futures io



How to reference Session template Price/Time?


Discussion in NinjaTrader

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




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

How to reference Session template Price/Time?

(login for full post details)
  #1 (permalink)
 forrestang 
Urban Samurai
Chicago IL
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
 
forrestang's Avatar
 
Posts: 1,224 since Jun 2010
Thanks: 302 given, 924 received

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

Journal Challenge April 2021 results (now extended!):
Competing for $1800 in prizes from Jigsaw
looks_oneMaking a Living with the Microsby sstheo
(79 thanks from 10 posts)
looks_twoSalao's Journalby Salao
(23 thanks from 5 posts)
looks_3Deetee’s DAX Trading Journal (time based)by Deetee
(16 thanks from 8 posts)
looks_4Learning to Profit - A journey in algorithms and optionsby Syntax
(12 thanks from 7 posts)
looks_5Rogue MNQ 2/21 Journeyby RogueJoules
(0 thanks from 2 posts)
 
Best Threads (Most Thanked)
in the last 7 days on futures io
The Crude Dude Oil Trading System
73 thanks
futures io site changelog and issues/problem reporting
71 thanks
Would You Sell Your System?
65 thanks
FIO Journal Challenge - April 2021 w/Jigsaw Trading
30 thanks
Big Mike in Ecuador
25 thanks
 
(login for full post details)
  #3 (permalink)
 Fat Tails 
Market Wizard
Berlin, Europe
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,855 since Mar 2010
Thanks: 4,238 given, 26,742 received



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:	132
Size:	21.3 KB
ID:	54863  
Reply With Quote
The following 2 users say Thank You to Fat Tails for this post:
 
(login for full post details)
  #4 (permalink)
 forrestang 
Urban Samurai
Chicago IL
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
 
forrestang's Avatar
 
Posts: 1,224 since Jun 2010
Thanks: 302 given, 924 received

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
 
(login for full post details)
  #5 (permalink)
 Fat Tails 
Market Wizard
Berlin, Europe
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,855 since Mar 2010
Thanks: 4,238 given, 26,742 received


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
 
(login for full post details)
  #6 (permalink)
 forrestang 
Urban Samurai
Chicago IL
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
 
forrestang's Avatar
 
Posts: 1,224 since Jun 2010
Thanks: 302 given, 924 received

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:	122
Size:	29.9 KB
ID:	55568  
Started this thread Reply With Quote
 
(login for full post details)
  #7 (permalink)
 Fat Tails 
Market Wizard
Berlin, Europe
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,855 since Mar 2010
Thanks: 4,238 given, 26,742 received


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:	99
Size:	20.9 KB
ID:	55571  
Reply With Quote
 
(login for full post details)
  #8 (permalink)
 forrestang 
Urban Samurai
Chicago IL
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
 
forrestang's Avatar
 
Posts: 1,224 since Jun 2010
Thanks: 302 given, 924 received


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
 
(login for full post details)
  #9 (permalink)
 Fat Tails 
Market Wizard
Berlin, Europe
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,855 since Mar 2010
Thanks: 4,238 given, 26,742 received


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
The following user says Thank You to Fat Tails for this post:


futures io Trading Community Platforms and Indicators NinjaTrader > How to reference Session template Price/Time?


Last Updated on November 24, 2011


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Journal Challenge w/$1,800 in prizes!

April
 

Seven Trading Mistakes Solved With Smart Trading Tools w/Brannigan Barrett

Elite only
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts