Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

C# and NinjaTrader

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

    C# and NinjaTrader

    I've successfully created a lot of strategies using the NinjaScript Editor. But my ignorance of C# as it relates to NinjaTrader is great. What reference materials would you recommed, besides your user guide, since it seems to be lacking in detail in the basics, to learn more about "types", "branching", "bools" vs. "methods", etc.

    Your user guide has been very helpful, but it always seems to end before it really explains my questions.

    Like what is the difference between branching: "if, else if, else" and "if, if, if, else"?
    When should bools be used and when should methods() be used.

    I've tried using methods() and bools, but when I try to combine them, I get an error:

    Operator '&&’ cannot be applied to operands of type ‘bool' and ‘void’ for the code:

    protected override void OnBarUpdate()
    {
    if (TimeToTrade && UpTrend())
    do something...

    thanks

    #2
    You're looking for general programming help. These concepts are pretty universal across languages so I'd look at the internet for free information or consider getting a book.

    Here's a free programming tutorial you may find useful:
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks for link but "general programing" is to wide in it's scope. I need more programing info as it "relates to NinjaTrader", not Tick Tack Toe. There are basic concepts that NinjaTrader uses over and over. I need to learn more about "types", "branching", "bools" vs. "methods", etc. And what is the difference between branching: "if, else if, else" and "if, if, if, else"? When should bools be used and when should methods() be used. Why am I getting this error?
      Operator '&&’ cannot be applied to operands of type ‘bool' and ‘void’ for the code:

      protected override void OnBarUpdate()
      {
      if (TimeToTrade && UpTrend())
      do something...

      Thanks

      Comment


        #4
        For sure programming can be challenging. The concepts you're looking to know more about can be learned without NinjaTrader at all and this is why you might want to start at the fundamentals of programming.

        Data Types
        Branching
        Bools
        Methods

        These all exist in any programming language. Basic programming concepts as it relates to NinjaTrader can be found here:


        If you can understand these concepts in another language, you can apply to C#. Maybe look into a local or online course. A C# course would be good as you can then immediately apply your knowledge to NinjaScript, but syntax is the easy part once you get the concepts down.

        Bools are a datatype that store values true / false structure.
        Methods perform some task that you need to do frequently.
        Types - Is a way of structuring variables / data so the program can interpret correctly. Bool is an example of a data type.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by kenb2004 View Post
          I've successfully created a lot of strategies using the NinjaScript Editor. But my ignorance of C# as it relates to NinjaTrader is great. What reference materials would you recommed, besides your user guide, since it seems to be lacking in detail in the basics, to learn more about "types", "branching", "bools" vs. "methods", etc.

          Your user guide has been very helpful, but it always seems to end before it really explains my questions.

          Like what is the difference between branching: "if, else if, else" and "if, if, if, else"?
          When should bools be used and when should methods() be used.

          I've tried using methods() and bools, but when I try to combine them, I get an error:

          Operator '&&’ cannot be applied to operands of type ‘bool' and ‘void’ for the code:

          protected override void OnBarUpdate()
          {
          if (TimeToTrade && UpTrend())
          do something...

          thanks
          I know this is a really old post, but I did not see an answer to your original question, and on the chance someone else has this issue and is wondering what the problem is....I figured I would explain it real quick.

          The code you were using is:
          Code:
          protected override void OnBarUpdate()
          {
          if (TimeToTrade && UpTrend())
          do something...
          The error was that the '&&' could not be used to compare a 'bool' (a boolean type variable) and a 'void' (a non-value returning method). The reason the two cannot be compared is specifically because the '&&' operator requires two values to compare. The 'void' does not return a value, so the '&&' operator only has one value (the TimeToTrade variable) of the required two values.

          Comment


            #6
            A solution!

            Hey Ken,

            Ok mate, just start a basic C# programming course.. there are 100's online.
            It doesn't really matter which one, just Google a few and pick one you think is simple and clearly explained.

            RE your error message, this is a relatively simple issue (once you know how to code),
            looks like UpTrend() which is a method (or function in other languages), does not give you a bool answer..(bool is a type) your if && statement requires two boolean answers..
            Again this may sound like Greek but is simple stuff that would soon become very clear once you did a couple of tutorials..

            Mate, checkout Coursera 'C# game programming'


            It will be fun to do and teach you the very basics.. and it will help you much more with Ninja.

            Programming is like driving a car.. a but awkward at first, but if you do a couple of hours everyday , 3 months will fly by and suddenly you will look back and realize how far you went - stick at it bru

            Comment


              #7
              Thanks, I'll check out that link.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              639 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              366 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              107 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              569 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              572 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X