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

Error CS0246 "the type or name could not be found"

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

    Error CS0246 "the type or name could not be found"

    Hello,

    The basics of my code are:

    namespace NinjaTrader.NinjaScript.Strategies.EvanStrategies
    {
    public class fading1 : Strategy
    {
    public NinjaTrader.NinjaScript.Indicators.TrendZigZagUTG4 zig;

    else if (State == State.DataLoaded)
    {
    zig = TrendZigZagUTG4(true, spansize, 3, 10);
    }
    }
    protected override void OnBarUpdate()
    {

    Print(zig.swings.Count); --- This works fine ----------

    foreach(swing b in zig.swings) {Print(b);} --- This throws an error CS0246: The type or namespace name 'swing' could not be found (are you missing a using directive or assembly reference?)

    }





    The indicator looks like this:

    public class TrendZigZagUTG4 : Indicator
    {
    public int dir, pb1, pb2, pb3;
    public double pv1, pv2, pv3;
    private double hival, loval, price;
    private Brush plotcolor;
    private int plotwidth;
    private bool drawlines, drawdots;



    public List <swing> swings = new List<swing>();


    public class swing

    {
    public int bar { get; set; }
    public double price { get; set; }

    }


    protected override void OnStateChange()
    {



    Any ideas what's wrong with my code?

    #2
    Here is the indicator file. In my startegy I'm just trying to do the following:

    foreach(swing b in zig.swings) {Print(b);}


    But i get error CS0246: The type or namespace name 'swing' could not be found (are you missing a using directive or assembly reference?)
    Attached Files

    Comment


      #3
      Hi evanp90, thanks for your question.

      If the swing class is not available from the script you are calling the TrendZigZag from you will get a compile error. Consider defining the swing class outside of the indicator class e.g.

      Code:
          public class swing{//definintion}
      
          public class TrendZigZagUTG4 : Indicator
          { ...}
      That will make swing available to any script that belongs to NinjaScript.Indicators.

      Please let me know if I can assist any further.
      Chris L.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by wzgy0920, 02-22-2024, 01:11 AM
      5 responses
      32 views
      0 likes
      Last Post wzgy0920  
      Started by wzgy0920, Yesterday, 09:53 PM
      2 responses
      49 views
      0 likes
      Last Post wzgy0920  
      Started by Kensonprib, 04-28-2021, 10:11 AM
      5 responses
      191 views
      0 likes
      Last Post Hasadafa  
      Started by GussJ, 03-04-2020, 03:11 PM
      11 responses
      3,230 views
      0 likes
      Last Post xiinteractive  
      Started by andrewtrades, Today, 04:57 PM
      1 response
      14 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Working...
      X