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
Counting Renko Bars in a session.
Collapse
X
-
Counting Renko Bars in a session.
What is best way to count Renko bars in a session or multiple sessions? -
Hello GKonheiser,
Thank you for your post.
You will want to use something like this to get your session bars -
if(Bars.FirstBarOfSession)
int startBar = CurrentBar;
Print((CurrentBar - startBar));
There is also Bars.BarsSinceSession available as well.
http://www.ninjatrader.com/support/h...ncesession.htm
http://www.ninjatrader.com/support/h...rofsession.htmCal H.NinjaTrader Customer Service
-
-
Originally posted by NinjaTrader_Cal View PostGKonheiser,
You would want to use the Bars.FirstBarOfSession example that I provide and build your logic around that to track the different sessions and update your variables accordingly.
I’ve used ‘Bars.FirstBarOfSession’ quite a bit in my own coding, but there’s one thing I still don’t know how to do: and that is how to reference previous sessions (as per post #3) or just the previous session, etc.
Could you please be so kind as to give a brief indication of what methods and/or code are used to achieve this.
Thanks very much in advance.
Comment
-
Hello arbuthnot,
Thank you for your post.
You would need to manually track the count of bars in each in session. In the following example I use a list to store the value.
Code:#region Using declarations using System; using System.ComponentModel; using System.Diagnostics; using System.Drawing; using System.Drawing.Drawing2D; using System.Xml.Serialization; [B]using System.Collections;[/B] using NinjaTrader.Cbi; using NinjaTrader.Data; using NinjaTrader.Gui.Chart; #endregion namespace NinjaTrader.Indicator { public class MyTestIndicator1 : Indicator { #region Variables private ArrayList sesBarCount = new ArrayList(); private int prevCount = 0; #endregion protected override void Initialize() { } protected override void OnBarUpdate() { if(Bars.FirstBarOfSession) { Print(prevCount); sesBarCount.Add(CurrentBar - prevCount); Print(Convert.ToInt32(sesBarCount[sesBarCount.Count -1])); prevCount = CurrentBar; } } #region Properties #endregion }
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by r68cervera, Today, 05:29 AM
|
0 responses
2 views
0 likes
|
Last Post
by r68cervera
Today, 05:29 AM
|
||
Started by geddyisodin, Today, 05:20 AM
|
0 responses
3 views
0 likes
|
Last Post
by geddyisodin
Today, 05:20 AM
|
||
Started by JonesJoker, 04-22-2024, 12:23 PM
|
6 responses
33 views
0 likes
|
Last Post
by JonesJoker
Today, 05:14 AM
|
||
Started by GussJ, 03-04-2020, 03:11 PM
|
12 responses
3,239 views
0 likes
|
Last Post
by Leafcutter
Today, 05:08 AM
|
||
Hi
by AveryFlynn
Started by AveryFlynn, Today, 04:57 AM
|
0 responses
6 views
0 likes
|
Last Post
by AveryFlynn
Today, 04:57 AM
|
Comment