Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error CS0246: The namespace name 'DataSeries' could not be found

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

    Error CS0246: The namespace name 'DataSeries' could not be found

    Hi there,

    My code looks like this:

    region Using declarations using System;
    using System.ComponentModel;
    using System.Windows.Media;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui.Tools;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript.Strategies;
    using NinjaTrader.NinjaScript.Indicators;
    using NinjaTrader.Gui;
    #endregion

    // Indicator Declaration
    [Gui.Design.DisplayName("Custom Stochastic")]
    public class CustomStochastic : Indicator
    {
    private Stochastics stochastics;

    protected override void Initialize()
    {
    // Define the visual elements
    Add(new Plot(new Pen(Brushes.Cyan, 1.4), PlotStyle.Line, "%K"));

    Add(new Line(Brushes.Red, 80, "Upper1"));
    Add(new Line(Brushes.Orange, 70, "Upper2"));
    Add(new Line(Brushes.Orange, 30, "Lower1"));
    Add(new Line(Brushes.Red, 20, "Lower2"));

    stochastics = Stochastics(8, 3, 6);
    }

    protected override void OnBarUpdate()
    {
    if (CurrentBar < 1) return;

    double K = stochastics.K[0];
    double D = stochastics.D[0];
    double PrevK = stochastics.K[1];
    double PrevD = stochastics.D[1];

    // Assign values
    Values[0][0] = K;

    // Check for crossover
    if (PrevK <= PrevD && K > D) // Cross up
    {
    PlotBrushes[0][0] = Brushes.Cyan;
    }
    else if (PrevK >= PrevD && K < D) // Cross down
    {
    PlotBrushes[0][0] = Brushes.DarkViolet;
    }

    // If it's exactly on the crossover, we color it white
    if ((PrevK <= PrevD && K >= D) || (PrevK >= PrevD && K <= D))
    {
    PlotBrushes[0][0] = Brushes.White;
    }
    }

    region Properties
    [Browsable(false)]
    public DataSeries K // <----- The error is here
    {
    get { return Values[0]; }
    }
    #endregion
    }

    Error: CS0246 - The type or namespace name 'DataSeries' could not be found.

    Could anyone think of why I would be getting this error? Your help would be greatly appreciated.

    Thanks in advance!



    #2
    Hello TraderJosh,

    This appears to be a mix of NT7 and NT8 code, did you by chance use an external tool to generate this code for you?

    Can you confirm are you trying to make an NT7 indicator or NT8 indicator?

    Comment


      #3
      Hi Jesse

      First of all, thanks for your response. This code was written by chat gpt based on a prompt I provided. I am intending to use this indicator on Ninjatrader 8.

      Comment


        #4
        Could you kindly point out which lines are NT7 code? I should be able to get the AI to rewrite them for NT8 (Im a noob at coding)

        Comment


          #5
          Hello TraderJosh,

          Thanks for confirming. Based on this code being generated by chatgpt I cannot assist with that code but I can make a suggestion on how to start making indicators in NT8. Chatgpt does not work for NinjaScript because it does not know the nuances of NinjaTrader code. I have included a disclaimer about using chatgpt below.

          I would suggest looking at some of the stock indicators in NT8 like the bollinger or stochastics indicators. Those both show how to add plots, set values, use public properties and have all the correct namespaces and code. You can also generate a new indicator using the NinjaScript editor which will allow you to define properties or plots so that code is generated for you when you create the indicator. You can additionally use the help guide to learn about using NinjaScript, NT7 and NT8 code are not compatible so you need to make sure to use the NT8 helpguide for NT8 NinjaScript.




          From our experience at this time, ChatGpt is not adequate to generate valid compilable NinjaScripts that function as the user has intentioned. We often find that the generated code will call non-existent properties and methods, use improper classes or inheritance, and may have incorrect logic. We highly encourage that you create a new NinjaScript yourself using the NinjaScript Editor.

          While It would not be within our support model to correct generated scripts at user request, we would be happy to provide insight for any direct specific inquiries you may have if you would like to create this script yourself. Our support is able to assist with finding resources in our help guide as well as simple examples, and we are happy to assist with guiding you through the debugging process to assist you with understanding unexpected behavior.

          You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like a list of affiliate consultants who would be happy to create this script or any others at your request or provide one on one educational services.​

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          597 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          343 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          103 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          556 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          555 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X