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

Is there code to bring chart to front?

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

    Is there code to bring chart to front?

    Hi everyone

    Like many users, I have many charts open at the same time.

    Is the following at all possible:

    When an indicator or strategy (of my own devising) hits any 'action' point I stipulate in the code (this would normally be associated with a sound alert), does there exist any code that would immediately bring that particular chart to the foreground (so I can easily make a visual check before placing a trade)?

    Many thanks in advance for any advice with this.

    #2
    Hello arbuthnot,

    Thanks for your post.

    I first want to mention that there is no supported way to do this.

    That being said, there is an unsupported way of achieving this.

    You can add System.Windows.Forms to the using section and then use ChartControl to get handle of the Form window and then use BringToFront() on the form.

    Attached is a sample of how this works.
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Much obliged for that, Chelsea.

      I'll try it out on one of my indicators - that will be very effective.

      Just one question: what exactly do you mean by 'supported' and 'unsupported'? Do you mean this does not belong to official NinjaScript coding?

      Thanks for letting me know.

      Comment


        #4
        Hello arbuthnot,

        You are correct. Unsupported means that is not official NinjaScript code, is not documented, and we cannot offer assistance in its use.

        However, I did want to mention that it is possible.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thanks again, Chelsea.

          I really appreciate that you let me know about this as it could well prove to be extremely helpful.

          Comment


            #6
            Hi

            I'm coming back to this thread after a couple of years as I'm only now applying this for the first time.

            Also to say that I know this is not officially supported but if anyone could give me a pointer, I'd be very grateful.

            In post #2 of this thread, Chelsea kindly attached a sample indicator. I've adapted this slightly in another indicator as follows to test it:

            Code:
            if(
            CurrentBar == Count - 2
            && Close[0] > Open[0] // for example
            ) 
            			
            {
            				Form myForm = this.ChartControl.FindForm();
            			
            				myForm.BringToFront();
            }
            This compiles and works well.

            However, when I've copied this exact code into a long and complex indicator, it won't compile, with the error message:

            The type or namespace 'Form' could not be found (are you missing a directive or an assembly reference?)
            Many thanks in advance.

            Comment


              #7
              Originally posted by arbuthnot View Post
              Hi

              I'm coming back to this thread after a couple of years as I'm only now applying this for the first time.

              Also to say that I know this is not officially supported but if anyone could give me a pointer, I'd be very grateful.

              In post #2 of this thread, Chelsea kindly attached a sample indicator. I've adapted this slightly in another indicator as follows to test it:

              Code:
              if(
              CurrentBar == Count - 2
              && Close[0] > Open[0] // for example
              ) 
              			
              {
              				Form myForm = this.ChartControl.FindForm();
              			
              				myForm.BringToFront();
              }
              This compiles and works well.

              However, when I've copied this exact code into a long and complex indicator, it won't compile, with the error message:



              Many thanks in advance.
              Did you add to the using section as mentioned below?

              Comment


                #8
                Hello arbuthnot,

                Sledge is referring to the following at the top of Chelsea's code:
                Code:
                #region Using declarations
                using System;
                using System.ComponentModel;
                using System.Diagnostics;
                using System.Drawing;
                using System.Drawing.Drawing2D;
                using System.Xml.Serialization;
                using NinjaTrader.Cbi;
                using NinjaTrader.Data;
                using NinjaTrader.Gui.Chart;
                
                [B]using System.Collections.Generic;
                using System.Windows.Forms;[/B]
                #endregion

                Comment


                  #9
                  Originally posted by sledge View Post
                  Did you add to the using section as mentioned below?
                  Thanks very much, sledge.

                  I've edited my original reply as now see what you mean by then using section and I know why I didn't find it because it wasn't expanded.

                  Sorry, I've never altered anything in this section before so please excuse a newbie in this advanced type of coding.

                  I'm sure it'll work now.
                  Last edited by arbuthnot; 07-17-2015, 09:07 AM.

                  Comment


                    #10
                    Thanks to you also, Patrick.

                    I'd worked out the solution just before you posted.

                    Now I know!

                    Cheers.

                    Comment


                      #11
                      Hi again

                      I don't think there's going to be a solution to this (and I know the basic method is officially unsupported anyway) but is there a line I could add to the code so that when the chart in question is brought to the front using BringToFront, the chart is automatically brought to the right so the 'current action' is necessarily visible?

                      Thanks again in advance.

                      Comment


                        #12
                        Hello arbuthnot,

                        I am not aware of any supported or unsupported methods of controlling the chart range or scale.

                        However, this thread will remain open for any community members that would like to assist.
                        Chelsea B.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by sephichapdson, Today, 11:36 PM
                        0 responses
                        1 view
                        0 likes
                        Last Post sephichapdson  
                        Started by bortz, 11-06-2023, 08:04 AM
                        47 responses
                        1,612 views
                        0 likes
                        Last Post aligator  
                        Started by jaybedreamin, Today, 05:56 PM
                        0 responses
                        9 views
                        0 likes
                        Last Post jaybedreamin  
                        Started by DJ888, 04-16-2024, 06:09 PM
                        6 responses
                        19 views
                        0 likes
                        Last Post DJ888
                        by DJ888
                         
                        Started by Jon17, Today, 04:33 PM
                        0 responses
                        6 views
                        0 likes
                        Last Post Jon17
                        by Jon17
                         
                        Working...
                        X