Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Serializing DashStyleHelper
Collapse
X
-
Originally posted by kenz987 View PostCan it be done? Like saving Brushes to keep your default color?
Thank you for your post.
DashStyleHelper is an enum value, so it should be serialized natively. It is not a type of object, such as TimeSpan or Brush, that requires the [XmlIgnore] attribute for serialization. To demonstrate, I have modified the SampleBrushInput script to include a DashStyleHelper user input that is used to draw a horizontal line. No additional serialization steps are needed for this to work properly, as seen in the properties region.
Please let me know if I may be of further assistance.Attached FilesEmily C.NinjaTrader Customer Service
Comment
-
-
Originally posted by kenz987 View PostOK another question. How do I get the index like "Solid" = 0 etc from an existing Draw.Line, I cant use DrawStyle[0] ??
Thank you for your reply.
What are you looking to achieve after getting an index for the dashStyle value from a Line object? You may access the value for DashStyleHelper from the draw object's Stroke as shown in the following snippet:
Code:private NinjaTrader.NinjaScript.DrawingTools.Line myLine; protected override void OnBarUpdate() { if (CurrentBar < 10) return; myLine = Draw.Line(this, "tag", true, 5, Low[5] - 5 * TickSize, 0, High[0] + 5 * TickSize, Brushes.Blue, DashStyleHelper.Dot, 5); Print("myLine dashStyle: " + myLine.Stroke.DashStyleHelper); }
The output shows as:
myLine dashStyle: DotEmily C.NinjaTrader Customer Service
Comment
-
-
Hello kenz987,
Thank you for your patience.
Typecasting, which bltdavid has referred to, is a general C# concept and is not specific to NinjaTrader. We do not provide C# programming education services or one on one educational support in the NinjaScript department, so you will need to do outside research to learn more about how it works. That said, I have added to the previously modified sample to show how an int could be used to get a DashStyleHelper enum selection via typecasting and draw another horizontal line. You may test out this sample to try and get a better understanding or to achieve what you desire by converting an int into a DashStyleHelper selection. Here is the sample:
Code:private int myInt; protected override void OnStateChange() { else if (State == State.DataLoaded) { myInt = 4; } } protected override void OnBarUpdate() { if(CurrentBar < 5) return; // Use our two user definable brush inputs for the colors of our rectangle. Draw.Rectangle(this, "CustomColorsRectangle", true, 0, High[0], 5, Low[5], BorderBrush, FillBrush, 50); Draw.HorizontalLine(this, "tag", Close[0], BorderBrush, DashStyleSelection, 5); // casting an int to an enum to get a DashStyleHelper dashStyle from myInt DashStyleHelper style = (DashStyleHelper)myInt; // draw a magenta horizontal line above the current bar's high price using the "style" we just created Draw.HorizontalLine(this, "Tag", High[0] + 5 * TickSize, Brushes.Magenta, style, 5); }
It is also important to note that typecasting works differently outside of a compiled assembly vs. inside of a compiled assembly. For more information, please see the following help guide page:
If you require additional assistance, you could also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our NinjaTrader Ecosystem team to follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request or provide one on one educational services.
Thank you for your time and patience.Emily C.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by ZenCortexCLICK, Today, 04:58 AM
|
0 responses
2 views
0 likes
|
Last Post Today, 04:58 AM | ||
Started by sidlercom80, 10-28-2023, 08:49 AM
|
172 responses
2,280 views
0 likes
|
Last Post
by sidlercom80
Today, 04:40 AM
|
||
Started by Irukandji, Yesterday, 02:53 AM
|
2 responses
17 views
0 likes
|
Last Post
by Irukandji
Today, 03:55 AM
|
||
Started by adeelshahzad, Today, 03:54 AM
|
0 responses
4 views
0 likes
|
Last Post
by adeelshahzad
Today, 03:54 AM
|
||
Started by Barry Milan, Yesterday, 10:35 PM
|
3 responses
13 views
0 likes
|
Last Post Yesterday, 11:58 PM |
Comment