You gave us NinjaTrader.Gui.Design.SerializableFont in NT7. What is the method to serialize SimpleFont in NT8?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
How to Serialize SimpleFont?
Collapse
X
-
From the references, SampleFontChangeOriginally posted by koganam View PostYou have replaced Font with SimpleFont?
You gave us NinjaTrader.Gui.Design.SerializableFont in NT7. What is the method to serialize SimpleFont in NT8?
Code:[COLOR=#0000ff]#region[/COLOR] Properties [[COLOR=#080808]NinjaScriptProperty[/COLOR]] [[COLOR=#080808]Display[/COLOR]([COLOR=#080808]Name[/COLOR]=[COLOR=#b22222]"Large Font"[/COLOR], [COLOR=#080808]Description[/COLOR]=[COLOR=#b22222]"Font Size"[/COLOR], [COLOR=#080808]Order[/COLOR]=[COLOR=#ff8c00]1[/COLOR], [COLOR=#080808]GroupName[/COLOR]=[COLOR=#b22222]"Font"[/COLOR])] [COLOR=#0000ff]public[/COLOR] [COLOR=#080808]SimpleFont[/COLOR] [COLOR=#080808]LargeFont [/COLOR]{ [COLOR=#0000ff]get[/COLOR]{[COLOR=#0000ff]return[/COLOR] [COLOR=#080808]largeFont[/COLOR];} [COLOR=#0000ff]set[/COLOR]{[COLOR=#080808]largeFont[/COLOR] = [COLOR=#080808]value[/COLOR];} }
-
Well, that means nothing special to be done, but I do not see SampleFontChange in my installation. What references?Originally posted by -=Edge=- View PostFrom the references, SampleFontChange
Code:[COLOR=#0000ff]#region[/COLOR] Properties [[COLOR=#080808]NinjaScriptProperty[/COLOR]] [[COLOR=#080808]Display[/COLOR]([COLOR=#080808]Name[/COLOR]=[COLOR=#b22222]"Large Font"[/COLOR], [COLOR=#080808]Description[/COLOR]=[COLOR=#b22222]"Font Size"[/COLOR], [COLOR=#080808]Order[/COLOR]=[COLOR=#ff8c00]1[/COLOR], [COLOR=#080808]GroupName[/COLOR]=[COLOR=#b22222]"Font"[/COLOR])] [COLOR=#0000ff]public[/COLOR] [COLOR=#080808]SimpleFont[/COLOR] [COLOR=#080808]LargeFont [/COLOR]{ [COLOR=#0000ff]get[/COLOR]{[COLOR=#0000ff]return[/COLOR] [COLOR=#080808]largeFont[/COLOR];} [COLOR=#0000ff]set[/COLOR]{[COLOR=#080808]largeFont[/COLOR] = [COLOR=#080808]value[/COLOR];} }

Comment
-
All of these I've looked thru except the Color Region have been converted to NT8 as well.. (haven't looked at them all)Originally posted by koganam View PostWell, that means nothing special to be done, but I do not see SampleFontChange in my installation. What references?

Comment
-
Ah. Now I am too embarrassed to even be here.Originally posted by -=Edge=- View Post
Comment
-
An even shorter version should be like this???Originally posted by -=Edge=- View PostFrom the references, SampleFontChange
Code:[COLOR=#0000ff]#region[/COLOR] Properties [[COLOR=#080808]NinjaScriptProperty[/COLOR]] [[COLOR=#080808]Display[/COLOR]([COLOR=#080808]Name[/COLOR]=[COLOR=#b22222]"Large Font"[/COLOR], [COLOR=#080808]Description[/COLOR]=[COLOR=#b22222]"Font Size"[/COLOR], [COLOR=#080808]Order[/COLOR]=[COLOR=#ff8c00]1[/COLOR], [COLOR=#080808]GroupName[/COLOR]=[COLOR=#b22222]"Font"[/COLOR])] [COLOR=#0000ff]public[/COLOR] [COLOR=#080808]SimpleFont[/COLOR] [COLOR=#080808]LargeFont [/COLOR]{ [COLOR=#0000ff]get[/COLOR]{[COLOR=#0000ff]return[/COLOR] [COLOR=#080808]largeFont[/COLOR];} [COLOR=#0000ff]set[/COLOR]{[COLOR=#080808]largeFont[/COLOR] = [COLOR=#080808]value[/COLOR];} }
Set the default value in SetDefaults of OnStateChange():Code:[COLOR="RED"]// [NinjaScriptProperty] as for brushes, we don't need this, right?[/COLOR] [Display(Name="Large Font", Description="Font Size", Order=1, GroupName="Font")] public SimpleFont LargeFont [COLOR="GREEN"]{ get; set; }[/COLOR]
With this style we don't need the private variable largeFont. This is one of the best things I see in NinjaScript of NT8. No needs to boringly add private variables for properties.Code:LargeFont = new SimpleFont("Arial", 14);
(correct me if I'm wrong
)
Last edited by ninZa; 11-08-2015, 03:38 AM.
Comment
-
Hello ninZa,
Thank you for your contribution and you are correct.
Just a little more information on:
This tag makes it so the NinjaScript generated code contains an overload for the property. So if you wanted to be able to set the font programatically when adding an indicator to a strategy, you would add the NinjaScriptProperty tag.Code:[NinjaScriptProperty]
Michael M.NinjaTrader Quality Assurance
Comment
-
But I believe the properties work a little slower than the private variables work when you use them in hard calculations, because extracting or setting a property requires to call an additional method to access it. Ain't I right?Originally posted by ninZa View PostAn even shorter version should be like this???
...
With this style we don't need the private variable largeFont. This is one of the best things I see in NinjaScript of NT8. No needs to boringly add private variables for properties.
(correct me if I'm wrong
)Last edited by quicktrick; 11-09-2015, 02:42 AM.
Comment
-
Thanks Michael.Originally posted by NinjaTrader_MichaelM View PostHello ninZa,
Thank you for your contribution and you are correct.
Just a little more information on:
This tag makes it so the NinjaScript generated code contains an overload for the property. So if you wanted to be able to set the font programatically when adding an indicator to a strategy, you would add the NinjaScriptProperty tag.Code:[NinjaScriptProperty]
I'm a little embarrassed here
Fonts, like brushes, are just for visual displays on chart. But we have no charts when calling an indicator from a strategy or another indicator, that's why brush serialization does not go with NinjaScriptProperty (I believe so). Can you give me an example about a practical use of NinjaScriptProperty for font serialization?
I don't think so, because NT uses "no-variable" style in many of their default NT8 indicators.Originally posted by quicktrickBut I believe the properties work a little slower than the private variables work when you use them in hard calculations, because extracting or setting a property requires to call an additional method to access it. Ain't I right?
But we will wait for an answer from Michael of NT.Last edited by ninZa; 11-09-2015, 03:07 AM.
Comment
-
The auto-implemented properties are just a design choice as the code is optimized by the compiler. It's just easier to read/debug without having to create and track your own backing field:
MatthewNinjaTrader Product Management
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
666 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
377 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
110 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
575 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
580 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment