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 PaulMohn, Today, 12:36 PM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by yertle, Yesterday, 08:38 AM
      8 responses
      36 views
      0 likes
      Last Post ryjoga
      by ryjoga
       
      Started by rdtdale, Today, 01:02 PM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Started by alifarahani, Today, 09:40 AM
      3 responses
      16 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by RookieTrader, Today, 09:37 AM
      4 responses
      19 views
      0 likes
      Last Post RookieTrader  
      Working...
      X