(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 Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
563 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
329 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 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
547 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
548 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment