Has anyone else experienced this? I am using multiple time frames for an indicator to track volume changes which is why I have noticed this since the volume counts are not reseting.
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
Odd behavior with FirstTickOfBar
Collapse
X
-
Odd behavior with FirstTickOfBar
I am occasionally finding the FirstTickOfBar will not fire true after running for a while.
Has anyone else experienced this? I am using multiple time frames for an indicator to track volume changes which is why I have noticed this since the volume counts are not reseting.Tags: None
-
here is a stripped down version.
/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
Overlay = false;
Add(PeriodType.Minute, 2);
Add(PeriodType.Minute, 3);
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
Plot0.Set(Close[0]);
if (CurrentBar==0) return;
if (FirstTickOfBar) {
Print(Label + "Time:" + Time[1] + ", Total Volume:" + Volume[1]);
if (BarsInProgress == 0) {
askVolume = 0;
bidVolume = 0;
}
hasTime=false;
} else {
if (BarsInProgress == 0) {
if (!hasTime) { Print(Label + "Time:" + Time[0]); hasTime=true; };
Print(" Volume:" + (Volume[0] - lastVolume));
}
}
if (BarsInProgress == 0) {
lastVolume = Volume[0];
}
}
Comment
-
It may be IB - could their data cause it to act strange?Last edited by MarketAlly; 12-31-2013, 01:23 PM.
Comment
-
Thank you for this. One thing to be aware of is that FirstTickOfBar is only intended to be used when CalculateOnBarClose = false.
Otherwise all calculations will be performed on the closing tick.
Once you have this if the issue persists please let me know the output your getting that appears incorrect.
Let me know how I can further assist.LanceNinjaTrader Customer Service
Comment
-
Originally posted by MarketAlly View Posthere is a stripped down version.
/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
Overlay = false;
Add(PeriodType.Minute, 2);
Add(PeriodType.Minute, 3);
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
Plot0.Set(Close[0]);
if (CurrentBar==0) return;
if (FirstTickOfBar) {
Print(Label + "Time:" + Time[1] + ", Total Volume:" + Volume[1]);
if (BarsInProgress == 0) {
askVolume = 0;
bidVolume = 0;
}
hasTime=false;
} else {
if (BarsInProgress == 0) {
if (!hasTime) { Print(Label + "Time:" + Time[0]); hasTime=true; };
Print(" Volume:" + (Volume[0] - lastVolume));
}
}
if (BarsInProgress == 0) {
lastVolume = Volume[0];
}
}
Comment
-
No - I left that out unless the indicator gets to choose when to obey the setting on the indicator properties window? It works for a while then stops triggering the FirstTickOfBar.
Comment
-
The output is the following until the FirstTickOfBar stops being set:
1 min - Time:12/31/2013 11:41:00 AM, Total Volume:884
2 min - Time:12/31/2013 11:40:00 AM, Total Volume:2028
3 min - Time:12/31/2013 11:39:00 AM, Total Volume:1405
Time:12/31/2013 11:47:00 AM <-- at every tick
Volume:21 <-- at every tick
then it simply keeps printing:
Volume:# <-- at every tick
if the FirstTickOfBar stops being set to true - then it will continuously print
Volume:# <-- at every tick
otherwise every minute it should print:
1 min - Time:12/31/2013 11:47:00 AM, Total Volume:#
with a few more at the 2 and 3 minute mark.
Comment
-
With the way your code is stuctured I would expect it to print every single tick update.
The reason for this is that you have print statements outside the conditional check.
Consider moving your if(FirstTickOfBar) braces to encompass your BarsInProgress logic too, if this is your goal.
Let me know if I can further assist.LanceNinjaTrader Customer Service
Comment
-
That is not my goal Lance... if you run the code, you will see how it will (hopefully) stop working. It worked for 90 minutes before stopping the first time and then after 40 minutes. I am unsure what would cause it to be intermittent.
I am not seeking assistance in what the output is - only why the FirstTickOfBar stopped being triggered.
Comment
-
here is the missing Label variable.
string Label = "";
if (BarsInProgress == 0) {
Label = "1 min - ";
lastVolume = 0;
} else if (BarsInProgress == 1) {
Label = "2 min - ";
} else {
Label = "3 min - ";
}
Comment
-
In this case could you please provide me with the following.
1. Please attach complete script source file located in (MY)Documents\NinjaTrader 7\bin\Custom\Indicator
2. Instrument to test on
3. any custom input settings
4. time of day (and timezone) when you saw the issue.
Look forward to assisting you further.LanceNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Kaledus, Today, 01:29 PM
|
0 responses
3 views
0 likes
|
Last Post
by Kaledus
Today, 01:29 PM
|
||
Started by PaulMohn, Today, 12:36 PM
|
1 response
16 views
0 likes
|
Last Post Today, 01:23 PM | ||
Started by yertle, Yesterday, 08:38 AM
|
8 responses
37 views
0 likes
|
Last Post
by ryjoga
Today, 01:22 PM
|
||
Started by rdtdale, Today, 01:02 PM
|
1 response
6 views
0 likes
|
Last Post Today, 01:13 PM | ||
Started by alifarahani, Today, 09:40 AM
|
3 responses
19 views
0 likes
|
Last Post Today, 12:47 PM |
Comment