(I mean start / end datetime of backtest, which are set in backtest settings)
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Get From/Until of backtest
Collapse
X
-
Hi misova,
While I am not aware of any undocumented (or documented) way of reading the Start date and End date when running a backtest directly, a work around would be to read the first and last bar's time.
(edited to NinjaTrader 7 code)
Code:protected override void OnStartUp() { Print(string.Format("startTime: {0} | endTime: {1}", Bars.GetTime(0), Bars.GetTime(Count - 1) )); }Chelsea B.NinjaTrader Customer Service
-
Thank you, this solution works.Originally posted by NinjaTrader_ChelseaB View PostHi misova,
While I am not aware of any undocumented (or documented) way of reading the Start date and End date when running a backtest directly, a work around would be to read the first and last bar's time.
(edited to NinjaTrader 7 code)
Code:protected override void OnStartUp() { Print(string.Format("startTime: {0} | endTime: {1}", Bars.GetTime(0), Bars.GetTime(Count - 1) )); }
By trial and error I found, these properties work and they are the exact values put into the GUI properties:
- Strategy.BackTestFrom
- Strategy.BackTestTo
Comment
-
Hi Chelsea,
Here is the quick fix: remove the "Strategy."
I wrote Strategy.XXX just to underline idea, that XXX can be invoked on the Strategy class. That could cause confusion.
Here is the corrected line (and full code in attachment):
Best regardsCode:Print(string.Format("{0} | {1}", BackTestFrom, BackTestTo));
MisovaAttached Files
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Hwop38, 05-04-2026, 07:02 PM
|
0 responses
154 views
0 likes
|
Last Post
by Hwop38
05-04-2026, 07:02 PM
|
||
|
Started by CaptainJack, 04-24-2026, 11:07 PM
|
0 responses
306 views
0 likes
|
Last Post
by CaptainJack
04-24-2026, 11:07 PM
|
||
|
Started by Mindset, 04-21-2026, 06:46 AM
|
0 responses
244 views
0 likes
|
Last Post
by Mindset
04-21-2026, 06:46 AM
|
||
|
Started by M4ndoo, 04-20-2026, 05:21 PM
|
0 responses
345 views
0 likes
|
Last Post
by M4ndoo
04-20-2026, 05:21 PM
|
||
|
Started by M4ndoo, 04-19-2026, 05:54 PM
|
0 responses
176 views
0 likes
|
Last Post
by M4ndoo
04-19-2026, 05:54 PM
|

Comment