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
Historical Bars.TickCount
Collapse
X
-
Tags: None
-
Hello EC_Chris,
Thank you for your note.
There may be several ways to accomplish getting a tick count per 5 minute bar but one which comes to mind would be to add a secondary tick series to the strategy/indicator, then run the strategy with Calculate set to OnEachTick, and have a counter count each OnBarUpdate.
This counter would be increased by 1 on each OnBarUpdate, on each 5 minute bar. This would be a way to track the number of ticks per bar.
See the following example of adding an additional tick series
You can submit orders to different Bars objects. This allows you the flexibility of submitting orders to different timeframes. Like in live trading, taking entry conditions from a 5min chart means executing your order as soon as possible instead of waiting until the next 5min bar starts building. You can achieve this by
The concept, not tested, which I was suggesting might look something like this,
Code:Private int xCurrentBar=0; Private int counter=0; In OnBarUpdate, If(CurrentBars[0] >= xCurrentBar+1) { Counter=0; //Reset Counter on each new 5 minute bar. } else Counter++;
As far as existing indicators, I would suggest checking the following two links to our indicators section of the forum for NT7 and NT8,
Please let us know if you need further assistance.Last edited by NinjaTrader_AlanP; 03-22-2018, 12:54 PM.Alan P.NinjaTrader Customer Service
-
Hi Alan,
Thanks for your response. This is for an indicator not a strategy. I did see the strategy example and I couldn't get real far with it. Here is my code:
Code:else if(State == State.Configure) { AddDataSeries(Data.BarsPeriodType.Tick, 1); } } protected override void OnBarUpdate() { if (State == State.Historical) Value[0] = Bars.TickCount; else Value[0] = Bars.TickCount; }
I assume I need to get that historical state Value[0] to reference the add data series tick data, is that correct? I'm wondering if there are errors in this approach.
Thanks
Comment
-
Hello EC_Chris,
That error could come from no CurrentBar check. The following link will introduce you to current bar checks,
You may also want to check that what you are trying to set Value[0] is not null. The following link will go over checking for null references,
Adding prints to your script would be helpful. I’ve provided a link to a youtube video which covers an example of using prints to understand behavior:
Dive into manipulating C# code from within an unlocked NinjaScript strategy using the NinjaScript Editor.NinjaTrader 7 is an award winning end to end online ...
I’ve provided a link covering debugging which you may find helpful.
Debugging: http://ninjatrader.com/support/forum...ead.php?t=3418
If you’d like I could have someone from our business development team pass over a list of third party developers that you could contact about developing what your looking for.
Please let us know if you need further assistance.Alan P.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by chbruno, Today, 04:10 PM
|
0 responses
3 views
0 likes
|
Last Post
by chbruno
Today, 04:10 PM
|
||
Started by josh18955, 03-25-2023, 11:16 AM
|
6 responses
436 views
0 likes
|
Last Post
by Delerium
Today, 03:42 PM
|
||
Started by FAQtrader, Today, 03:35 PM
|
0 responses
6 views
0 likes
|
Last Post
by FAQtrader
Today, 03:35 PM
|
||
Started by rocketman7, Today, 09:41 AM
|
5 responses
19 views
0 likes
|
Last Post Today, 03:33 PM | ||
Started by frslvr, 04-11-2024, 07:26 AM
|
9 responses
127 views
1 like
|
Last Post
by caryc123
Today, 03:12 PM
|
Comment