![]() |
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Dec 2008
Posts: 134
Thanks: 15
Thanked 4 times in 4 posts
|
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
|
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Dec 2008
Posts: 134
Thanks: 15
Thanked 4 times in 4 posts
|
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.
|
|
|
|
|
|
#3 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
|
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
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#4 |
|
Senior Member
Join Date: Dec 2008
Posts: 134
Thanks: 15
Thanked 4 times in 4 posts
|
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.
|
|
|
|
|
|
#5 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
|
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.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#6 |
|
Senior Member
Join Date: Dec 2008
Posts: 134
Thanks: 15
Thanked 4 times in 4 posts
|
Yes I use CalculateOnBarClose = true. That is correct.
Is there any way around this ? |
|
|
|
|
|
#7 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
|
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]).
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#8 |
|
Senior Member
Join Date: Dec 2008
Posts: 134
Thanks: 15
Thanked 4 times in 4 posts
|
TY NinjaTrader_Bertrand
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |