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
MTF in an Indicator
Collapse
X
-
MTF in an Indicator
MTF support was limited to only strategies in NT 6. Now in NT 7 you added MTF support on charts by using the Data Series. Can we know write indicators that support MTF. If the answer is yes then I assume that one has to follow the same conventions that applied to MTF support in Strategies for NT 6.Tags: None
-
Austin,
I am trying to build a barebones MTF indicator and I am not getting any output on application to a historical data chart built on other rangebar period, but it does compile correctly ...
Code:[FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff] #region[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][COLOR=#000000] Using declarations[/COLOR] [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]using[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][COLOR=#000000] System;[/COLOR] [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]using[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][COLOR=#000000] System.Diagnostics;[/COLOR] [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]using[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][COLOR=#000000] System.Drawing;[/COLOR] [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]using[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][COLOR=#000000] System.Drawing.Drawing2D;[/COLOR] [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]using[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][COLOR=#000000] System.ComponentModel;[/COLOR] [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]using[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][COLOR=#000000] System.Xml.Serialization;[/COLOR] [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]using[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][COLOR=#000000] NinjaTrader.Data;[/COLOR] [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]using[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][COLOR=#000000] NinjaTrader.Gui.Chart;[/COLOR] [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]#endregion [/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][/FONT][FONT=Arial][COLOR=#008000][FONT=Arial][COLOR=#008000]// This namespace holds all indicators and is required. Do not change it. [/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]namespace[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][COLOR=#000000] NinjaTrader.Indicator[/COLOR] { [/FONT][FONT=Arial][COLOR=#808080][FONT=Arial][COLOR=#808080]///[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][COLOR=#008000][FONT=Arial][COLOR=#008000] [/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][COLOR=#808080][FONT=Arial][COLOR=#808080]<summary> [/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][/FONT][FONT=Arial][COLOR=#808080][FONT=Arial][COLOR=#808080]///[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][COLOR=#008000][FONT=Arial][COLOR=#008000] (R5Low) is the 5 Range LOW [/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][/FONT][FONT=Arial][COLOR=#808080][FONT=Arial][COLOR=#808080]///[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][COLOR=#008000][FONT=Arial][COLOR=#008000] [/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][COLOR=#808080][FONT=Arial][COLOR=#808080]</summary> [/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][Description([/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]"The R5Low is a framework to have 5Range OHLC available in trading systems as DATA."[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial])] [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]public[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]class[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] R5Low : Indicator { [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]#region[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] Variables [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]private[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]int[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] thePeriod = [/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]5[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]; [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]public[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] DataSeries sR5Lo; [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]#endregion [/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]protected[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]override[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]void[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] Initialize() { Add(PeriodType.Range, [/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]5[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]); [/FONT][FONT=Arial][COLOR=#008000][FONT=Arial][COLOR=#008000]// BarsInProgress index = 1 [/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]Add([/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]new[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] Plot(Color.Green, [/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]"R5Low"[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial])); sR5Lo = [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]new[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] DataSeries([/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]this[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]); } [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]protected[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]override[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]void[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] OnBarUpdate() { [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]if[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] (BarsInProgress == [/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]1[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]) [/FONT][FONT=Arial][COLOR=#008000][FONT=Arial][COLOR=#008000]//Range bars [/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]{ [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]if[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] (CurrentBars[[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]1[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]] >= [/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]) sR5Lo.Set(Lows[[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]1[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]][[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]]); } } [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]#region[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] Properties [Description([/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]"Numbers of bars used for calculations"[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial])] [GridCategory([/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]"Parameters"[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial])] [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]public[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]int[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] ThePeriod { [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]get[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] { [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]return[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] thePeriod; } [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]set[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] { thePeriod = value; } } [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]#endregion [/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]} }[/FONT]
anything jump out as a newbie goof/ways to fix it? This was built by hand not in the wizard
Thanks,
Jon
Comment
-
Hi Jon,
There is likely an exception raised if you check log tab of control center. This line is good for most multi series, but you don't want to place it within a BIP - Just at the top of OnBarUpdate(). This will help prevent NinjaTrader from trying to access bar objects if they don't exist.
if (CurrentBar < 0 || CurrentBars[1] < 0)
return;Ryan M.NinjaTrader Customer Service
Comment
-
Ryan,
DataSeries still does not exist in context, but there are no errors in the log tab.
I tried again rewritten, the Prints print everything requested but not the dataseries values: parts omit to fitCode:[FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#008000] [/COLOR][/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]namespace[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][COLOR=#000000] NinjaTrader.Indicator[/COLOR][/FONT] [FONT=Arial]{[/FONT] [FONT=Arial][COLOR=#808080][/COLOR][/FONT][FONT=Arial][Description([/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]"The R5Close is a framework to have Range5 Close available in trading systems as DATA."[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial])][/FONT] [FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]public[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]class[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] R5Close : Indicator[/FONT] [FONT=Arial]{[/FONT] [FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]private[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]int[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] thePeriod = [/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]5[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial];[/FONT] [FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]private[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] DataSeries sR5Cl;[/FONT] [FONT=Arial][COLOR=#0000ff][/COLOR][/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]protected[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]override[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]void[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] Initialize()[/FONT] [FONT=Arial]{[/FONT] [FONT=Arial]Add(PeriodType.Range, thePeriod); [/FONT][FONT=Arial][COLOR=#008000][FONT=Arial][COLOR=#008000]// BarsInProgress index = 1[/COLOR][/FONT] [/COLOR][/FONT][FONT=Arial]Add([/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]new[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] Plot(Color.Green, [/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]"R5Close"[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]));[/FONT] [FONT=Arial]Plots[[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]].Pen.DashStyle = DashStyle.Dot;[/FONT] [FONT=Arial]sR5Cl = [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]new[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] DataSeries([/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]this[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]);[/FONT][FONT=Arial][COLOR=#008000] [/COLOR][/FONT][FONT=Arial]CalculateOnBarClose = [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]true[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial];[/FONT] [FONT=Arial]DisplayInDataBox = [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]true[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial];[/FONT] [FONT=Arial]Overlay = [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]true[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]; [/FONT] [FONT=Arial]PaintPriceMarkers = [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]true[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial];[/FONT] [FONT=Arial]}[/FONT] [FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]protected[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]override[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]void[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] OnBarUpdate()[/FONT] [FONT=Arial]{ [/FONT] [FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]if[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] (CurrentBar < [/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] || CurrentBars[[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]1[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]] < [/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial])[/FONT] [FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]return[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]; [/FONT] [FONT=Arial]{[/FONT] [FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]if[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] (BarsInProgress == [/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]) [/FONT][FONT=Arial][COLOR=#008000][FONT=Arial][COLOR=#008000]//[/COLOR][/FONT] [/COLOR][/FONT][FONT=Arial]{[/FONT] [FONT=Arial]Print([/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]"Value of 00 close = "[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]+Closes[[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]][[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]]+[/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]", CurrentBar0#="[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]+CurrentBars[[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]]+[/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]"Time of bar="[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]+Time[[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]]+[/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]", CurrentBar1#="[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]+CurrentBars[[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]1[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]]);[/FONT] [FONT=Arial]}[/FONT] [FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]if[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] (BarsInProgress == [/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]1[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]) [/FONT][FONT=Arial][COLOR=#008000][FONT=Arial][COLOR=#008000]//[/COLOR][/FONT] [/COLOR][/FONT][FONT=Arial]{[/FONT] [FONT=Arial]sR5Cl.Set(Close[[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]]); [/FONT] [FONT=Arial][COLOR=#008000][FONT=Arial][COLOR=#008000]// sR5Cl.Set(Closes[0][0]); has the same problem [/COLOR][/FONT] [/COLOR][/FONT][FONT=Arial]Print([/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]"Value of R5 close = "[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]+Closes[[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]1[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]][[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]]+[/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]", CurrentBar1#="[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]+CurrentBars[[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]1[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]]+[/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]"Time of bar="[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]+Time[[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]]+[/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]", bar0 closed "[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]+Closes[[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]][[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]]+[/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]", Bar0HI="[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]+Highs[[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]][[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]]+[/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]", Bar0LO="[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]+Lows[[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]][[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]]+[/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]", CurrentBar00#="[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]+CurrentBars[[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]]);[/FONT] [FONT=Arial]Print([/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]"Value of R5CI = "[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]+sR5CI[[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]]);[/FONT] [FONT=Arial]}[/FONT] [FONT=Arial]}[/FONT] [FONT=Arial]}[/FONT] [FONT=Arial][Description([/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]"Numbers of bars used for calculations"[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial])][/FONT] [FONT=Arial][GridCategory([/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]"Parameters"[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial])][/FONT] [FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]public[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]int[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] ThePeriod[/FONT] [FONT=Arial]{[/FONT] [FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]get[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] { [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]return[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] thePeriod; }[/FONT] [FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]set[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] { thePeriod = value; }[/FONT] [FONT=Arial]}[/FONT][FONT=Arial][COLOR=#0000ff] [/COLOR][/FONT][FONT=Arial]}[/FONT] [FONT=Arial]}[/FONT] [/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]}[/FONT]
Comment
-
almost fixed
Looks like the DataSeries name has to be a minimum length. AFAIK thats what was causing the compile error. Still have 1 issue ... data from the Dataseries prints out but doesnt plot or show in the DataBox ... ???!!!!
Code:[FONT=Arial] [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]public[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]class[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] R5Close : Indicator { [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]private[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]int[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] thePeriod = [/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]5[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]; [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]public[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] DataSeries sRange5Closes; [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]protected[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]override[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]void[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] Initialize() { Add( PeriodType.Range, thePeriod); Add([/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]new[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] Plot([/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]new[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] Pen (Color.FromKnownColor(KnownColor.ForestGreen), [/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]3[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]), PlotStyle.Line, [/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]"sRange5Closes"[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial])); Plots[[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]].Pen.DashStyle = DashStyle.Solid; sRange5Closes = [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]new[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] DataSeries ([/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]this[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]); [/FONT][FONT=Arial][COLOR=#008000][FONT=Arial][COLOR=#008000]// [/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]CalculateOnBarClose = [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]true[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]; DisplayInDataBox = [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]true[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]; Overlay = [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]true[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]; } [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]protected[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]override[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]void[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] OnBarUpdate() { [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]if[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] (CurrentBar < [/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] || CurrentBars[[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]1[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]] < [/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]) [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]return[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]; { [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]if[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] (BarsInProgress == [/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]) { Print([/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]"BIP=0 close = "[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]+Closes[[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]][[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]]+[/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]", CurrentBar0#="[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]+CurrentBars[[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]]+[/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]"Time of bar0="[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]+Times[[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]][[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]]+[/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]", Bar0HI="[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]+Highs[[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]][[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]]+[/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]", Bar0LO="[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]+Lows[[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]][[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]]); } [/FONT][FONT=Arial][COLOR=#008000][FONT=Arial][COLOR=#008000]// [/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]if[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] (BarsInProgress == [/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]1[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]) { sRange5Closes.Set(Closes[[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]1[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]][[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]]); Print([/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]"BIP=1 close = "[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]+Closes[[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]1[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]][[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]]+[/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]", CurrentBar1#="[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]+CurrentBars[[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]1[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]]+[/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]"Time of bar1="[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]+Times[[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]1[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]][[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]]+[/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]", Bar1HI="[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]+Highs[[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]1[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]][[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]]+[/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]", Bar1LO="[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]+Lows[[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]1[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]][[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]]); Print([/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]"Range5Close= "[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]+sRange5Closes[[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]]); } } } [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]#region[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] Properties [/FONT][FONT=Arial][COLOR=#008000][FONT=Arial][COLOR=#008000]// [/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][Description([/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]"Numbers of bars used for calculations"[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial])] [GridCategory([/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]"Parameters"[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial])] [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]public[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]int[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] ThePeriod { [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]get[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] { [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]return[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] thePeriod; } [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]set[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] { thePeriod = value; } } [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]#endregion [/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]} }[/FONT]
Comment
-
Try this.
Remove these 2 lines:
public DataSeries sRange5Closes;
sRange5Closes = new DataSeries (this);
Add this code under the Properties region:
#region Properties
[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public DataSeries sRange5Closes
{
get { return Values[0]; }
}
Look up the definition of Values. This is a collection holding object that hold the indicator's underlying calculated values. For every Add() there will be an associated Values[] collection.
Hope this helps.
Comment
-
Thanks, scjohn.
DataSeries will not automatically plot or show up in data box. They have to be tied to a specific Values[ ] collection in order to plot, and also need the add statement in Initialize(). The structure of plots is setup for you when you create an indicator through the indicator wizard. You can do this and won't have to create data series separately. You can set using the plot name defined when you create through the indicators wizard.Ryan M.NinjaTrader Customer Service
Comment
-
scjohn,
Thanks very much for the code sample! It fit perfectly.
Ryan,
Thanks for the explicit information. It is what I needed to understand this!
I had actually tried the 'value' fix, but had not removed both instances of the DataSeries code to make it work .. head is now on straight again.
Jon
Comment
-
Inconsistency when Moving from Historical to Real-Time Data
I have coded a multi time frame indicator and stumbled upon an inconsistency in the bars logic. I will try to explain what it is.
I understand that NinjaTrader's bars logic is event driven and that there are historical and real-time bars, which show a different behavior. The problem that I detected comes at the intersection of historical and real-time data.
The indicator uses a primary bar series from the chart (BarSeries 0), and has a second bar series (BarSeries 1) added in the initialize section. For the first real-time bar, there are two case that I observed
(A) most common: NinjaTrader builds a hybrid bar from historical and real-time data
(B) sometimes: NinjaTrader starts a new real-time bar after a complete historical bar
This is as expected. Now let us look what happens to the second bar series (Bar Series 1) in both cases:
(A) OnBarUpdate inserts a BarsInProgress==1 loop at the end of the Historical part, which catches the ticks from the DataSeries 0 and inserts them into the developping bar of BarSeries 1. The last loop executed in Historical mode is (BarsInProgress ==1).
Now the inconsistency comes, when there is no hybrid bar, but real-time data starts with the FirstTick of a bar of BarSeries 0. Two cases can be observed:
(B1) OnBarUpdate inserts a BarsInProgress==1 loop at the end of the Historical part, as for (A) above.
(B2) OnBariUpdate inserts a BarsInProgress==1 loop after the FirstTick of the first real-time bar of BarSeries 0.
The case B2 is not as expected, because it creates a FirstTickOfBar of the BarSeries 1 in the middle of that first real-time bar of the BarSeries 0. So I had to code around it, to avoid false results.
This behaviour is in my opinion inconsistent and points to a bug.
Comment
-
Unfortunately I am not quite following you Harry. Instead of discussing in generalities, let us work off an exact example so we can sync up on the exact scenario you are referring to. Are you talking tick bars? Minute bars? Mix of tick and minute? Same instrument? Which is the larger series, primary or secondary?
Not sure I follow why you feel B2 is wrong in theory? Bars 0 and 1 do not have any relation to each other and can update depending on whichever series gets called. There is no forced sequence of 0 is before 1 or 1 is before 0 in real-time.Josh P.NinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_Josh View PostUnfortunately I am not quite following you Harry. Instead of discussing in generalities, let us work off an exact example so we can sync up on the exact scenario you are referring to. Are you talking tick bars? Minute bars? Mix of tick and minute? Same instrument? Which is the larger series, primary or secondary?
Not sure I follow why you feel B2 is wrong in theory? Bars 0 and 1 do not have any relation to each other and can update depending on whichever series gets called. There is no forced sequence of 0 is before 1 or 1 is before 0 in real-time.
1st BarSeries : 6E 5-tick (chart series)
2nd BarSeries: 6E 1-min (added by indicator, not visible)
Everything is fine for historical and real-time data:
Historical data
Bars are mostly alternating and rarely have a common time-stamp. If they have the same time-stamp BarSeries 0 (chart bars) is called first, the added series is called second.
Real-Time data
Each incoming tick (event) triggers first an OnBarUpdate loop for BarSeries 0, then another loop for BarSeries 1 (BarsInProgress==1).
Problem occurs in the way NinjaTrader organizes the loops for the first real-time bar for BarSeries 0. It usually creates an additional (phantom) FirstTickofBar for the BarSeries 1 prior to the first real-time tick, which in turn triggers BarSeries 0.
But sometimes this FirstTickOfBar for the BarSeries 1 - although there is already sufficient data for the current bar prior to the first real-time tick - is erroneously triggered in the middle of the first real-time bar of BarSeries 0.
To be precise: The historical FirstTickOfBar of BarSeries 1 is only injected after NinjaTrader has switched to non-Historical, and after the first run of the non-Historical OnBarUpdate for BarSeries 0. The historical tick is delayed and creates a false FirstTickOfBar event for BarSeries 1, when it should not happen.
Below is a chart showing the problem. I have also added a second BarSeries to the chart to make the BarSeries added by the indicator visible (in gray). The chart also shows the EMA generated from the BarSeries added via chart (blue reference EMA) and the EMA generated from the BarSeries added to the indicator (red multi time frame EMA). They are both as expected, as the code tries to work around the bug.Last edited by Harry; 03-10-2011, 04:46 PM.
Comment
-
Harry,
First, please consider the following:
- Tick bars and minute bars do not need to start/end in conjunction with each other. For instance, a tick bar could be in the middle of building while the minute bar would end or just begin a new one. You could be in tick #3 of a 5 tick bar and have the minute bar for that tick bar close on tick #4.
With that being said let us examine the exact scenario you are describing. You are describing a scenario where the switch to real-time coincides with the first tick of a new primary bars (5 ticks), but NOT a new secondary bars (1 min).
I will use the following code to evaluate:
Print(Historical + " " + Time[0] + " " + BarsInProgress + " " + FirstTickOfBar);
Code:True 3/10/2011 3:57:14 PM 0 True True 3/10/2011 3:57:16 PM 0 True True 3/10/2011 3:58:00 PM 1 True [COLOR=Red][B]False 3/10/2011 3:57:17 PM 0 True False 3/10/2011 3:58:00 PM 1 False[/B][/COLOR] False 3/10/2011 3:57:17 PM 0 False False 3/10/2011 3:58:00 PM 1 False ... False 3/10/2011 3:57:59 PM 0 False False 3/10/2011 3:58:00 PM 1 False False 3/10/2011 3:57:59 PM 0 False False 3/10/2011 3:58:00 PM 0 True False 3/10/2011 3:59:00 PM 1 True
Please see the first screenshot illustrating the exact scenario. The boxes represent the min bars displayed in a Box style. At 3:57:17 is when we switched to real-time along with the building of a brand new 5-tick primary bar. The 3:58 bar which was being built historically earlier is now being built hybrid with part historical and part real-time. The output shown earlier proves no such FirstTickOfBar event was ever pushed when in a hybrid minute bar construction.
Second screenshot shows relatively the same thing. Big boxes are the 1min series behind the 5-tick series.Josh P.NinjaTrader Customer Service
Comment
-
Hi Josh,
thank you for your detailed answer, much appreciated!
Originally posted by NinjaTrader_Josh View Post- Tick bars and minute bars do not need to start/end in conjunction with each other. For instance, a tick bar could be in the middle of building while the minute bar would end or just begin a new one. You could be in tick #3 of a 5 tick bar and have the minute bar for that tick bar close on tick #4.
Originally posted by NinjaTrader_Josh View PostWith that being said let us examine the exact scenario you are describing. You are describing a scenario where the switch to real-time coincides with the first tick of a new primary bars (5 ticks), but NOT a new secondary bars (1 min).
Originally posted by NinjaTrader_Josh View PostI will use the following code to evaluate:
Print(Historical + " " + Time[0] + " " + BarsInProgress + " " + FirstTickOfBar);
Originally posted by NinjaTrader_Josh View PostYou can see above I managed to capture the exact scenario you are describing. When the script goes to real-time is the exact same time that the primary bars is building a new one. The secondary bars are not building a new one, but continuing on a previously built one. You can then see the event thrown for that first real-time tick does NOT trigger a FirstTickOfBar = true on the secondary series.
Originally posted by NinjaTrader_Josh View PostPlease see the first screenshot illustrating the exact scenario. The boxes represent the min bars displayed in a Box style. At 3:57:17 is when we switched to real-time along with the building of a brand new 5-tick primary bar. The 3:58 bar which was being built historically earlier is now being built hybrid with part historical and part real-time. The output shown earlier proves no such FirstTickOfBar event was ever pushed when in a hybrid minute bar construction.
Second screenshot shows relatively the same thing. Big boxes are the 1min series behind the 5-tick series.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by mly916, Today, 09:48 PM
|
0 responses
6 views
0 likes
|
Last Post
by mly916
Today, 09:48 PM
|
||
Started by Mikey_, Today, 09:21 PM
|
0 responses
10 views
0 likes
|
Last Post
by Mikey_
Today, 09:21 PM
|
||
Started by cre8able, Today, 05:53 PM
|
3 responses
13 views
0 likes
|
Last Post
by cre8able
Today, 09:20 PM
|
||
Started by Aryan Kumar, Today, 09:04 PM
|
0 responses
4 views
0 likes
|
Last Post
by Aryan Kumar
Today, 09:04 PM
|
||
Started by yertle, Yesterday, 05:49 PM
|
3 responses
16 views
0 likes
|
Last Post
by Mindset
Today, 08:38 PM
|
Comment