Ignore previous sessions - NinjaTrader | futures io social day trading
futures io futures trading


Ignore previous sessions
Updated: Views / Replies:2,076 / 11
Created: by humy65 Attachments:0

Welcome to futures io.

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

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

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

Reply
 
Thread Tools Search this Thread
 

Ignore previous sessions

  #1 (permalink)
Elite Member
Haifa/Israel
 
Futures Experience: Beginner
Platform: NinjaTrader
Favorite Futures: Stocks
 
Posts: 15 since Mar 2012
Thanks: 3 given, 2 received

Ignore previous sessions

I would like to avoid in my OnBarUpdate processing all bars that are prior to the current session - how ?

Reply With Quote
 
  #2 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 46,240 since Jun 2009
Thanks: 29,357 given, 83,240 received

Answer
This post has been selected as an answer to the original posters question Answer

Add at the top of OnBarUpdate

if (Historical) return;

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
The following user says Thank You to Big Mike for this post:
 
  #3 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 46,240 since Jun 2009
Thanks: 29,357 given, 83,240 received



humy65 View Post
I would like to avoid in my OnBarUpdate processing all bars that are prior to the current session - how ?

If you really want to include all the bars of current session, and not just the current bar, then you would need to do some logic check for the current bar date vs the Bars.Session stuff. I don't have Ninja up and haven't looked at that kind of code in years, but you can find sessions under Bars.Session* if I remember right.

Otherwise the if (Historical) return; would get you 99% there.

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
The following user says Thank You to Big Mike for this post:
 
  #4 (permalink)
Elite Member
Haifa/Israel
 
Futures Experience: Beginner
Platform: NinjaTrader
Favorite Futures: Stocks
 
Posts: 15 since Mar 2012
Thanks: 3 given, 2 received


Big Mike View Post
If you really want to include all the bars of current session, and not just the current bar, then you would need to do some logic check for the current bar date vs the Bars.Session stuff. I don't have Ninja up and haven't looked at that kind of code in years, but you can find sessions under Bars.Session* if I remember right.

Otherwise the if (Historical) return; would get you 99% there.

Mike

t

I need all bars in current session, not just the last.... so I'll have a look into the Bars.Session collection...

BTW : is there a way for me to detect whether the current connection is Market Replay connection ? (In side an indicator)

Reply With Quote
 
  #5 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,653 since Mar 2010
Thanks: 4,226 given, 25,602 received
Forum Reputation: Legendary


humy65 View Post
I would like to avoid in my OnBarUpdate processing all bars that are prior to the current session - how ?

Before I answer, I need to come back to a definition

Trading day: Refers to the contract of the instrument that you trade. For example for ES the trading day currently starts at 3:30 PM Central Time and ends at 3:15 PM Central Time next day. Starting from November 18, the trading day for ES will start at 5:00 PM Central Time and end at 4:15 PM Central Time.

Session: Part of the trading day. For ES there could be night session from 3:30 PM to 8:30 AM and a day session from 8:30 AM to 3:15 PM.

NinjaTrader uses both the concept of the trading day and the session. A trading day can be made up of 1, 2 or 3 sessions - theoretically there could be more than 3, but I have never seen any practical application.

I assume that you want to know how to avoid to process any bars prior to the current trading day. I do not know why you want to do that, there is really no need, as you can easily code indicators that reset at the beginning of each session. For example, I have coded a SMA that resets at the start of the session to apply it to the NYSE Tick, because I do not want to include tick values of the prior trading day.

But coming back to your question, this is how not to process bars of the prior trading day:

(1) collect the current time
(2) find the start time (date, hour, minutes) of the trading day
(3) check each bar that is processed, whether it has a time stamp prior to the start of the trading day or afterwards


Current Time

You may use DateTime.Now. If you are connected to Market Replay you can use a method Now
 
Code
private DateTime Now
{
	get 
	{ 
		DateTime now = (Bars.MarketData.Connection.Options.Provider == Cbi.Provider.Replay ? Bars.MarketData.Connection.Now : DateTime.Now); 
		if (now.Millisecond > 0)
			now = Cbi.Globals.MinDate.AddSeconds((long) System.Math.Floor(now.Subtract(Cbi.Globals.MinDate).TotalSeconds));
		return now;
	}
}


Find the start of the current session
 
Code
private DateTime sessionBegin;
private DateTime sessionEnd;
Bars.Session.GetNextBeginEnd(Now, out sessionBegin, out sessionEnd);

