NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 03-09-2009, 05:40 AM   #1
makra081
Senior Member
 
Join Date: Dec 2008
Posts: 134
Thanks: 15
Thanked 4 times in 4 posts
Default Last Bar of Session

Hello Ninja Team,

I am looking for a way to check within a strategy if we are at the last Bar of the session.

This should avoid the execution of an entry signal during the first bar of next days session (e.g. 7:00) which was created on the last bar of a session (19:00) - but not executed because of onBarClose.

The session parameters(chart) are set to session from 7:00 to 19:00.

I searched the forum for answers without success.
Any Ideas ?

TY
makra081 is offline  
Reply With Quote
Old 03-09-2009, 06:04 AM   #2
makra081
Senior Member
 
Join Date: Dec 2008
Posts: 134
Thanks: 15
Thanked 4 times in 4 posts
Default

I tried Bars.BarsSinceSession !=0 .

This does not work, because the execution in the morning (e.g. 7:00) has Bars.BarsSinceSession = X , e.g. 31 from the previous session/ day.

To make it really complicated: my executions are set to OnBarClose, market orders and I use range bars(Alt).


The problem seems to be that the execution on BarClose of the last bar of session is in reality executed on the next day.

If I use Range Bars instead of RangeAlt the problem is solved. But is there a way to have RangeAlt nonetheless ?
Last edited by makra081; 03-09-2009 at 06:21 AM.
makra081 is offline  
Reply With Quote
Old 03-09-2009, 06:33 AM   #3
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
Default

Hi makra081, thanks for your posts - have you tried to limit your trading strategy with time filters? Please see this reference sample for details - http://www.ninjatrader-support2.com/...ead.php?t=3226
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 03-09-2009, 07:35 AM   #4
makra081
Senior Member
 
Join Date: Dec 2008
Posts: 134
Thanks: 15
Thanked 4 times in 4 posts
Default

Hello,

TY for replying.

Sadly that does not solve my problem.

I set the Chart Session Parameter to 7:00-19:00.

If there is a entry sig on the last bar - e.g 18:45 - the execution should be done on that day - not the next day !!

Ninjatrader waits for the new Bar which is not printed before the next day.
Last edited by makra081; 03-09-2009 at 08:01 AM.
makra081 is offline  
Reply With Quote
Old 03-09-2009, 08:17 AM   #5
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
Default

This is expected since I guess you run your strategy on CalculateOnBarClose = true, right?

So this means the strategy waits for your 15 min bar to close to place orders on the next bar, which is then the first of the new day with your session times setup.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 03-09-2009, 04:54 PM   #6
makra081
Senior Member
 
Join Date: Dec 2008
Posts: 134
Thanks: 15
Thanked 4 times in 4 posts
Default

Yes I use CalculateOnBarClose = true. That is correct.

Is there any way around this ?
makra081 is offline  
Reply With Quote
Old 03-10-2009, 06:45 AM   #7
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
Default

You could try running your strategy on CalculateOnBarClose = false and then moving your trading signal logic to execute on the first tick of a new bar with if (FirstTickOfBar) ... http://www.ninjatrader-support.com/H...TickOfBar.html

Of course you want to reference then one bar further back to adjust for this ([0] calls become [1]).
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 03-10-2009, 11:24 AM   #8
makra081
Senior Member
 
Join Date: Dec 2008
Posts: 134
Thanks: 15
Thanked 4 times in 4 posts
Default

TY NinjaTrader_Bertrand
makra081 is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Session times/bar calc nicko9 Market Analyzer 5 05-25-2009 12:55 AM
Last bar of session doesn't have indicators until next session begins cunparis Charting 8 11-04-2008 06:45 AM
Historical and first bar of current session palinuro General Programming 3 07-02-2008 11:55 AM
Bar index from the session or plot bar number on an intraday chart eneratom General Programming 1 02-27-2008 06:48 AM
How to reference the Nth bar of a session raintree Strategy Development 9 12-09-2007 02:51 AM


All times are GMT -6. The time now is 07:39 PM.