First Hour Bar High Low Indicator - Code Review Request

What’s the best way to upload a code file here? The code is too long to block quote.

I’m new here and figuring out how to walk. Here is the file.

Github File:
https://github.com/EgoNoBueno/NinjaTrader8—Public/blob/main/FirstHourHLAdvanced

Hey, the code seems pretty comprehensive, much more so and better than I can do…But I question if this is your goal:

// Only shows lines for the current processed session day.

Why is there so much code dealing with previous tags and renaming of the tags, to check if old lines exist etc.

Simply not changing the name of the line tags, would ensure that only 1 line for high and 1 line for low would exist on the chart and then you only have to have logic for drawing the lines on the current day / firstbarofsession.

And I have a question, I noticed you are cleaning up drawings on State.Terminate, is this necessary? I’ve never known Draw.objects drawn in OnBarUpdate to remain on the chart after the indicator has been removed.

Also, if you want some additional ideas. I have a similar script and have these options:

  • The option to add text to the line, along with the Value of the High / Low. “1 Hour High: XXX” for example. I have options for the positioning of the text relative to the lines.
  • The option to draw the lines in real time, as well as at the end.
  • The option to set the opacity of the line.
  • The option to set the DashStyle of the line.

You can add individual properties for these ofcourse (Opacity requires a custom brush) BUT…better, you add a stroke class for each line and you will get all the options for the line with 1 Ninjascript Property. HighLineStyle = new Stroke(), then you can use HighLineStyle.Width, HighlineStyle.Opacity etc)

https://ninjatrader.com/support/helpguides/nt8/NT%20HelpGuide%20English.html?stroke_class.htm

Also, perhaps you didn’t consider this if the indicator is only for personal use BUT your use of an additional 60 minute data series is quite limiting. You could consider:

  • Giving the user the option to choose whether to use the first 60m, 30m, 20m, 15m etc candle…and then load the relevant secondary data series based on their choice in State.Configure. I think you can do this without changing your code at all.

Or for more flexibility:

  • Add a 1 minute data series instead and in parameters you have a user defied end time as well as the start time.
1 Like

Thanks @several for your response.

This code was produced by Gemini AI 2.5 Pro. I always request in my AI engineered prompt to use best known practices. In my GitHub I have produced myself some coding guides which anyone is welcome to download and kick the tires on. I can’t guarantee they are worth anything, but it is what I am using to get grounded in this environment. https://github.com/EgoNoBueno/NinjaTrader8—Public

My go to document right now is Ninjascript development with GitHub Tools. Take a look at it and, I’d be grateful for suggestions.

I coded the indicator to comply with some training I received at TradeDevils.

Currently I am cosying up to Visual Studio, and using Copilot for code development.

I’ll take a look at the resources you provided, and I thank you for pointing me to them. I will take a close look at all your suggestions. I agree more flexibility for time choices is very much needed.

Thank you!

1 Like