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!
See more
See less

Partner 728x90

Collapse

Complete list of NinjaTrader.Gui.Design.Serializable options?

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

    #16
    Part 2/2

    Sample Looping code

    publicoverridevoid Plot(Graphics graphics, Rectangle bounds, double min, double max)
    {
    // ---< ensure you call the base Plot Method prior to exiting this method >---
    base.Plot(graphics, bounds, min, max);


    if (Bars == null || /*Plots.Count < 2 ||*/ ChartControl == null)
    return;

    if (CurrentBar <= 1)
    return;

    // ------------< Initialise Offsets & Graphic environment >---------------------
    int barWidth = ChartControl.ChartStyle.GetBarPaintWidth(ChartCont rol.BarWidth);
    int barSpace = ChartControl.BarSpace;

    SmoothingMode oldSmoothingMode = graphics.SmoothingMode;
    graphics.SmoothingMode = SmoothingMode.AntiAlias;

    // ===< Determaine where Indicators will be displayed. Top or Bottom of the Price Chart >===
    double[] YValues = newdouble[MaxNumOfSignalRows];
    for (int i = 0; i < MaxNumOfSignalRows; i++) {
    YValues[i] = (int)GetYValue(bounds, i + 1);

    // ---< For each bar that is displayed on the screen >---
    for(int cntBar = ChartControl.FirstBarPainted; cntBar <= ChartControl.LastBarPainted; cntBar++)
    {
    if ( (CurrentBar - cntBar) < 0)
    continue;

    int x = ChartControl.GetXByBarIdx(cntBar);
    DrawMySymbols(graphics, cntBar, x, (int)YValues[0] );
    //=====< Return SmoothingMode to its original value >========
    graphics.SmoothingMode = oldSmoothingMode;
    }
    Alternative 3:
    Design your own FONT & load it into Windows.

    This is not hard. Sorry I don't bandwidth to write you a tutorial on this at present. But try searching MSDN.Microsoft.com for tips on how to load you own font.
    A commercial approach below.
    Find help and how-to articles for Windows operating systems. Get support for Windows and learn about installation, updates, privacy, security and more.

    Comment


      #17
      Serializable Pen

      Has anyone figured out how to properly provide a Pen parameter?

      Adding the property is easy, but I have not been able to figure out how to serialize it. I tried using NinjaTrader.Gui.Design.SerializablePen, but could not get it to work.

      Comment


        #18
        something like this (from my own code)

        andreas

        www.zweisteintrading.eu



        public Color O_PenColor
        {
        get { return o_penColor; }
        set {

        o_penColor =
        value; }
        }
        // Serialize our Color object
        [Browsable(false)]
        publicstring O_PenColorSerialize
        {
        get { return NinjaTrader.Gui.Design.SerializableColor.ToString( o_penColor); }
        set {

        o_penColor = NinjaTrader.Gui.Design.SerializableColor.FromStrin g(
        value); }
        }

        Comment


          #19
          Sorry, I should have been more specific.

          By Pen, I mean a complete Pen which includes the Color, DashStyle, and Width of a drawing Pen.

          I can serialize all of the individual components correctly, but I wanted an integrated Pen to show up in the parameter list, instead of three separate parameters, similar to how it is presented in the Chart Properties - trade visualization section.

          Comment


            #20
            In any case I think, finally you have to serialise/deserialise all components separately.

            Or, do you rather want the components of you pen look hierarchically like (as an example) the lines-properties (lower/upper) of the ADX indicator?

            Regards
            Ralph

            Comment


              #21
              I want a single hierarchical parameter.

              Comment


                #22
                Here is a description how to accomplish that:



                You should scroll down to topic "Support for Custom Types".

                Comment


                  #23
                  Originally posted by aslane View Post
                  Sorry, I should have been more specific.

                  By Pen, I mean a complete Pen which includes the Color, DashStyle, and Width of a drawing Pen.

                  I can serialize all of the individual components correctly, but I wanted an integrated Pen to show up in the parameter list, instead of three separate parameters, similar to how it is presented in the Chart Properties - trade visualization section.
                  This works for me:

                  Code:
                   
                  private Pen _myPen;
                   
                   
                  [Category("Display")]
                  [Editor((typeof (PenEditor)), (typeof (UITypeEditor)))]
                  [Description("MyPen")]
                  [TypeConverter((typeof (PenConverter)))]
                  [Gui.Design.DisplayName("Some Display name")]
                  [VisualizationOnly]
                  [XmlIgnore]
                  public Pen MyPen
                  {
                  get { return _myPen; }
                  set { _myPen = value; }
                  }
                   
                  [Browsable(false)]
                  public SerializablePen Pen2Serialize
                  {
                  get { return SerializablePen.FromPen(_pen2); }
                  set { _pen2 = SerializablePen.ToPen(value); }
                  }

                  Comment


                    #24
                    I found the following works for V7.0.0.16...

                    Code:
                    using NinjaTrader.Gui.Design;     // For Pen definitions (e.g., PenEditor, SerializablePen).
                    using System.Drawing.Design;    // For Pen editing definition -- UITypeEditor.
                    
                    // The above lines must be at the very beginning of the indicator
                    //        (they should be just before or after the Using declarations.)
                    
                    // In Variables region:
                    
                    private Pen    colorUp  = new Pen( Color.Green, 2);  // Set default color & width.
                    
                    // In Properties region:
                    
                    [Editor((typeof (PenEditor)), (typeof (UITypeEditor)))]   // Necessary for Pen definition.
                    [TypeConverter((typeof (PenConverter)))]                    // Necessary for Pen definition.
                    [XmlIgnore()]
                    [Description("Color when moving up in price")]
                    [Category("Visual")]
                    [Gui.Design.DisplayNameAttribute("Backgound Up Trend Color")]
                    public Pen ColorUp
                    {
                        get { return colorUp; }
                        set { colorUp = value; }
                    }
                    
                    [Browsable(false)]
                    public SerializablePen ColorUpSerialize
                    {
                        get { return SerializablePen.FromPen(colorUp); }
                        set { colorUp = SerializablePen.ToPen(value); }
                    }

                    Comment


                      #25
                      David Lean:

                      Thanks for your thoughtful posts in this thread regarding NinjaTrader and Serializable options. I was wondering if you (or anyone else) happens to know if one can take advantage of Version Tolerant Serialization techniques with NinjaTrader?:



                      JD

                      Comment


                        #26
                        The code posted by roonius and KBJ is working for me. Although I did run into an issue while disposing the private pen variable in the OnTermination() method. If I dispose of the private pen variable then I get a "Parameter is not valid" message in the indicator parameter UI. Disposing the public pen property seems to also give the same message. Before I exposed the pen as public property I was disposing my private pens without issue.

                        I guess it's not a big deal to not dispose of the pen as it will eventually get disposed at some point. Wondering though if anyone has any insight into why this is happening or what the correct way to handle this is.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Damocoleman, 03-30-2022, 09:49 AM
                        17 responses
                        1,234 views
                        0 likes
                        Last Post Mykro
                        by Mykro
                         
                        Started by junkone, Yesterday, 02:19 PM
                        5 responses
                        69 views
                        1 like
                        Last Post junkone
                        by junkone
                         
                        Started by reynoldsn, Today, 07:19 PM
                        0 responses
                        9 views
                        0 likes
                        Last Post reynoldsn  
                        Started by reynoldsn, 04-21-2024, 07:53 PM
                        2 responses
                        19 views
                        0 likes
                        Last Post reynoldsn  
                        Started by stafe, 04-15-2024, 08:34 PM
                        13 responses
                        85 views
                        0 likes
                        Last Post stafe
                        by stafe
                         
                        Working...
                        X