will retrieve the session begin and end time of the current session of the primary bars. I have used the method Now defined above.


Check whether the current bar processed belongs to the current session

If you want to check whether the timestamp of the current bar belongs to the session that includes "Now", you have to differentiate between 2 cases.

Bars Built from ticks: You need to check, whether the timestamp iof the processed bar iss greater or equal that the value for sessionBegin.
Minute bars: You need to check, whether the timestamp of the processed bar is greater than the value for sessionBegin.

For example, if your ES session starts at 8:30 AM Central Time, then

-> a minute bar with the timestamp of 8:30 belongs to the prior session, you do not want to include it
-> a tick built bar (tick, volume, range, Renko bars ....) with the timestamp of 8:30 belongs to the current session, you want to include it


Attention

Depending on how you implement that concept, it will reset your indicators at the session start or it will not. I personally cannot imagine any reason to eliminate the bars of the prior session. Your request looks strange to me, and you have not explained what it can be used for.

Reply With Quote
The following 3 users say Thank You to Fat Tails for this post:
 
  #6 (permalink)
Elite Member
Haifa/Israel
 
Futures Experience: Beginner
Platform: NinjaTrader
Favorite Futures: Stocks
 
Posts: 15 since Mar 2012
Thanks: 3 given, 2 received

Reason


Fat Tails View Post
Before I answer, I need to come back to a definition

Trading day: Refers to the contract of the instrument that you trade. For example for ES the trading day currently starts at 3:30 PM Central Time and ends at 3:15 PM Central Time next day. Starting from November 18, the trading day for ES will start at 5:00 PM Central Time and end at 4:15 PM Central Time.

Session: Part of the trading day. For ES there could be night session from 3:30 PM to 8:30 AM and a day session from 8:30 AM to 3:15 PM.

NinjaTrader uses both the concept of the trading day and the session. A trading day can be made up of 1, 2 or 3 sessions - theoretically there could be more than 3, but I have never seen any practical application.

I assume that you want to know how to avoid to process any bars prior to the current trading day. I do not know why you want to do that, there is really no need, as you can easily code indicators that reset at the beginning of each session. For example, I have coded a SMA that resets at the start of the session to apply it to the NYSE Tick, because I do not want to include tick values of the prior trading day.

But coming back to your question, this is how not to process bars of the prior trading day:

(1) collect the current time
(2) find the start time (date, hour, minutes) of the trading day
(3) check each bar that is processed, whether it has a time stamp prior to the start of the trading day or afterwards


Current Time

You may use DateTime.Now. If you are connected to Market Replay you can use a method Now
 
Code
private DateTime Now
{
	get 
	{ 
		DateTime now = (Bars.MarketData.Connection.Options.Provider == Cbi.Provider.Replay ? Bars.MarketData.Connection.Now : DateTime.Now); 
		if (now.Millisecond > 0)
			now = Cbi.Globals.MinDate.AddSeconds((long) System.Math.Floor(now.Subtract(Cbi.Globals.MinDate).TotalSeconds));
		return now;
	}
}


Find the start of the current session
 
Code
private DateTime sessionBegin;
private DateTime sessionEnd;
Bars.Session.GetNextBeginEnd(Now, out sessionBegin, out sessionEnd);

will retrieve the session begin and end time of the current session of the primary bars. I have used the method Now defined above.


Check whether the current bar processed belongs to the current session

If you want to check whether the timestamp of the current bar belongs to the session that includes "Now", you have to differentiate between 2 cases.

Bars Built from ticks: You need to check, whether the timestamp iof the processed bar iss greater or equal that the value for sessionBegin.
Minute bars: You need to check, whether the timestamp of the processed bar is greater than the value for sessionBegin.

For example, if your ES session starts at 8:30 AM Central Time, then

-> a minute bar with the timestamp of 8:30 belongs to the prior session, you do not want to include it
-> a tick built bar (tick, volume, range, Renko bars ....) with the timestamp of 8:30 belongs to the current session, you want to include it


Attention

Depending on how you implement that concept, it will reset your indicators at the session start or it will not. I personally cannot imagine any reason to eliminate the bars of the prior session. Your request looks strange to me, and you have not explained what it can be used for.


Thanks much for the detailed answer!!!

The reason I want to process just the current session's bars is that as I'm processing 1 tick series and my
processing incurs an overhead which involves communication to external program - I need to make sure
the overhead when loading a chart which has long history is minimal.

Reply With Quote
 
  #7 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,653 since Mar 2010
Thanks: 4,226 given, 25,602 received
Forum Reputation: Legendary


humy65 View Post
Thanks much for the detailed answer!!!

The reason I want to process just the current session's bars is that as I'm processing 1 tick series and my
processing incurs an overhead which involves communication to external program - I need to make sure
the overhead when loading a chart which has long history is minimal.


What about opening a chart with a lookback period of 1 or 2 days?

If you leave out the data prior to the current trading day, your indicators may display false values. Each indicator has a training period, for recursive indicators this can be pretty long.

Reply With Quote
 
  #8 (permalink)
Elite Member
Haifa/Israel
 
Futures Experience: Beginner
Platform: NinjaTrader
Favorite Futures: Stocks
 
Posts: 15 since Mar 2012
Thanks: 3 given, 2 received


Fat Tails View Post
What about opening a chart with a lookback period of 1 or 2 days?

If you leave out the data prior to the current trading day, your indicators may display false values. Each indicator has a training period, for recursive indicators this can be pretty long.

No worries - this indicator has no display, it is used just as an integration vehicle to external application which gets tick data from the the NT feed.

If I'm to use the lookback period option, can it be set (by the indicator) ?
Can it be set for each dataseries to be a different value (this is a multi instrument, multi time frame indicator) ?

Reply With Quote
 
  #9 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,653 since Mar 2010
Thanks: 4,226 given, 25,602 received
Forum Reputation: Legendary

Answer
This post has been selected as an answer to the original posters question Answer


humy65 View Post
No worries - this indicator has no display, it is used just as an integration vehicle to external application which gets tick data from the the NT feed.

If I'm to use the lookback period option, can it be set (by the indicator) ?
Can it be set for each dataseries to be a different value (this is a multi instrument, multi time frame indicator) ?

You cannot set the lookback of the chart from the inidcator, and it is not possible to have different values for different instruments.

What you can do is simply check for a start date /start time when OnBarUpdate() is running. For example, if you trade ES and today's session started at 4:30 Eastern Time yesterday, you simply add three lines in the beginning of OnBarUpdate():
 
Code
DateTime startTime =  DateTime.Now.AddDays(-1).Date. AddHours(16).AddMinutes(30);
if((Bars.BarsType.BuiltFrom == PeriodType.Tick && Time[0] < startTime) || (Bars.BarsType.BuiltFrom == PeriodType.Minute && Time[0] <= startTime)
  return;

This would be the easiest solution. If you want to use that in Replay Mode, then you replace DateTime.Now with the method Now as shown above.

Reply With Quote
 
  #10 (permalink)
Elite Member
Haifa/Israel
 
Futures Experience: Beginner
Platform: NinjaTrader
Favorite Futures: Stocks
 
Posts: 15 since Mar 2012
Thanks: 3 given, 2 received



Fat Tails View Post
You cannot set the lookback of the chart from the inidcator, and it is not possible to have different values for different instruments.

What you can do is simply check for a start date /start time when OnBarUpdate() is running. For example, if you trade ES and today's session started at 4:30 Eastern Time yesterday, you simply add three lines in the beginning of OnBarUpdate():
 
Code
DateTime startTime =  DateTime.Now.AddDays(-1).Date. AddHours(16).AddMinutes(30);
if((Bars.BarsType.BuiltFrom == PeriodType.Tick && Time[0] < startTime) || (Bars.BarsType.BuiltFrom == PeriodType.Minute && Time[0] <= startTime)
  return;

This would be the easiest solution. If you want to use that in Replay Mode, then you replace DateTime.Now with the method Now as shown above.

Sure...though start of session should be derived from the instrument and not as a constant... Thanks much !!!!

Reply With Quote
The following user says Thank You to humy65 for this post:

Reply



futures io > > > > Ignore previous sessions

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ignore feature -- Should I use? or shouldn't? dario1 Traders Hideout 1 September 7th, 2012 12:18 PM
With US Data Improving, Markets May Ignore Europe Quick Summary News and Current Events 0 November 15th, 2011 08:50 PM
How to set the forum to Ignore certain users Big Mike Beginners and Introductions 2 September 23rd, 2009 01:55 AM


All times are GMT -4. The time now is 06:35 PM.

Copyright © 2017 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
Page generated 2017-12-18 in 0.16 seconds with 40 queries on phoenix via your IP 54.221.93.187