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

Series<double> problems

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

    Series<double> problems

    method 1: declare Series<double> without AddPlot
    method 2: declare Series<double> using AddPlot and at #region Properties

    As shown on the code (saved from built-in CandleStickPattern indicator) below, both method 1 and method 2 provide the intended functions. However, for the method 1 implementation, if this indicator is loaded on a chart and saving the chart template ("Saved As Default"), the indicator properties are not saved in the Default chart template. Charts opened in subsequent new tabs will not load this indicator. Reloading the Default template does not resolve the problem. Saving the chart template to a different name does not resolve the problem.

    With the method 2 implementation, the indicator properties are saved in the Default (or other name) chart template. Charts opened in subsequent new tabs load this indicator correctly.

    Is the method 1 implementation wrong? Is there a way to declare a public Series<double> without using AddPlot?


    // method 1: declare Series without AddPlot
    public Series<double> Price_Hi;

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = NinjaTrader.Custom.Resource.NinjaScriptIndicatorDe scriptionCandlestickPattern;
    Name = "kcCandleStickPattern";
    Calculate = Calculate.OnBarClose;
    IsOverlay = true;
    DrawOnPricePanel = true;
    DisplayInDataBox = false;
    IsAutoScale = false;
    PaintPriceMarkers = false;
    TrendStrength = 4;
    Isignal_Validate = true;

    AddPlot(Brushes.Transparent, NinjaTrader.Custom.Resource.CandlestickPatternFoun d);

    // method 2: declare Series using AddPlot and at #region Properties
    AddPlot(Brushes.Transparent, "Price_Hi");

    // method 1: declare Series without AddPlot
    Price_Hi = new Series<double>(this, MaximumBarsLookBack.Infinite);
    }
    else if (State == State.Configure)
    {
    ... ;
    }
    else if (State == State.DataLoaded)
    {
    ... ;
    }
    }

    #2
    Hello,

    Thank you for the question.

    The correct way to add a Series<T> would be to make it private like the help guide example, but in the case you do need it public for something you would have to add [XmlIgnore] attribute. A series is not serializable so it will cause serialization problems being public. You likely are receiving errors upon trying to save the workspace in the log tab.

    To correct this and leave it public, you could use the following:

    Code:
    [XmlIgnore]
    public Series<double> Price_Hi;
    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Jesse,
      Thank you very much for your quick and accurate response. With your suggested method of declaration, the indicator properties are saved in the chart template correctly. Subsequent chart opened in the new tab also retain the same indicator properties as per saved chart template.

      While I was testing the above on the latest NT 8.0.4.0, I found that the resequencing of indicator panel is no longer functional. I tested it by deleting all workspace and chart template and populate the new chart with 4 NT built-in indicators, then open the indicator dialog and change the panel sequence by moving them up/down. The new sequence is shown and retained correctly on the dialog but the indicator panel sequence on the chart remained unchanged. On the same chart indicator dialog I was able to change the chart panel sequence by changing the panel number, except for panel 1, where the indicator just disappears.

      Comment


        #4
        Hello,

        If by moving the sequence up and down you mean you are pressing the Up or Down buttons to move the indicators sequence in the list of added items I believe what you are seeing would be expected.

        The up and down arrows should only change the order in the indicators list but not the panel. Not all indicators will apply to a new panel by default and the first in the list does not specifically signify it would be on the primary panel. The expected way to change the panel would be to use the Panel dropdown.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Thanks for the confirmation.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by jeronymite, 04-12-2024, 04:26 PM
          3 responses
          43 views
          0 likes
          Last Post jeronymite  
          Started by frankthearm, Today, 09:08 AM
          4 responses
          10 views
          0 likes
          Last Post frankthearm  
          Started by yertle, Today, 08:38 AM
          5 responses
          15 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by adeelshahzad, Today, 03:54 AM
          3 responses
          18 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by bill2023, Yesterday, 08:51 AM
          6 responses
          27 views
          0 likes
          Last Post NinjaTrader_Erick  
          Working...
          X