(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 CarlTrading, 03-31-2026, 09:41 PM
|
1 response
157 views
1 like
|
Last Post
|
||
|
Started by CarlTrading, 04-01-2026, 02:41 AM
|
0 responses
91 views
1 like
|
Last Post
by CarlTrading
04-01-2026, 02:41 AM
|
||
|
Started by CaptainJack, 03-31-2026, 11:44 PM
|
0 responses
143 views
2 likes
|
Last Post
by CaptainJack
03-31-2026, 11:44 PM
|
||
|
Started by CarlTrading, 03-30-2026, 11:51 AM
|
0 responses
131 views
1 like
|
Last Post
by CarlTrading
03-30-2026, 11:51 AM
|
||
|
Started by CarlTrading, 03-30-2026, 11:48 AM
|
0 responses
107 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:48 AM
|

Comment