Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Has IsFirstTickOfBar issues reported ?
Collapse
X
-
Hello pstrusi,
This would depend on if you are looking at historical data or realtime data.
if Calculate is set to OnPriceChange in real-time or historically with TickReplay enabled the behavaior should be the same. With TickReplay disabled, IsFIrstTickOfBar will always be true in historical data.
From the help guide:
"On a historical data set, only the OHLCVT of the bar is known and not each tick that made up the bar. As a result, State.Historical data processes OnBarUpdate() only on the close of each historical bar even if this property is set to OnEachTick or OnPriceChange. You can use TickReplay or a Multi-time frame script to obtain intrabar data."
Below is a publicly available link to the help guide on Calculate.
And TickReplay.
-
Originally posted by NinjaTrader_ChelseaB View PostHello pstrusi,
Print the value of IsFirstTickOfBar along with the time.
Is this true when you are expecting it? (and false when you are expecting it?)
I've tested but I'm not able to reproduce any issues printing the IsFirstTickOfBar with Calculate set to OnEachTick in real-time or historically with TickReplay enabled.
If I set " Calculate as Calculate.OnPriceChange ", but I didn't activate the Tick replay property in the Data series: would it "IsFirstTickOfBar" still work? Tickreplay seems to be a feature to evaluate in the historical data, but when it comes to realtime data, whay would I need to have activated Tickreplay ?
Thanks
Leave a comment:
-
Hello pstrusi,
Print the value of IsFirstTickOfBar along with the time.
Is this true when you are expecting it? (and false when you are expecting it?)
I've tested but I'm not able to reproduce any issues printing the IsFirstTickOfBar with Calculate set to OnEachTick in real-time or historically with TickReplay enabled.
Leave a comment:
-
Has IsFirstTickOfBar issues reported ?
I think there must be a problem with " IsFirstTickOfBar" cause I can't find any other cause. In the following simple code you can see the logic flow. If "IsFirstTickOfBar" is true, all statements should be triggered, but they doesn't.
Here the code:
Code:namespace NinjaTrader.NinjaScript.Strategies { public class Trendline { public int Position; public double Price; public Trendline() { Position=0; Price=0.00; } } public class R : Strategy { Trendline[] Uptrend; // Array of uptrends Trendline[] Downtrend; // Array of uptrends private int ARRAY_SIZE; // Array size private int Uptrendcount; // Number of active uptrends private int Downtrendcount; // Number of active Downtrends protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @""; Name = "R"; Calculate = Calculate.OnPriceChange; MaximumBarsLookBack = MaximumBarsLookBack.Infinite; } else if (State == State.Configure) { ARRAY_SIZE = 100000; Uptrendcount = 0; Downtrendcount = 0; Uptrend = new Trendline[ARRAY_SIZE]; Downtrend = new Trendline[ARRAY_SIZE]; } } protected override void OnBarUpdate() { if ( CurrentBar < 1 ) { Uptrendcount=0; Downtrendcount=0; for (int i = 0; i <ARRAY_SIZE; i++) { Uptrend[i]= new Trendline(); Downtrend[i]= new Trendline(); } for (int i = 0; i <ARRAY_SIZE; i++) // just in case this initialization was necessary to solve the issue { Uptrend[i].Position=0; Uptrend[i].Price=0.00; Downtrend[i].Position=0; Downtrend[i].Price=0.00; } return; } if (IsFirstTickOfBar) { if ( Uptrendcount==0 && Downtrendcount==0 ) { Ps=0; } else { // certain code } Uptrendcount+=1; Downtrendcount+=1; } ...the continues relying on that at least are Uptrendcount=1 and Downtrendcount=1, but they're just 0....logically I got an array error outside of bounds
Thanks in advanceLast edited by pstrusi; 09-11-2017, 11:47 AM.Tags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Haiasi, 04-25-2024, 06:53 PM
|
2 responses
16 views
0 likes
|
Last Post
by Massinisa
Today, 05:32 AM
|
||
Started by Creamers, Today, 05:32 AM
|
0 responses
5 views
0 likes
|
Last Post
by Creamers
Today, 05:32 AM
|
||
Net Change
by Segwin
Started by Segwin, 05-07-2018, 02:15 PM
|
12 responses
1,786 views
0 likes
|
Last Post
by Leafcutter
Today, 05:30 AM
|
||
Started by poplagelu, Today, 05:00 AM
|
0 responses
3 views
0 likes
|
Last Post
by poplagelu
Today, 05:00 AM
|
||
Started by fx.practic, 10-15-2013, 12:53 AM
|
5 responses
5,407 views
0 likes
|
Last Post
by Bidder
Today, 12:22 AM
|
Leave a comment: