Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Samples of building classes

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

    Samples of building classes

    Are there any sample scripts that build/initialise/discuss custom classes in NT8?

    just need something simple to help me get started e.g.

    myClass mc = new myClass();

    public class myClass
    {
    private int _capacity = 100;
    }

    and how it fits into the existing NT8 script?
    Last edited by dibDab; 09-26-2023, 01:20 PM.

    #2
    Hello dibDab,

    This is general C# education and is not necessary to learn to create NinjaScripts.

    I would recommend a C# tutorial on classes or formal C# class to learn the ins and outs of programming custom C#.

    I do have an example of partial classes you may find interesting.
    Explanation: I wrote a base class Indicator class that I'm using to inherit all my other indicators from. So this baseclass is defined as: namespace NinjaTrader.NinjaScript.Indicators.AssistedTrades { public class ATBaseIndicator: Indicator { ... } } And any other indicator is defined as: namespace NinjaTrader.NinjaScr
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Study the file @TrendLines.cs in the Indicators folder.

      Comment


        #4
        I understand I'm bordering on c# type questions but if possible can I ask where is the best place in ninjascript indicator code to

        1. create: private object[,] ctrl = new object[3,5]; (e.g. class member of public class myIndicator : Indicator)

        2, initialise ctrl (e.g. IsFirstTickOfBar and CurrentBar == 0)
        Last edited by dibDab; 09-27-2023, 07:25 AM.

        Comment


          #5
          Hello dibDab,

          Declare the variable in the scope of the class. (Between the curly braces of the class)
          Assign the variable an instantiated object in State.DataLoaded.

          In the scope of the class:
          private int[,] ctrl;

          In the scope of State.DataLoaded in OnStateChange():
          ctrl = new int[,] { {3,5} };
          Chelsea B.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          633 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          364 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          105 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          567 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          568 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X