if that is correct behaviour what is the alternative?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Bars.LastBarOfSession always true
Collapse
X
-
Bars.LastBarOfSession always true
Bars.LastBarOfSession always true when CalculateOnBarClose=true
if that is correct behaviour what is the alternative? -
The error occurs using MBTrading FX DatafeedOriginally posted by NinjaTrader_Bertrand View PostMicroTrends, I can't confirm this here in my tests run, which version / market / sessions are you using?
also: this would be unfortunately not a supported NinjaScript functionality (not documented).
You could check for the hours of the template applied with the GetNextSessionBeginEnd:
http://www.ninjatrader.com/support/h...t7/session.htm
Delete the Forex sesison template
use the 24/7 Template
Set calculatebaronclose =false;
test on barupdate
Comment
-
Actually i thinnk it was a PFGBEST cme session or a 24/5 sesison for futures....I will have to dig:-)
Comment
-
ok i remembered:
Harry's indicator shows the issue visually:
It works as normal on a chart but, the issue is created by the adidtion of a strategy.with calculateonbarclose set to false
Last edited by MicroTrends; 05-20-2011, 03:49 AM.
Comment
-
Could reproduce bug over here
The bug is easy to reproduce. Just add the indicator below to a virgin chart and use it with real-time data and CalculateOnBarClose = false setting.
NinjaTrader will now identify every real-time bar as last bar of session, see chart below.
The bug also showed on index futures.Last edited by Harry; 05-20-2011, 04:09 AM.
Comment
-
Comment
-
MicroTrends and Harry,
This is not a supported property that you guys are using for the exact reason as you guys have outlined in this thread. In our source code we specifically have notes commented on it that says it would always be true for the right-most bar making it pretty much unusable for real-time strategies.
Unfortunately we will not be able to make any changes to this property.Josh P.NinjaTrader Customer Service
Comment
-
Bars.LastBarOfSession
I would like a live strategy to perform a certain action after it has processed all its historical bars.
In a backtest, one can use "OnTermination", but a live strategy ( on a chart, CalculateOnBarClose = false ) doesn't receive that unless and until the strategy is disabled.
Normally I would just have the strategy act upon the first "OnBarUpdate" to arrive, but under extra-market conditions, for example, those can be few and far between and I can't wait for them, so I'd like the strategy to be able to immediately act upon "knowing" it has processed its last historical bar.
Would "Bars.LastBarOfSession", although unsupported, be useful here ? There's no documentation to refer to, but it would seem a property like this might exist mainly for these purposes.
Comment
-
Hello Shogun SunTzu,
I believe Historical property should work for you.
It's used in the example below to exclude processing on Historical bars and only work on real time data.
if (Historical) return;
If you want some historical processing but not for a specific condition, use:
if (!Historical)Ryan M.NinjaTrader Customer Service
Comment
-
Try this....Originally posted by Shogun SunTzu View Post[FONT=Verdana][SIZE=3]I would like a live strategy to perform a certain action after it has processed all its historical bars.
/Code:protected override void OnBarUpdate() { if (LastBarOnChart) Print "We're on the last bar"; } // Returns true if processing last bar added to chart. // private bool LastBarOnChart { get { return( Historical && (CurrentBar == (Bars.Count - 1 - (CalculateOnBarClose ? 1 : 0 )) )); // Return TRUE if at the last historical bar of the chart. } }
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
648 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
369 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
108 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
572 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
574 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment