Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NinjaScript operators

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

    NinjaScript operators

    Hello, I need your help trying to find out what some operators in NinjaScript mean.

    I tried to parse Parabolic SAR formula and implement it to Excel, but I faced some difficulties.

    • if (afIncreased && prevBar != CurrentBar) - what those "&&" and "!=" mean?
    • if ((longPosition && (Low[0] < todaySAR || Low[1] < todaySAR))
      || (!longPosition && (High[0] > todaySAR || High[1] > todaySAR)))
      - hard to track those lines as well.

    And also this one:

    for (int x = 1; x <= 2; x++)

    #2
    Aivaras - NinjaScript is the C# programming language. I recommend that anyone planning on using NinjaScript start by getting a good introduction to C# book.

    Without going into much detail:
    && means AND
    != means NOT EQUAL
    ! means NOT
    || means OR

    You will want to learn about precedence, the order in which various operators are evaluated.

    for (int x = 1; x <= 2; x++) is a C# "for" loop statement.
    "int x = 1" defines an integer (int) variable called x, and initializes its value to 1.
    " x <= 2" is a boolean (true/false) statement. If it is true (if x is less than or equal to 2) then the body of the loop is executed.
    "x++" is an iterator statement. In this case, at the bottom of the "for" loop, x will be incremented by 1.
    The "for" loop will continue to be executed until "x <= 2" evaluates to false or unless there is some other criteria in the body of the "for" loop that causes it to terminate.

    Get a good C# book which can explain in more detail what you need to know.

    Comment


      #3
      Thank you very much, I will try to crack the code tomorrow, because it seems a bit different than any other Parabolic SAR Excel files I encountered.

      Comment


        #4
        And what does those parenthesis mean?
        • Value.Set(Reverse())
        • AfIncrease()

        There's nothing inside them.

        Also, I tried to convert SMA indicator script to excel (after successfully converting EMA indicator).

        I failed to trace what "Input[Period]" is. Could you tell me? Input[0] is close of current bar and what is Input[Period]?


        whole string looks like this: ((Value[1] * Math.Min(CurrentBar, Period) + Input[0] - Input[Period]) / Math.Min(CurrentBar, Period))



        So it's yesterdays_SMA * Min (CurrentBarNumber; Period) + today's_close - Input[Period]) / Min (CurrentBarNumber; Period))
        Last edited by Aivaras; 01-12-2014, 03:08 AM.

        Comment


          #5
          Reverse() and AfIncrease() are called "methods" in C#, similar to functions in C++. The empty () as part of the method means that there are no parameters being passed to the method. So, if you are trying to trace the logic and code of an indicator (method) then you will also need to understand the logic and code of any methods called from within the indicator or method.

          From NinjaTrader help:
          Input represents the input data source of the indicator. If you implement an indicator where PriceTypeSupported is set to true, then when referencing the input data source value, you will want to reference Input[0] instead of Close[0]. This is because Input[0] will return the data value of the selected PriceType.

          So, assuming that in your case Input represents the Close data source then Input[0] is equivalent to Close[0] and Input[Period] is equivalent to Close[Period] which is the closing value of the bar Period bars ago.

          The above type of information can be found in a C# book and in the NinjaTrader help.
          Last edited by higler; 01-12-2014, 10:50 AM.

          Comment


            #6
            Hello Aivaras,

            Thank you for your posts and welcome to the NinjaTrader Support Forum!

            higler provides some good information here on C# programming. We have Premium Paid Educational events where you will join a NinjaScript expert for a pair of 6-8 hour long intensive courses designed to provide you with an in depth look at programming indicators and automated strategies through the use of NinjaScript:


            If you would like to take on learning NinjaScript on your own, we have a fully documented help guide which will help you get started with Ninja Script. You will find language references to all of the methods and functions you will be using. You will also see a tutorial section which will help you create your first indicator and get you started with some of these concepts.
            A link to our Help Guide can be found below: http://www.ninjatrader.com/support/h...stribution.htm

            I am also linking you to the Educational Resources section of the Help Guide to help you get started with NinjaScript: http://www.ninjatrader.com/support/h..._resources.htm

            You will find Reference Samples online as well as some Tips and Tricks for both indicators and strategies:
            Click here to see our NinjaScript Reference Samples: http://www.ninjatrader.com/support/f...splay.php?f=30
            Click here to see our NinjaScript Tips: http://www.ninjatrader.com/support/f...ead.php?t=3229

            These samples can be downloaded, installed and modified from NinjaTrader and hopefully serve as a good base for your custom works.

            There is a also a growing library of user submitted custom indicators (100+) that can be downloaded from our support form. Please look in the NinjaScript File Sharing section of our support forum as you may find what you are looking for there: http://www.ninjatrader.com/support/f...splay.php?f=37

            If you have limited time or programming capabilities, you can discuss your requirements with any of our certified NinjaScript consultants.
            Click here for a list of certified NinjaScript Consultants: http://www.ninjatrader.com/Ecosystem/NonBroker.php#81

            Please let me know if you have any questions.

            Comment

            Latest Posts

            Collapse

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