Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Screen rendering not working with multiple dataseries

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

    Screen rendering not working with multiple dataseries

    i am testing some ideas to see how various indicators work and i have run into an issue. when i am working with multiple dataseries and plots, all the plots dont render initially. however, when i go into a dialog box and adjust an unrelated property like autoscale or pricemarker, the lines render on the chart. any idea what might be going on? here is my code for the test:

    region Using declarations
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Gui.SuperDom;
    using NinjaTrader.Gui.Tools;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    using NinjaTrader.NinjaScript.DrawingTools;
    #endregion

    //This namespace holds Indicators in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.Indicators.MyIndicators {

    public class TestEventArgs : EventArgs {
    public TestEventArgs(double p) { Price = p; }
    public double Price { get; private set; }
    }

    public class MyTestIndicator : Indicator {
    const int Period = 21;
    const int LineWidth = 3;
    private EMA _emaDefault;
    private EMA _emaTypical;
    private EMA _emaOpen;
    private EMA _emaHigh;
    private EMA _emaLow;
    private EMA _emaClose;
    protected override void OnStateChange() {

    if (State == State.SetDefaults) {
    Description = @"Enter the description for your new custom Indicator here.";
    Name = "MyTestIndicator";
    Calculate = Calculate.OnBarClose;
    IsOverlay = true;
    AddPlot(new Stroke(Brushes.Black, LineWidth), PlotStyle.Line, "EMA(Default)");
    AddPlot(new Stroke(Brushes.Aqua, LineWidth), PlotStyle.Line, "EMA(Typical)");
    AddPlot(new Stroke(Brushes.LimeGreen, LineWidth), PlotStyle.Line, "EMA(Open)");
    AddPlot(new Stroke(Brushes.DodgerBlue, LineWidth), PlotStyle.Line, "EMA(High)");
    AddPlot(new Stroke(Brushes.Coral, LineWidth), PlotStyle.Line, "EMA(Low)");
    AddPlot(new Stroke(Brushes.Red, LineWidth), PlotStyle.Line, "EMA(Close)");
    }
    else if(State == State.Configure) {
    _emaDefault = EMA(Period);
    _emaTypical = EMA(Typical, Period);
    _emaOpen = EMA(Open, Period);
    _emaHigh = EMA(High, Period);
    _emaLow = EMA(Low, Period);
    _emaClose = EMA(Close, Period);
    }
    }
    protected override void OnBarUpdate() {
    if (CurrentBar < Period)
    return;

    Values[0][0] = _emaDefault[0];
    Values[1][0] = _emaTypical[0];
    Values[2][0] = _emaOpen[0];
    Values[3][0] = _emaHigh[0];
    Values[4][0] = _emaLow[0];
    Values[5][0] = _emaClose[0];
    }
    }
    }

    region NinjaScript generated code. Neither change nor remove.

    namespace NinjaTrader.NinjaScript.Indicators
    {
    public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
    {
    private MyIndicators.MyTestIndicator[] cacheMyTestIndicator;
    public MyIndicators.MyTestIndicator MyTestIndicator()
    {
    return MyTestIndicator(Input);
    }

    public MyIndicators.MyTestIndicator MyTestIndicator(ISeries<double> input)
    {
    if (cacheMyTestIndicator != null)
    for (int idx = 0; idx < cacheMyTestIndicator.Length; idx++)
    if (cacheMyTestIndicator[idx] != null && cacheMyTestIndicator[idx].EqualsInput(input))
    return cacheMyTestIndicator[idx];
    return CacheIndicator<MyIndicators.MyTestIndicator>(new MyIndicators.MyTestIndicator(), input, ref cacheMyTestIndicator);
    }
    }
    }

    namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
    {
    public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
    {
    public Indicators.MyIndicators.MyTestIndicator MyTestIndicator()
    {
    return indicator.MyTestIndicator(Input);
    }

    public Indicators.MyIndicators.MyTestIndicator MyTestIndicator(ISeries<double> input )
    {
    return indicator.MyTestIndicator(input);
    }
    }
    }

    namespace NinjaTrader.NinjaScript.Strategies
    {
    public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
    {
    public Indicators.MyIndicators.MyTestIndicator MyTestIndicator()
    {
    return indicator.MyTestIndicator(Input);
    }

    public Indicators.MyIndicators.MyTestIndicator MyTestIndicator(ISeries<double> input )
    {
    return indicator.MyTestIndicator(input);
    }
    }
    }

    #endregion

    #2
    Hello love2code2trade,

    Thanks for your post.

    I do not see where you are adding additional secondary data series in the code you shared. To clarify, are you referring to running the custom NinjaScript indicator on multiple charts, each set to a different data series?

    So I may accurately assist, please send me the steps you are taking to reproduce the behavior and a screenshot demonstrating the behavior you are reporting.
    • To send a screenshot with Windows 10 or newer I would recommend using the Windows Snipping Tool.
    • Alternatively to send a screenshot press Alt + PRINT SCREEN to take a screenshot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save it as a jpeg file and send the file as an attachment.
    ​Also, please provide an exported copy of the indicator so that I may test it on my end using the steps you provide.

    To export a NinjaScript indicator, go to Tools > Export > NinjaScript AddOn.

    I look forward to assisting further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    646 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    367 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    107 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    569 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    573 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X