NexusFi: Find Your Edge


Home Menu

 





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


Discussion in NinjaTrader

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




 
Search this Thread

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

  #1 (permalink)
 
forrestang's Avatar
 forrestang 
Chicago IL
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
Posts: 1,333 since Jun 2010
Thanks Given: 354
Thanks Received: 1,049

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?
Quantum physics & Trading dynamics
The Elite Circle
Strategy stop orders partially filled
EasyLanguage Programming
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Cheap historycal L1 data for stocks
Stocks and ETFs
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Funded Trader platforms
49 thanks
Just another trading journal: PA, Wyckoff & Trends
21 thanks
Trading with Intuition
18 thanks
Self sabotage reframed
15 thanks
GFIs1 1 DAX trade per day journal
9 thanks
  #2 (permalink)
 
trendisyourfriend's Avatar
 trendisyourfriend 
Quebec Canada
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG
Trading: ES, NQ, YM
Frequency: Daily
Duration: Minutes
Posts: 4,527 since Oct 2009
Thanks Given: 4,177
Thanks Received: 6,022

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
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
Posts: 1,333 since Jun 2010
Thanks Given: 354
Thanks Received: 1,049


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
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
Posts: 1,333 since Jun 2010
Thanks Given: 354
Thanks Received: 1,049

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




Last Updated on January 5, 2021


© 2024 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 - Privacy Policy - Downloads - Top
no new posts