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

Adding parameters to an existing indicator

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

    Adding parameters to an existing indicator

    Hello,

    A short while ago I installed NinjaTrader 7, and have been reading the various Help menus and practicing with the pre-installed indicators, as well as writing my own for testing. The wizard can be used to start a new indicator from scratch, where the parameters, data and type of graphical output can be specified. However, I do not know how to add new data or parameters to an existing indicator, and would be most grateful for some help.

    On opening a chart and specifying indicators, a window is opened with a list of indicators on the left and the parameters, data, graphics etc. displayed on the right. The value in an input parameter can be changed, but how do I add a new parameter or item of data?

    In looking at the code at the beginning of an indicator are various standard .NET “using System” statements, followed by “using NinjaTrader.Cbi”, “using NinjaTrader.Data” and “using NinjaTrader.Gui.Chart”, which are obviously specific to NinjaTrader, and the last one obviously refers to graphics, so the code associated with parameters and indicators must be referred by the other two “using” statements, but I am unable to locate the source code.

    In going to \Program Files\NinjaTrader 7\ are the folders bin, db, doc and sounds, together with a Word document with the license agreement. By elimination it looks as if the code I’m looking for must be in \db\NinjaTrader SQL server. I only have .NET express installed and no SQL currently installed.

    The upshot is that I would be most grateful to know how to change the numbers of parameters or data types in an existing indicator, either by using some kind of wizard or by locating and modifying the source code that is set up by the wizard before the specific indicator is called, and would be most grateful for some help on this.

    Christopher
    Csharp

    #2
    Originally posted by csharp View Post
    Hello,

    A short while ago I installed NinjaTrader 7, and have been reading the various Help menus and practicing with the pre-installed indicators, as well as writing my own for testing. The wizard can be used to start a new indicator from scratch, where the parameters, data and type of graphical output can be specified. However, I do not know how to add new data or parameters to an existing indicator, and would be most grateful for some help.

    On opening a chart and specifying indicators, a window is opened with a list of indicators on the left and the parameters, data, graphics etc. displayed on the right. The value in an input parameter can be changed, but how do I add a new parameter or item of data?

    In looking at the code at the beginning of an indicator are various standard .NET “using System” statements, followed by “using NinjaTrader.Cbi”, “using NinjaTrader.Data” and “using NinjaTrader.Gui.Chart”, which are obviously specific to NinjaTrader, and the last one obviously refers to graphics, so the code associated with parameters and indicators must be referred by the other two “using” statements, but I am unable to locate the source code.

    In going to \Program Files\NinjaTrader 7\ are the folders bin, db, doc and sounds, together with a Word document with the license agreement. By elimination it looks as if the code I’m looking for must be in \db\NinjaTrader SQL server. I only have .NET express installed and no SQL currently installed.

    The upshot is that I would be most grateful to know how to change the numbers of parameters or data types in an existing indicator, either by using some kind of wizard or by locating and modifying the source code that is set up by the wizard before the specific indicator is called, and would be most grateful for some help on this.

    Christopher
    Csharp
    Look in the properties section, and cross-reference them to the private variables.

    Comment


      #3
      csharp, I would suggest you take a look at this tip here - http://www.ninjatrader.com/support/f...ead.php?t=5782
      BertrandNinjaTrader Customer Service

      Comment


        #4
        OK, I did exactly that and it works! Many thanks indeed. I'm new to NinjaScript and that advice saved me a lot of time.

        At some point I might want to change some of the other quantities in Data, Visual, Label and Plots. Of these only the last, Plot0, is in the Properties section, and it is set up in the Initialize() method. Where are the other properties set up? I realise that it may make sense to changes some of these in the code.

        Many thanks,

        csharp

        Comment


          #5
          At the end of my reply I meant to say that it may ONLY make sense to change some of these in the code, e.g. the input series, say AA (Daily), depends on what Data Series you select, so there is no point in changing the code for this.

          csharp

          Comment


            #6
            Hi csharp,

            Those categories are built in and are non-configurable, as far what items appear in those categories. Each item there is a property you can set in the indicator's initialize() method, that will serve as the default when you apply the script. Autoscale, Displacement, CalculateOnBarClose, etc. Can see an alphabetical listing of all NinjaScript here:


            You can of course add plots and they will show up under the plots category. If you add any inputs, like a period calculation, they're set to display under a Parameters category. You can also customize and provide your own category name.
            Last edited by NinjaTrader_RyanM1; 08-23-2011, 12:10 PM.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Hi Ryan M,

              Many thanks, and that is pretty much as I had expected. The link you gave me is of course the same as the Help that comes with NinjaTrader.

              Incidentally, if I put in at the beginning "using System.Windows.Forms;" a MessageBox can be used which is convenient for testing and debugging, and by making some other changes, it is possible to get a console displayed and use the Console.WriteLine() method for additional output.

              csharp

              Comment


                #8
                Originally posted by csharp View Post
                Hi Ryan M,

                ... and by making some other changes, it is possible to get a console displayed and use the Console.WriteLine() method for additional output.

                csharp
                Care to detail how?

                Comment


                  #9
                  Originally posted by csharp View Post
                  Hi Ryan M,

                  Many thanks, and that is pretty much as I had expected. The link you gave me is of course the same as the Help that comes with NinjaTrader.

                  Incidentally, if I put in at the beginning "using System.Windows.Forms;" a MessageBox can be used which is convenient for testing and debugging, and by making some other changes, it is possible to get a console displayed and use the Console.WriteLine() method for additional output.

                  csharp
                  csharp, as this is more a general C# topic we could unfortunately not offer support on that.
                  BertrandNinjaTrader Customer Service

                  Comment


                    #10
                    Hi Ryan M,

                    OK, thanks, and I appreciate that general C# coding issues are outside the scope of this forum. However, as I was asked to provide details on how to get a console output, here are my suggestions, although there are still some errors that have not been fixed yet.

                    1) Add the following usings at the top:
                    using System.Text;
                    using System.IO;
                    using System.Runtime.InteropServices;
                    using Microsoft.Win32.SafeHandles;

                    2) In the Variables region of the class, add the following code (the link is given where I found this):
                    // http://social.msdn.microsoft.com/For...-0966f69ef4a2/
                    [DllImport("kernel32.dll",
                    EntryPoint = "GetStdHandle",
                    SetLastError = true,
                    CharSet = CharSet.Auto,
                    CallingConvention = CallingConvention.StdCall)]
                    private static extern IntPtr GetStdHandle(int nStdHandle);
                    [DllImport("kernel32.dll",
                    EntryPoint = "AllocConsole",
                    SetLastError = true,
                    CharSet = CharSet.Auto,
                    CallingConvention = CallingConvention.StdCall)]
                    private static extern int AllocConsole();
                    private const int STD_OUTPUT_HANDLE = -11;
                    private const int MY_CODE_PAGE = 437;

                    3) In the OnBarUpdate() method add the following code:
                    Console.WriteLine("This text you can see in debug output window.");

                    AllocConsole();
                    IntPtr stdHandle=GetStdHandle(STD_OUTPUT_HANDLE);
                    SafeFileHandle safeFileHandle = new SafeFileHandle(stdHandle, true);
                    FileStream fileStream = new FileStream(safeFileHandle, FileAccess.Write);
                    Encoding encoding = System.Text.Encoding.GetEncoding(MY_CODE_PAGE);
                    StreamWriter standardOutput = new StreamWriter(fileStream, encoding);
                    standardOutput.AutoFlush = true;
                    Console.SetOut(standardOutput);

                    Console.WriteLine("This text you can see in console window. " + CurrentBar);

                    This is only preliminary, and so far I have not found how to close the console window with
                    FreeConsole(). It also hangs after after 64 bars with a message of an invalid handle.

                    As this is more general C#, which incidentally I know less well than Java, I leave it to someone to contact me privately at [email protected] at their convenience.

                    csharp

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by rocketman7, Today, 02:12 AM
                    5 responses
                    23 views
                    0 likes
                    Last Post rocketman7  
                    Started by trilliantrader, 04-18-2024, 08:16 AM
                    7 responses
                    28 views
                    0 likes
                    Last Post NinjaTrader_BrandonH  
                    Started by samish18, 04-17-2024, 08:57 AM
                    17 responses
                    66 views
                    0 likes
                    Last Post NinjaTrader_BrandonH  
                    Started by briansaul, Today, 05:31 AM
                    1 response
                    15 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by PaulMohn, Today, 03:49 AM
                    1 response
                    12 views
                    0 likes
                    Last Post NinjaTrader_BrandonH  
                    Working...
                    X