Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Objects of Other Classes

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

    Objects of Other Classes

    Goal: Plot the skew of similar calculations against each other. For example, skew of dataseries (close[1]-close[0]) versus (close[0]-open[0])

    Actions:
    I created an indicator class called Statistics. Within that class, I wrote a method called Skew. The new indicator where I want to create objects from the Statistics class is called SkewDiff

    Problem:
    I don't understand how to call methods from other classes.

    How do I create an object in the new indicator SkewDiff and assign its value to the Skew() method from the class Statistics? I know I could just copy and paste the method, but I'm trying to learn how to reference everything.

    What I tried so far in SkewDiff (and it's probably way off the mark):

    #region Variables
    private DataSeries skewCtoO ;
    #endregion
    // skewCtoO represents skew of the Close to Open

    protected override void Initialize()
    {
    Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "ClosetoOpen"));

    Statistics skewCtoO =
    new Statistics();
    }

    protected override void OnBarUpdate()
    {
    closeOpen.Set(Close[
    0] - Open[0]);
    ClosetoOpen.Set(skewCtoO.Skew(barLookBack , closeOpen));
    }

    #2
    Also, I realize that Statistics skewCtoO = new Statistics() calls the Statistics constructor, which does not exist. If I try using new Skew(), it won't compile.

    Comment


      #3
      If you are wanting to call a method that exists on a custom NinjaScript indicator, then you would write something like:

      myIndicator.MyMethod();
      RayNinjaTrader Customer Service

      Comment


        #4
        ClosetoOpen.Set(Statistics.Skew(barLookBack , closeOpen));

        NinjaTrader.Indicator.Indicator.Statistics()' is a 'method' which is not valid in the given context.

        CS0119

        Comment


          #5
          I assume your method signature is:

          Skew(int value, IDataSeries value)

          returning a double value?
          RayNinjaTrader Customer Service

          Comment


            #6
            Yes, that's correct.

            Comment


              #7
              texasnomad,

              We will need your complete script, both files, to be able to understand what is going on. It would be helpful if you attached both .cs files as attachments here. Thanks.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                It won't let me export files because there are programming errors. Is there another way to do it? I'd like to know for future reference.

                I got around the issue by commenting line 45 of SkewDiff. Please remove the comments and try to recompile.
                Attached Files

                Comment


                  #9
                  Please review the comments inside the attached files.

                  There is no way to get around exporting files with errors. You can just upload the .cs file from your My Documents\NinjaTrader 6.5 folder directly, but that is not preferred.
                  Attached Files
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Thanks, Josh. The comments clearly explain the issue.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    649 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    370 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    109 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    574 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    576 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X