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

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.
    Brandon H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Tburg1073, Today, 08:36 AM
    0 responses
    3 views
    0 likes
    Last Post Tburg1073  
    Started by alexstox, 10-16-2018, 03:29 PM
    10 responses
    333 views
    0 likes
    Last Post Tburg1073  
    Started by smartromain, 03-13-2024, 01:42 AM
    6 responses
    98 views
    0 likes
    Last Post smartromain  
    Started by Jonker, 04-27-2024, 01:19 PM
    4 responses
    29 views
    0 likes
    Last Post Jonker
    by Jonker
     
    Started by Yasharandom, Today, 07:45 AM
    0 responses
    5 views
    0 likes
    Last Post Yasharandom  
    Working...
    X