Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to Serialize SimpleFont?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to Serialize SimpleFont?

    You have replaced Font with SimpleFont?

    You gave us NinjaTrader.Gui.Design.SerializableFont in NT7. What is the method to serialize SimpleFont in NT8?

    #2
    Originally posted by koganam View Post
    You have replaced Font with SimpleFont?

    You gave us NinjaTrader.Gui.Design.SerializableFont in NT7. What is the method to serialize SimpleFont in NT8?
    From 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];}
     }
    -=Edge=-
    NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

    Comment


      #3
      Originally posted by -=Edge=- View Post
      From 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];}
       }
      Well, that means nothing special to be done, but I do not see SampleFontChange in my installation. What references?

      Comment


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



        -=Edge=-
        NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

        Comment


          #5
          Originally posted by -=Edge=- View Post
          All of these I've looked thru except the Color Region have been converted to NT8 as well.. (haven't looked at them all)



          Ah. Now I am too embarrassed to even be here.

          Comment


            #6
            Originally posted by -=Edge=- View Post
            From 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];}
             }
            An even shorter version should be like this???

            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]
            Set the default value in SetDefaults of OnStateChange():
            Code:
            LargeFont = new SimpleFont("Arial", 14);
            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 ninZa; 11-08-2015, 03:38 AM.
            ninZa
            NinjaTrader Ecosystem Vendor - ninZa.co

            Comment


              #7
              Hello ninZa,

              Thank you for your contribution and you are correct.

              Just a little more information on:
              Code:
              [NinjaScriptProperty]
              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.
              Michael M.NinjaTrader Quality Assurance

              Comment


                #8
                Originally posted by ninZa View Post
                An 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 )
                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?
                Last edited by quicktrick; 11-09-2015, 02:42 AM.

                Comment


                  #9
                  Originally posted by NinjaTrader_MichaelM View Post
                  Hello ninZa,

                  Thank you for your contribution and you are correct.

                  Just a little more information on:
                  Code:
                  [NinjaScriptProperty]
                  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.
                  Thanks Michael.

                  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?

                  Originally posted by quicktrick
                  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?
                  I don't think so, because NT uses "no-variable" style in many of their default NT8 indicators.
                  But we will wait for an answer from Michael of NT.
                  Last edited by ninZa; 11-09-2015, 03:07 AM.
                  ninZa
                  NinjaTrader Ecosystem Vendor - ninZa.co

                  Comment


                    #10
                    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:

                    For an automatically implemented property in C#, the compiler creates a private, anonymous backing field accessed only through get and set accessors of the property.
                    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 Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    377 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    110 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    575 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    580 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X