I'm trying to simplify an aspect of my trading by displaying a Range Bar Count in the top right of my Range chart that shows the Count of Range bars within the last 30mins (and 60mins) from the current bar.
Finding the Count
I've read through a number of functions, but can't seem to find a simple way to grab this count.
I figure I could cycle through all the bars going backwards from the current bar and check the time on each one, but this seems like excessive work for something so simple.
Anyone know an easy way to work this out?
Happy to just get it working as an OnBarUpdate() for the latest candle, but if possible I'd quite like it to work when scrolling the chart as well. So that, whenever you are looking back through the data, it always shows the count for 30min behind the currently displayed bar.
I've had a look at the OnRender() function for chart scrolling but not sure if this is appropriate due to all the warnings about not attempting to do too many calculations within the OnRender() call.
Help?
Display
In terms of display: I've sorted out the Text positioning with declaring these as Fonts:
private NinjaTrader.Gui.Tools.SimpleFont BTFont = new NinjaTrader.Gui.Tools.SimpleFont("Arial", 12) { Size = 30, Bold = false };
private NinjaTrader.Gui.Tools.SimpleFont BTSmallFont = new NinjaTrader.Gui.Tools.SimpleFont("Arial", 12) { Size = 20, Bold = false };
Then adding this to OnBarUpdate() (currently just using integers with preset values):
rangeString = "| " + int30minCount + " |";
range60String = int60minCount + "<padding spaces here - not shown in forums> .";
Draw.TextFixed(this, "30MinCount", rangeString, TextPosition.TopRight, myAlertBrush, BTFont, Brushes.Transparent, Brushes.Transparent, 0);
Draw.TextFixed(this, "60MinCount", range60String, TextPosition.TopRight, myAlertBrush, BTSmallFont, Brushes.Transparent , Brushes.Transparent, 0);
Which creates a large value (BTFont) closest to the right side, then some padding spaces to give a smaller number (BTSmallFont) which seems fine and produces this in the top right:
Although I'm curious if these is a simpler way to do this display as well.
Thanks to all, and sorry this is so long.
WeLoveTheLibrary
Comment