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

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 Stanfillirenfro, Yesterday, 09:19 AM
                    7 responses
                    51 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Started by TraderCro, 04-12-2024, 11:36 AM
                    4 responses
                    69 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Mindset, Yesterday, 02:04 AM
                    1 response
                    15 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by agclub, 04-21-2024, 08:57 PM
                    4 responses
                    18 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Started by Irukandji, Today, 04:58 AM
                    0 responses
                    6 views
                    0 likes
                    Last Post Irukandji  
                    Working...
                    X