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

Undocumented/Unsupported Ninja Tips and Tricks

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

    Originally posted by shalabh View Post
    Dear Sirs,

    Lot of interesting stuff is there on this thread. But i am searching for a very simple task i.e. import historical data into NT using code/program. NT told me it is not supported but i know it is possible and have seen one or two programs providing this feature. Can any one throw some light on it? It will be of great help. Thanks
    Which 1 or 2 programs? Are these available for purchase?

    Why won't NT import work??

    Use Excel or OpenOffice to convert your data to the NT specification, and then import.

    Or do you plan on importing like many contracts/stocks/indexes and not 1 by 1?

    Comment


      Originally posted by sledge View Post
      Which 1 or 2 programs? Are these available for purchase?

      Why won't NT import work??

      Use Excel or OpenOffice to convert your data to the NT specification, and then import.

      Or do you plan on importing like many contracts/stocks/indexes and not 1 by 1?
      +1, I'm also wondering which programs you've seen that have this functionality.

      Comment


        adding instrument after loading strategy

        hi guys, can anyone tip me about a way to add an instrument after loading the strategy script?

        original post:

        "i've created a form with buy and sell market order buttons.

        can i add, via code, a button that adds a bars object and to place orders on that instrument when the strategy is already running?

        i'm not asking how to code it, i'm asking to make sure i won't encounter any under-the-hood mechanisms that will interfere with my goal."

        thanks

        Comment


          ok for anyone who might be interested, this is how i opened a chart with two instruments and made them available for the script:

          - load a chart with two instruments instead of one

          - code Initialize() with:

          Code:
          Add(ChartControl.BarsArray[1].Instrument.FullName, ChartControl.BarsArray[1].Period.Id, ChartControl.BarsArray[1].Period.Value);
          - this way i accessed the unsupported ChartControl.BarsArrey[] that contained all instruments loaded on the chart

          - after that i added the additional Bars objects to the regular BarsArray[] via the Add() method (the base instrument was already there)

          - this isn't limited to just two instruments of course

          have fun
          Last edited by savekad; 01-01-2013, 12:33 AM.

          Comment


            Originally posted by savekad View Post
            ok for anyone who might be interested, this is how i opened a chart with two instruments and made them available for the script:

            - load a chart with two instruments instead of one

            - code Initialize() with:

            Code:
            Add(ChartControl.BarsArray[1].Instrument.FullName, ChartControl.BarsArray[1].Period.Id, ChartControl.BarsArray[1].Period.Value);
            - this way i accessed the unsupported ChartControl.BarsArrey[] that contained all instruments loaded on the chart

            - after that i added the additional Bars objects to the regular BarsArray[] via the Add() method (the base instrument was already there)

            - this isn't limited to just two instruments of course

            have fun
            Enlighten me, please. I cannot see how this is any different from just using the supported 2nd or 3rd overload for the Add() method.

            ref: http://www.ninjatrader.com/support/h...s/nt7/add3.htm

            Comment


              because with the supported Add() you have to code the instruments you want to add whereas with the offered solution you can avoid that by letting the user open a chart with what instruments he wants and the strategy will import them.

              even if you choose to input the instrument name via a user accessible property, it is still not as clean as having it on chart and already set from the get go.

              i do, however, encounter an issue where i get the following error on the output window:

              "Failed to call method 'Initialize' for strategy ... Object reference not set to an instance of an object."

              the error does not appear when commenting out the line:

              Add(ChartControl.BarsArray[1].Instrument.FullName, ChartControl.BarsArray[1].Period.Id, ChartControl.BarsArray[1].Period.Value)

              update:

              the error appears only for the collective Initialize() calls that are made when openning the strategies window. the error does not appear when loading the strategy to the chart because then the properties are already set to an instance.

              so buttom line i guess the error is not critical at all.
              Last edited by savekad; 01-02-2013, 01:45 AM.

              Comment


                Can someone enlighten me whether it would be possible through the ChartControl. to access and change the BackgroundColor of a chart to "Transparent"?

                I can change the background color to any color in the Properties section of a chart - however "Transparent" is disabled. Thus my question whether it could be possible to enable it - even though it is not then NT supported - by accessing it through ChartControl.

                And if so, any idea how the line of code would have to continue after "ChartControl. ...."

                sandman

                Comment


                  Population of ChartForm

                  I can create a chart by playing around sending keys to the Control Center, but that can be problematic because that form is really a modal dialog or at least that is the way Ninja treats it.

                  Without the above:

                  I can create a ChartForm and display it programmatically, but I have not found a way to hook up the bars objects without using ChartBars. Anyone know how to do that?

                  Leroy

                  Comment


                    P.S.

                    ChartBars is the Data Series modal dialog box.

                    I'm sure they (NT) are hooking stuff up in the processing for the OK button..

                    Leroy

                    Comment


                      LastBarPainted

                      Hi,

                      I know this is not supported but I thought I'd ask in case someone knows. If you have a single data series on a chart then you can get the last bar on the chart from

                      int lastBar = Math.Min(this.ChartControl.LastBarPainted, this.ChartControl.Bars.Count - 1);

                      What is the equivalent if you have multiple series on a single chart? I tried

                      int lastBar = Math.Min(this.ChartControl.BarsArray[1].LastBarIdx, this.ChartControl.BarsArray[1].Count - 1);

                      This does not work as


                      this
                      .ChartControl.BarsArray[seriesIndex].LastBarIdx
                      always returns -1.

                      Any thoughts would be greatly appreciated. Thank you.

                      Comment


                        if it's the X co ordinate you are after

                        int lboc = ChartControl.GetXByBarIdx(BarsArray[0],CurrentBar)+myBarWidth;

                        private int myBarWidth
                        {
                        get{ return this.ChartControl.ChartStyle.GetBarPaintWidth(Bars .BarsData.ChartStyle.BarWidthUI);}
                        set {this.ChartControl.ChartStyle.GetBarPaintWidth(Bar s.BarsData.ChartStyle.BarWidthUI);}
                        }

                        Comment


                          Thanks for the reply. No, it is not the last X coordinate. I am really after the last bar painted in a multi-series environment. I indicated the code for a single data series. I'd like the equivalent for a multi-series/multi-timeframes on the same chart situation. Thanks nonetheless.

                          Comment


                            How to use VS to debug code

                            I have and use MS Visual Studio to do my web development. It can also do C#... so I am wondering if any of you have found a way to run your custom indicator/strategy code in the VS environment so you can do proper debugging with trace, breakpoints, etc.

                            I am so tired of putting "Print(CurrentBar + ": variablename = " + variablename); into my code!! :-)

                            Thanks!
                            Bryan
                            cassb
                            NinjaTrader Ecosystem Vendor - Logical Forex

                            Comment


                              How to draw on price panel

                              I want to have a 'dashboard' display on my chart panel 1 with some indicator info in it -- kind of like how the Data Box works, only fixed in the upper right of the chart.

                              I am trying the "documented" features to do this without much success. I attached a screen shot of what I am looking for. But what I would like it to be able to change fonts and colors inside this 'box' in the upper right from my indicator code... which does not seem possible using this syntax:

                              Code:
                                          #region Draw info panel
                                          string panelText = "|                   Test                       |" + "\n| ATR: value\n| EMA: value\n| Daily High: value\n| Etc...";
                                          DrawTextFixed("InfoPanel", panelText, TextPosition.TopRight,Color.Black, new Font("Ariel", 8, FontStyle.Regular), Color.Transparent, Color.LightGray, 10);
                                          #endregion
                              Is there an undocumented way to place a dashboard panel like this onto a chart and be able to control how it looks with fonts, colors, formatting, etc?

                              Thanks!
                              Bryan
                              Attached Files
                              cassb
                              NinjaTrader Ecosystem Vendor - Logical Forex

                              Comment


                                Draw on Price Panel

                                Are you asking if there is a way to just right click with the mouse and change it...or can you put some information inside your indicator regarding color, font, etc?

                                The latter is easy to do, the former more difficult.

                                If you just want to set up some variables in your code, you can do it like this.

                                Code:
                                class YourClassName : Indicator (or Strategy)
                                {
                                ...
                                     // variable
                                     Font dashBoardFont = new Font("System", 12);
                                     Color dashBoardTextColor = Color.Black;
                                
                                ...
                                    [Description("Dashboard font")]
                                    [Gui.Design.DisplayName("Dashboard font")]
                                    [XmlIgnore()]
                                    [Category("Parameters")]
                                    public Font DashBoardFont {
                                	get { return dashBoardFont ; }
                                	set { dashBoardFont = value; }
                                    }
                                
                                    [Browsable(false)]
                                    public string DashBoardFontSerialize {
                                	get { return NinjaTrader.Gui.Design.SerializableFont.ToString(dashBoardFont ); }
                                	set { dashBoardFont = NinjaTrader.Gui.Design.SerializableFont.FromString(value); }
                                   }
                                   [Description("Dashboard text color")]
                                   [Gui.Design.DisplayName("DB Text Color")]
                                   [XmlIgnore()]
                                   [Category("Parameters")]
                                   public Color DashboardTextColor {
                                	get { return this.dashBoardTextColor ; }
                                	set { dashBoardTextColor = value; }
                                   }
                                  [Browsable(false)]
                                  public string DashboardTextColorSerialize {
                                	get { return NinjaTrader.Gui.Design.SerializableColor.ToString(dashBoardTextColor ); }
                                	set { dashBoardTextColor = NinjaTrader.Gui.Design.SerializableColor.FromString(value); }
                                  }	
                                }
                                This will serialize and be restored upon a restart. Alternatively after the setup looks good, you can then save it as the default so subsequent charts always use the same font.

                                Leroy

                                P.S. Don't know if I answered exactly what you were asking...hope so.
                                Last edited by ldissinger; 02-02-2013, 07:52 AM.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by XanderT, Today, 01:27 AM
                                0 responses
                                2 views
                                0 likes
                                Last Post XanderT
                                by XanderT
                                 
                                Started by anton_tymoshchuk, Today, 01:14 AM
                                0 responses
                                2 views
                                0 likes
                                Last Post anton_tymoshchuk  
                                Started by marco231, Yesterday, 11:32 PM
                                1 response
                                4 views
                                0 likes
                                Last Post marco231  
                                Started by sofortune, Yesterday, 10:55 PM
                                0 responses
                                3 views
                                0 likes
                                Last Post sofortune  
                                Started by sofortune, Yesterday, 10:19 PM
                                0 responses
                                9 views
                                0 likes
                                Last Post sofortune  
                                Working...
                                X