NexusFi: Find Your Edge


Home Menu

 





Possible to add 'DashStyleHelper' as enum for User Input?


Discussion in NinjaTrader

Updated
    1. trending_up 4,793 views
    2. thumb_up 3 thanks given
    3. group 2 followers
    1. forum 4 posts
    2. attach_file 1 attachments




 
Search this Thread
  #1 (permalink)
 
forrestang's Avatar
 forrestang 
Chicago IL
Legendary Urban Samurai
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
Posts: 1,345 since Jun 2010
Thanks Given: 357
Thanks Received: 1,060

Imagine you want to draw a line of the form:

 
Code
Draw.Line(this, "line", false, 10, High[10], 0, High[10], Brushes.Cyan, DashStyleHelper.Dot, 1);
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:
 
Code
		[NinjaScriptProperty]
		[XmlIgnore]
		[Display(Name="Some Color", Order=1, GroupName="1)MyColors")]
		public Brush MyColor
		{ get; set; }

		[Browsable(false)]
		public string MyColorSerializable
		{
			get { return Serialize.BrushToString(MyColor); }
			set { MyColor= Serialize.StringToBrush(value); }
		}


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Bookmap Global Plus Lifetime + Lifetime Addons For Sale
Platforms and Indicators
Kraken Becomes First US Digital Asset Bank With Direct F …
Cryptocurrency
Expiration Day: Wall Street Rallies on Peace Hopes While …
Prediction Markets & Event Contracts
Weekend Update: First Qatari LNG Transit Attempted -- IR …
Traders Hideout
Prop Firms Are Banning Gold Trading as Record Prices Mak …
Funded Trading Evaluation Firms
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
22 thanks
2026 Jlab journal
10 thanks
Trying to learn Volume and price action correlation
8 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Hello Im new here
5 thanks
  #2 (permalink)
 
trendisyourfriend's Avatar
 trendisyourfriend 
Quebec Canada
Legendary Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG
Trading: ES, NQ, YM
Frequency: Daily
Duration: Minutes
Posts: 4,580 since Oct 2009
Thanks Given: 4,266
Thanks Received: 6,199

You can with an enum and a switch. Example right here:
https://forum.ninjatrader.com/forum/ninjascript-educational-resources/reference-samples/3529-indicator-creating-a-user-defined-parameter-type-enum?t=3420


Reply With Quote
Thanked by:
  #3 (permalink)
 
forrestang's Avatar
 forrestang 
Chicago IL
Legendary Urban Samurai
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
Posts: 1,345 since Jun 2010
Thanks Given: 357
Thanks Received: 1,060


I just happened to stumble across an indie that did this the other day. So posting just in case someone else has such a need.

In the class level, can add:
 
Code
		private PlotStyle	myPlotStyle = PlotStyle.Line;
		private DashStyleHelper	myDashStyle  = DashStyleHelper.DashDot;



In the properties section for a user input:
 
Code
		[Display(ResourceType = typeof(Custom.Resource), Name = "", Description = "", GroupName = "Plot Parameters", Order = 0)]
		public PlotStyle MyPlotStyle				        
		{	
                         get { return myPlotStyle; }
                         set { myPlotStyle = value; }
		}
		
		[Display(ResourceType = typeof(Custom.Resource), Name = "", Description = "", GroupName = "Plot Parameters", Order = 1)]
		public DashStyleHelper MyDashStyle				        
		{
			get { return myDashStyle; }
			set { myDashStyle = value; }
		}

The dashstyleHelper can be used in methods such as Draw.Line() or other on-chart drawings.

Both of the above items can be used in standard plots, and configured in onStateChange() like:
 
Code
			else if (State == State.Configure)
			{
				Plots[0].PlotStyle = myPlotStyle;
				Plots[0].DashStyleHelper = myDashStyle;	
                        }


Started this thread Reply With Quote
Thanked by:
  #4 (permalink)
 
forrestang's Avatar
 forrestang 
Chicago IL
Legendary Urban Samurai
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
Posts: 1,345 since Jun 2010
Thanks Given: 357
Thanks Received: 1,060

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.

At the class level, you add:
 
Code
private SimpleFont myTextFont = new NinjaTrader.Gui.Tools.SimpleFont("Impact", 12);

In the properties section, you'd add:
 
Code
		[XmlIgnore]
		[Display(ResourceType = typeof(Custom.Resource), Name = "Text Type", Description = "", GroupName = "Text Control", Order = 0)]
		public SimpleFont MyTextFont
		{ 
			get {return myTextFont;}
			set {myTextFont = value;}
		}


2021-01-05_221512


Started this thread Reply With Quote
  #5 (permalink)
 
Fi's Avatar
 Fi 
NexusFi
 


forrestang View Post
I just happened to stumble across an indie that did this the other day. So posting just in case someone else has such a need.

@forrestang,

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:

 
Code
public Stroke MyStroke { get; set; }
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."


Learn more about Fi AI trading companion
IMPORTANT: I can make mistakes! Always verify data before relying on 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.
Reply With Quote




Last Updated on February 21, 2026


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts