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

Select window and then tab that indicator is running on

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

    Select window and then tab that indicator is running on

    Hi,

    In a situation where I have multiple windows with multiple tabs open on each window, I am trying to have code within an indicator that will find and focus on the tab with the indicator running then use the SendKey.Wait method.

    I am unable to get the tab to become focussed in the first instance.

    I am using .Focus() within a dispatcher then checking using .IsFocused however I cannot get IsFocused to become true.

    Can you please suggest the correct use of code to focus on the tab with the indicator running please.

    Thanks

    #2
    My current attempt is as follows, but it doesn't results in IsTabFocussed being false;

    __________________________________________________ _______________________________-



    private NinjaTrader.Gui.Chart.ChartTab chartTab;
    private Chart chartWindow;
    private System.Windows.Controls.TabItem tabItem;



    protected override void OnBarUpdate()
    {

    ChartControl.Dispatcher.InvokeAsync((Action)(() =>
    {

    chartWindow = Window.GetWindow(this.ChartControl.Parent) as Chart;
    if(chartWindow==null)
    {
    Print("chartWindow== null");
    return;
    }

    foreach (System.Windows.Controls.TabItem tab in chartWindow.MainTabControl.Items)
    if ((tab.Content as ChartTab).ChartControl == ChartControl && tab == chartWindow.MainTabControl.SelectedItem)
    tabItem=tab;

    if (tabItem == null)
    return;

    chartTab = tabItem.Content as NinjaTrader.Gui.Chart.ChartTab;
    if (chartTab == null)
    return;

    chartTab.Focus();

    Print(chartTab.IsFocused);


    }));

    }

    Comment


      #3
      Hello b16_aln,

      This would be far outside of what is documented or supported by NinjaTrader but may be possible.

      This thread will remain open for any community members that would like to assist.


      I have a few indicators that can recognize if the chartcontrol they are added to is the one in focus you may find helpful.
      Hello All, Moving forward this will be maintained in the help guide reference samples and no longer maintained on the forum. Creating Chart WPF (UI) Modifications from an Indicator - https://ninjatrader.com/support/help...ui)-modifi.htm (https://ninjatrader.com/support/helpGuides/nt8/creating-chart-wpf-(ui)-modifi.htm) I've
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Hi Chelsea,

        Yes, I used your rollover indictor as the basis for my attempt at the code, so thank you for that, however I was unable to get it to work as I intended. I think I know how I need to the code to differ but was unable to implement it hence reaching out for help, very glad it was you that responded!

        I don't think I am too far off what I want to achieve and hoped you could help.

        The first difference and confusion for me is transforming parts of the rollover code so that it doesn;t work based on a button and click event and is instead triggered by an IF statement. I'm not sure how to ammend the RolloverBtn_Click method so that I can use it based on and IF statement, I think the use of an object sender in the method initiator is the problem for me. Could you please suggest how to edit the method for use with an IF statement instead? I can then use that to send the keys I want to use.

        Secondly, i can use TabSelected to ensure I'm on the correct chart, however the TabChangedHandler works to check that the tab i've manually selected is the correct tab so this is no good for what i'm looking for however I believe it used a lot of the same concepts so I hoped to be able to modify and it get it to where I need it to be. In the simplest of explanations I am only looking to find, activate and focus on the tab with the indicator running so si can then use your version of send keys (RolloverBtn_Click). I thought it might be as easy as using ChartControl.OwnerChart.Focus() however that doesn;t appear to work so I thought I would need to do something similar to the TabChangedHandler but instead of reacting to a manual change in tab selection I wanted it to find the correct tab, possibly by looping through all open tabs and windows and until TabSelected ==true.

        I would really appreciate your help if you have the time.

        Thanks




        Comment


          #5
          Hello b16_aln,

          When do you want the code to be evaluated?
          Put the code in the action block for that event or action in an if statement.

          I do not have any suggestions for changing the selected tab on a chart which is not supported by NinjaTrader.

          This thread will remain open for any community members that would like to suggest unsupported code to achieve this.

          You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our business development follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Rollover indicator isn't supported by NinjaTrader but you give plenty of advice on that. In fact, there are numerous examples of you giving advice on code not supported by ninjatrader.

            You've been of not help at all, your colleagues are much more helpful.

            I'll make your employers aware of your poor customer service as I'm sure they take the service received by their paying customers a lot more seriously than you appear to do.

            Comment


              #7
              Hello b16_aln,

              Specifically, changing the selected tab on a chart is not supported.

              The Rollover indications indicator does not do this, however the rollover indications does use unsupported code to send key presses to change the instrument which officially is not supported by NinjaTrader.

              See another forum post where a colleague of mine is also stating this is not supported.
              https://ninjatrader.com/support/foru...100#post772100

              Please note as you report my behavior, that you are specifically asking for code that is not supported or documented. Also, please include a link to this forum thread.
              Last edited by NinjaTrader_ChelseaB; 03-31-2020, 11:33 AM.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                So you pick and choose what unsupported questions you are willing to help with? I assume this is based on your general mood at the time and what you can be bothered doing?

                I notice others have questioned your attitude in the past so I'm sure this will not be the first time your employers will have received poor feedback on your customer service skills. You may be a good coder, but your customer service skills in supporting paying customers falls woefully short...which appears to be what your job is.

                Comment


                  #9
                  Hello b16_aln,

                  When it comes to unsupported code, if I know of something that may work that is undocumented but I can provide a resource or a link to a 3rd party site I will. In this case I don't know of a way to achieve what you are asking and I have nothing to suggest. As its unsupported, you will need to work out something on your own if there is a way, or you can submit a feature request for our development to put under consideration.

                  I apologize you feel that I am presenting a bad attitude. I am very happy to assist with any documented NinjaScript you have questions about and I am not intentionally attempting to be rude or use bad language. However, my job is to assist with developers in understanding supported tools in the help guide and due to resource constraints am I not allowed to fully support unsupported items.

                  Our standard spiel is below:

                  Unfortunately, in the support department at NinjaTrader it is against our policy to create, debug, or modify, code or logic for our clients. This is so that we can maintain a high level of service for all of our clients as well as our partners.

                  We do have a large ecosystem available to help you with unsupported code or programming logic questions. You can post on our forum and ask the other 40,000+ forum members.


                  You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our business development follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request.
                  Chelsea B.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by DJ888, 04-16-2024, 06:09 PM
                  6 responses
                  18 views
                  0 likes
                  Last Post DJ888
                  by DJ888
                   
                  Started by Jon17, Today, 04:33 PM
                  0 responses
                  1 view
                  0 likes
                  Last Post Jon17
                  by Jon17
                   
                  Started by Javierw.ok, Today, 04:12 PM
                  0 responses
                  6 views
                  0 likes
                  Last Post Javierw.ok  
                  Started by timmbbo, Today, 08:59 AM
                  2 responses
                  10 views
                  0 likes
                  Last Post bltdavid  
                  Started by alifarahani, Today, 09:40 AM
                  6 responses
                  41 views
                  0 likes
                  Last Post alifarahani  
                  Working...
                  X