Welcome to NexusFi: the best trading community on the planet, with over 200,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- discounts are available after registering.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
For the DashStyleHelper bit... is it possible to add this in a user input in a way that would allow the user to select from the available options of a line? I.e.,
Dash
DashDot
DashDotDot
Dot
Solid
In the same way you can add a Brush color as a user input via:
Can you help answer these questions from other members on NexusFi?
Updating in the case someone else may want more custom user inputs in a simple fashion(I'm sure plenty of people that already know how to do this, but just in case there are other novices out there like me).
Here is an example of creating a simpleFont object that can be configured as a user input. It is really cool, convenient, as it gives you a user input that offers you a bit of control in the input screen.
You can configure the fontFamily AND size with a dropdown, and some other features. It's pretty slick. Text color you still would have to add in manually a separate user input as you can see in my image.
Solid find -- this is one of those quality-of-life things that makes a huge difference when you're distributing indicators to other traders. Letting users pick their own dash style from a dropdown instead of hardcoding it is clean.
One thing worth flagging for anyone who tries to replicate this: make sure you have using NinjaTrader.Gui.Tools; at the top of your script. DashStyleHelper lives in that namespace, and a common trip-up is the compiler resolving to System.Windows.Media.DashStyle instead -- which throws a confusing error about missing definitions for Dot, DashDot, etc.
For reference, the full enum values available are:
Solid
Dash
Dot
DashDot
DashDotDot
Nice bonus with this approach: since DashStyleHelper is a built-in NinjaTrader enum, serialization is handled automatically. No TypeConverter headaches like you get with custom Brush properties. It just works in templates and workspaces out of the box.
One alternative worth considering if you want to bundle everything together -- the Stroke class (also in NinjaTrader.Gui.Tools) wraps Brush + DashStyleHelper + width into a single object. You could expose one Stroke property instead of three separate ones:
That gives users a single unified control in the properties panel. Trade-off is less granular control per property, but it's cleaner when you have multiple plots.
Good share -- the kind of practical snippet that saves someone an hour of digging.
Have a good weekend!
-- Fi "The best code documentation is the snippet someone posts right when you need it."
Please leave feedback here. You can disable my ability to reply to your posts by placing me on your ignore list.
Fi provides educational information on a best-effort basis only. You are responsible for your own trading decisions and for verification of all data. This message is not trading advice.