Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Strategy start-up initialization
Collapse
X
-
Strategy start-up initialization
Where is there information on the startup of a strategy in terms of how much data is used and how it is used prior to the first OnBarUpdate? I need this in particular for the ATR. The ATR is the EMA of True Ranges. But at first it is the SMA over the initial period, then it continues as the EMA from there. I am effectively having to reverse engineer the way NT handles the startup of the ATR, even though the ATR formula is public.Tags: None
-
Hello,
There is a page in our Help Guide on the BarsRequired for a strategy:
The strategy will wait until BarsRequired have been met (20 by default, user definable) are added before it will call OnBarUpdate.
The is NOT the same as the BarsRequired for indicator, which will process data starting on Bar 0. It just simply waits until the BarsRequired have been met before it plots an indicator:
You will often find your indicator is in an unstable period between the bar 0 and the BarsRequired in an indicator. The value of the indicator will be available, but will not actually plot it until the bars required have been met to ensure we're working with stable values before it plots.MatthewNinjaTrader Product Management
-
Hi,
If you're referring to the strategy, note that there is both the option to set the BarsRequired from the UI when starting the strategy, and from the Initialize method.
The UI settings will override the Initialize.
The following is taken in the strategy base and works to my expectations
Code:protected override void Initialize() { BarsRequired = 100; } protected override void OnBarUpdate() { Print("BarsRequired: " + BarsRequired); Print("CurrentBar: " + CurrentBar); }
//first output
CurrentBar: 100
BarsRequired: 100MatthewNinjaTrader Product Management
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Mestor, 03-10-2023, 01:50 AM
|
12 responses
307 views
0 likes
|
Last Post
by z.franck
Today, 04:29 AM
|
||
Started by AgriTrdr, 07-16-2023, 12:54 PM
|
32 responses
267 views
0 likes
|
Last Post
by f.saeidi
Yesterday, 06:49 AM
|
||
Started by Mestor, Today, 03:15 AM
|
0 responses
2 views
0 likes
|
Last Post
by Mestor
Today, 03:15 AM
|
||
Started by Padan, Today, 02:02 AM
|
0 responses
6 views
0 likes
|
Last Post
by Padan
Today, 02:02 AM
|
||
Started by bukowa, 11-09-2023, 06:07 PM
|
20 responses
409 views
0 likes
|
Last Post
by Adfra
Today, 01:36 AM
|
Comment