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

Problem saving chart template

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

    Problem saving chart template

    Hi there,

    I notice that in some cases, NT can't save templates due a failure on Indicator class reflection. I finally found a solution, but it was giving my nuts.

    I made a simple example to show the issue.

    Code:
    namespace NinjaTrader.NinjaScript.Indicators {
    
        public class [B]MyOrder[/B] {  // Simple demo class
            public double price;
    
            public MyOrder(double price=0) {
                this.price = price;
            }
        }
    
        public class MyIndicator : Indicator {
    
            [B]public MyOrder signal_entry; [/B] // the reflection fails when this line is uncommented
    
            protected override void OnStateChange() {
    
                switch (State) {
                    case State.SetDefaults: {
                        Description = @"My Indicator base classs";
                        Name = this.GetType().Name;
                        Calculate               = Calculate.OnBarClose;
                        IsOverlay               = false;
                        DisplayInDataBox        = true;
                        DrawOnPricePanel        = false;
                        DrawHorizontalGridLines = true;
                        DrawVerticalGridLines   = true;
                        PaintPriceMarkers       = true;
                        ScaleJustification      = NinjaTrader.Gui.Chart.ScaleJustification.Right;
                        //Disable this property if your indicator requires custom values that cumulate with each new market data event.
                        //See Help Guide for additional information.
                        IsSuspendedWhileInactive = true;
                        break;
                    }
                    case State.Configure: {
                        AddLine(Brushes.Yellow, 0, "Zero");
                        break;
                    }
                }
            }
    
            protected override void OnBarUpdate() {
                Print("I'm alive:" + Time[0]);
            }
    
            #region Properties
            #endregion
        }
    }

    Even more surprising is the fact that if I declare protected this member, everything works fine.

    Can anyone give me a hint about that problem?, seems a design decision, not really a problem.
    --
    Asterio

    #2
    Hello,

    Thank you for the post.

    Yes, this would be expected for any complex object that you make into a public property. You would either need to make this a private property or mark this property as [XmlIgnore].

    We have a sample of the syntax to ignore a property, and also make a serialization property here: https://ninjatrader.com/support/help...definedbrushes

    The same concept applies to any complex object, not just a brush. The platform is trying to save this with the template which is not wanted, so you would need to ignore it or make it not publically visible.


    Please let me know if I may be of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thank you Jesse!

      I also get the point on using [XmlIgnore] .

      Great!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by yertle, Today, 08:38 AM
      6 responses
      25 views
      0 likes
      Last Post ryjoga
      by ryjoga
       
      Started by algospoke, Yesterday, 06:40 PM
      2 responses
      24 views
      0 likes
      Last Post algospoke  
      Started by ghoul, Today, 06:02 PM
      3 responses
      16 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by jeronymite, 04-12-2024, 04:26 PM
      3 responses
      46 views
      0 likes
      Last Post jeronymite  
      Started by Barry Milan, Yesterday, 10:35 PM
      7 responses
      23 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Working...
      X