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

C# before NinjaScript for a beginner?

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

    C# before NinjaScript for a beginner?

    I want to code strategies and indicators in NT. I don't know anything about programming, so pretty much starting from ground zero. I have a bunch of ideas but I can't code them in excel, so thinking this is my best route to go.

    Hoping to get some expert advice, I assume I need to learn some basic C# skills before diving into NT scripts. Problem is I have watched videos on C# and NScripting and the method names, class names, etc are all different. So really wondering how much will knowing C# help me, how deep do I need to go?

    Would it be better to learn Matlab, or something else instead for testing?

    Appreciate your expert help.
    STeve

    #2
    Originally posted by sesplin View Post
    Hoping to get some expert advice, I assume I need to learn some basic C# skills before diving into NT scripts. Problem is I have watched videos on C# and NScripting and the method names, class names, etc are all different. So really wondering how much will knowing C# help me, how deep do I need to go?

    Would it be better to learn Matlab, or something else instead for testing?
    Yes, the more C# you know, absolutely the better off you will be with NinjaScript.

    As far as learning C#, how much time do you have? If you have more money than time, I suggest you hire someone. If you have more time than money, then start learning C# absolutely. If you have neither, start with the Strategy Wizard.

    Now, realize that NinjaScript is not a separate language.

    NinjaScript is a framework for writing plugins for NinjaTrader.exe, which is a .NET program. Read that sentence again, 10 times, out loud.

    Your plugins are either indicators or strategies, which are derived from class Indicator or class Strategy (but never both at the same time). These 2 classes are provided by the NinjaScript framework -- which is only available when running NinjaTrader.exe.

    [In techy terms, you could say that, under the hood, the NinjaScript framework provides a class library that exports some very important classes, such as Indicator, Strategy, DataSeries, etc. The NinjaScript compiler hides all this complexity, and can suppress understanding of the hierarchical relationships of everything -- but the NinjaScript framework is definitely an "in-addition-to-C#" thing, not a separate standalone thing.]

    My point is: get your head wrapped around the hierarchy and the relationships of things, make sure you understand who "owns" what, and that will help you see why all the "class names and methods are different". In other words, make sure you truly recognize the difference between a C# thing and a NinjaScript thing.

    So sure, if you have time, start with C#, work through some examples, read read read, but always, have fun.

    Comment


      #3
      Hello sesplin,

      bltdavid is certainly right that the more C# you know the better.

      We do provide in-depth help documentation on developing NinjaScripts, as well as samples and a complete reference of the language.

      You can find that information here: http://ninjatrader.com/support/helpG..._resources.htm

      If you have a basic understanding of C#, I suggest following the documented Code Breaking changes between NinjaTrader 7 and NinjaTrader 8, and get used to NinjaScripts by porting an existing NinjaTrader 7 indicator or strategy.

      You can find the Code Breaking changes here: http://ninjatrader.com/support/helpG...ng_changes.htm
      JimNinjaTrader Customer Service

      Comment


        #4
        Thank you bltdavid for the information. Aside from what NT_Jim sent today, is there a book, .pdf or something, not on NT site that you suggest I read to see the differences you talk about above? I have found the NT help not to be that helpful. Maybe I am in the wrong place in help.

        Not sure if you have experience testing in other environments other than NT like Python, Matlab, etc. If so, how does NT stack up?

        Thanks again.

        Comment


          #5
          Originally posted by sesplin View Post
          I want to code strategies and indicators in NT. I don't know anything about programming, so pretty much starting from ground zero. I have a bunch of ideas but I can't code them in excel, so thinking this is my best route to go.

          Hoping to get some expert advice, I assume I need to learn some basic C# skills before diving into NT scripts. Problem is I have watched videos on C# and NScripting and the method names, class names, etc are all different. So really wondering how much will knowing C# help me, how deep do I need to go?

          Would it be better to learn Matlab, or something else instead for testing?

          Appreciate your expert help.
          STeve
          IMHO, no. As I tell everyone who cares to listen, the correct way to learn to write NinjaScript is to work though and code all the tutorial examples in the NT Help. That will give you a rudimentary understanding of how things are setup in the NT Framework (which is based on c#).

          Only after you understand that do you want to go into c# proper to learn how to add those things that are not covered natively in NT. If you start the other way, you will have a lot of esoteric general knowledge that you then need to dumb down to figure out how NT actually frames things.

          Just my $0.02.

          Comment


            #6
            You can try looking at,

            NinjaScript C# programming tutorial ebook available on Smashwords.com


            And also pick a few starter websites from,

            Comment


              #7
              Originally posted by sesplin View Post
              Not sure if you have experience testing in other environments other than NT like Python, Matlab, etc. If so, how does NT stack up?
              No idea, NT is my first (real) experience at trade automation,
              as well as the (back) testing involved in that endeavor ...

              Comment


                #8
                Originally posted by koganam View Post
                work though and code all the tutorial examples in the NT Help.
                I don't disagree with this, but will add my thoughts and caveats.

                If you know absolutely nothing about logic and programming, you could be very lost doing it this way. But then I say this: man up, you're not stupid, right? so learn how to learn what you're looking at.

                In other words, you need that go-getter attitude to continue self-learning (somehow, someway, somewhere) those things in the tutorials which you don't know.

                In fact, that's how I learned NinjaScript. Yes, I started learning C# completely by focusing on NinjaScript first, then C# second. I did eventually buy a couple of (older and cheaper) books on C# and .NET to help me.

                [Why older & cheaper books? Because, NT7 did not support all the new fangled things coming out in C# and .NET ... NT7 was stuck in time with an older version of .NET, and all I really wanted to know was the basics of C# anyways.]

                But, I am a professional software engineer with almost 30 years of experience, all of it with C and C++, so for me, that was the most logical route -- aka, just dive in.

                For true newbies, this just dive-in approach can be frustrating, but, yet, might still be the best route to learning. Don't know what a compiler is? You'll learn. Don't know how to "see" what your code is doing? You'll quickly learn Print and the output window. Don't know what a method is, or an argument, or a class? You'll learn as you go, making little side projects for yourself to Google dozens of things to satisfy what it is you don't know.

                So, my point is: Koganam is (probably) right. For most people who can learn this way, (learning/researching side items you don't know to uncover/reveal the big ideas in the code in front of you), it can be very satisfying. The small victories as you accumulate knowledge and overcome problems in the tutorials empowers you, esp as you start to understand the big picture of what the heck the code is really doing.

                I am an optimist. Most people are not dumb. Even those NinjaTrader users with absolutely no training in computer programming should be able to learn enough to get things done. But you better drop all your fears and realize you CAN do it, and you WILL do it, and realize that Google is your friend. It is a long journey, and will be hard, but it builds upon itself nicely: just like math, learning programming is done in layers.

                But you still need free time to do this. And lots of reading, and time. Start with the simplest strategy tutorial and compile it. Now add a Print statement to Initialize, recompile, move it to OnStartUp, recompile, take the time to experiment as you go.

                Stay organized with your bookmarks of what you're learning, make time to keep track of your website references of where you learned something.

                Did I mention you'll need lots of time?
                Last edited by bltdavid; 12-26-2016, 09:01 AM.

                Comment


                  #9
                  You all have been so helpful, I'll ask another question. what do you use for data mining? i.e. what tool do you use to answer questions like: how does price react after making a new 10 day high, does it continue or does it mean revert. There are many scenarios like that where a data mining tool would work great. Once I get those questions answered I can then create a strategy to test in NT.

                  Books I have read recommend anything from excel to python, R and Matlab. what do you guys use?
                  Thanks again.,

                  Comment


                    #10
                    Originally posted by sesplin View Post
                    You all have been so helpful, I'll ask another question. what do you use for data mining? i.e. what tool do you use to answer questions like: how does price react after making a new 10 day high, does it continue or does it mean revert. There are many scenarios like that where a data mining tool would work great. Once I get those questions answered I can then create a strategy to test in NT.

                    Books I have read recommend anything from excel to python, R and Matlab. what do you guys use?
                    Thanks again.,
                    That is the purpose of the Strategy Analyzer. Write a strategy and analyze it using the Strategy Analyzer.

                    The other option for stuff like that is to write an indicator and put it on a chart to see visually; and output to a file if you want to validate the statistics.

                    I often do both.
                    Last edited by koganam; 12-22-2016, 02:47 PM.

                    Comment


                      #11
                      If you are a trader, stick to trading. Learning C# and the MANY peculiarities (being polite here) of NT is a tall mountain to climb. Before you can make a real dent in NT you have to at least know C#, .NET, and WPF. Then you have to decide managed vs. unmanaged trading. My advise to anyone looking down this rabbit hole is ... don't. Get with someone who already knows this stuff and either partner with them or pay them. Either way you save an enormous amount of time and effort.
                      The strategy builder is all but useless for anything but simplistic efforts.
                      My 2 cents ... Ed

                      Comment


                        #12
                        Originally posted by edstaffin View Post
                        ...
                        The strategy builder is all but useless for anything but simplistic efforts.
                        My 2 cents ... Ed
                        I agree, but that is not what I said. I said Strategy Analyzer, not Builder. I agree that something seems to be wonky about the NT8 one, but do not quote me, because I have not used it in a while. That is a large part of the reason why I have refused to do any client work in NT8. The NT7 Strategy Analyzer is solid and consistent, albeit, marginally more difficult to tame, especially if the trades require confirmation for entry and/or exit. That again, is talking about the Strategy Analyzer.

                        In any case, I find almost all so called "wizards" to be pretty weak code generators. After all, they are ipso facto static, capable only of what their creators have already programmed them to do, in a particular manner, and no other. They too often generate clumsy, inefficient code.

                        Just my $0.02.

                        Comment


                          #13
                          Understood. As to the strategy analyzer, I find that it has been nothing but an exercise in frustration. Run a backtest/optimization on one machine, get a result, then run the exact same test on another machine and get different results. Run a strat for a period of time (say, Jan.) on a sim account, and then run a back test for the same period and get different (often, not even close) results. Now try running a strat using market replay data and get yet another completely different set of results. Oh, and let's not forget to mention that if you use anything other than range bars with stops and targets > the range you can't trust the results because the target and stops in the non-range bar case can be within a single bar and then it's just an algorithmic guess. I don't at this point, see how you can get reliable, trustworthy information from this tool. Not something I am willing to throw cash at. It's very discouraging when, repeatedly, you run optimizations that suggest a good result and you then put it out to run on a sim account and it's not even close.
                          Not to mention the periodic crashes and memory leaks, incomplete saving of settings and various other bugs. All of this leads me to the conlclusion, that after something like 2 years of beta, we have a released product that is approaching alpha. There is nothing I'd like better to be able to do than to use this product and reliably make money with it. I just can't pull the trigger with the tool as messy as it is.
                          Sorry for the rant, but there you have it.
                          Ed

                          Comment


                            #14
                            Thank you for reporting your experience with the Strategy Analyzer, edstaffin. While it is true that Ninja has to simulate the actions of the trade desk (which are chaotic in real life) when backtesting, you should not be receiving dramatically different results between retests, on the same or on different machines. I appreciate how valuable your time is; would it be possible to answer a few questions which may help us improve this part of NinjaTrader?

                            • Can you get different trades with multiple runs using the built-in SampleMACrossover strategy?
                              • If so, can you let us know what conditions you used to get this to happen?

                            • If you make a chart with two SMA indicators, with periods matching your SampleMACrossover's periods, and you compare your chart with your result, do you see trades on every crossover?
                            • Who are you connected to? This is displayed in green on lower left corner of the Control Center window.
                              • IMPORTANT: if you would like backtest results to be repeatable, I would like to recommend that you DO NOT use the Simulated Data Feed. Backtesting this way is a terrific way to "smoke test" your strategy - in other words "turn it on and see if smoke pours out", make sure it runs at all - but will test your strategy against random market conditions. I highly recommend if you do not have a live data feed using the Market Replay (Playback in NT8) connection.

                            • What instrument(s) (and expiry if applicable) have you selected?
                            • If you are using NinjaTrader 8, have you tried using either Tick Replay or High Fill Resolution? These may dramatically improve the reliability of results, especially surrounding intra-bar data in situations like what you described

                            NinjaTrader 8 has also become a very stable platform for most of our customers, and I'm sorry to hear that you haven't had what has become a typical user experience. So that we may determine why your system has been crashing, could you send e-mail to platformsupport[at]ninjatrader[dot]com referencing Attn:NinjaTrader_JessicaP and 1626582 in the subject line? Could you attach the contents of your (My) Documents\NinjaTrader 8\logs and (My) Documents\NinjaTrader 8\traces folders in a zip file when sending this e-mail?


                            DirectX and WPF applications tend to favor performance over resource usage, and it is true that NinjaTrader 8 uses more processor time and memory than NinjaTrader 7 and requires a more powerful system. That said, if you have experienced a memory leak - or in other words, a low memory condition on your system that persists after NinjaTrader is closed - please let us know, so that we may take corrective action.


                            Even if you do not have the time to answer any of the above, I would like to let you know that your feedback is appreciated, and that we will do everything in our power to address what you have pointed out. Thank you for helping us make NinjaTrader 8 better.
                            Last edited by NinjaTrader_JessicaP; 12-26-2016, 10:02 AM.
                            Jessica P.NinjaTrader Customer Service

                            Comment


                              #15
                              Thanks for the reply Ed, and all. Seems like I might be better off doing what Michael the founder of Quantstart did, build my own backtester, optimizer, execution engine in Python. I have been impressed with his site and the information. At the end of the day, Python is supposed to be easier to learn, though not as powerful as C#. He seems to be willing to share some code for things he has done.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by gemify, 11-11-2022, 11:52 AM
                              6 responses
                              803 views
                              2 likes
                              Last Post ultls
                              by ultls
                               
                              Started by ScottWalsh, Today, 04:52 PM
                              0 responses
                              3 views
                              0 likes
                              Last Post ScottWalsh  
                              Started by ScottWalsh, Today, 04:29 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post ScottWalsh  
                              Started by rtwave, 04-12-2024, 09:30 AM
                              2 responses
                              22 views
                              0 likes
                              Last Post rtwave
                              by rtwave
                               
                              Started by tsantospinto, 04-12-2024, 07:04 PM
                              5 responses
                              70 views
                              0 likes
                              Last Post tsantospinto  
                              Working...
                              X