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

example of accountSelector.SelectionChanged for indicator?

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

    example of accountSelector.SelectionChanged for indicator?

    Hello,

    is there an example of how to subscribe to the accountSelector.SelectionChanged event for an indicator?

    the help system has one for an AddOnTab

    and it has a base.Cleanup that would not be appropriate for an Indicator...

    Thanks

    #2
    this will not compile

    private void accountSelectorChanged (object sender, AccountSelector.SelectionChangedEvent e)
    {​}

    this will compile but gets a run time error (from the help)

    accountSelector = chartWindow.FindFirst("ChartTraderControlAccountSe lector") as AccountSelector;

    accountSelector.SelectionChanged += (o, args) =>
    {
    };​

    Comment


      #3
      Hello llanqui,

      Thank you for your post.

      I am not aware of an indicator samples that use AccountSelector.SelectionChanged in the script.

      However, as it says in the sample code on the Account Selector help guide page, the code for the account selector can be carried over to any NinjaScript object you may be working on.

      Take a look at the AddOnFramework script which demonstrates using AccountSelector.SelectionChanged:




      Please take a look at the sample code which demonstrates how to properly implement the AccountSelector:



      If you have any further questions, please let us know.
      Gaby V.NinjaTrader Customer Service

      Comment


        #4
        from the help system example...this won't compile in an indicator

        // Find account selector

        accountSelector = LogicalTreeHelper.FindLogicalNode(pageContent, "accountSelector") as AccountSelector;


        this will..

        accountSelector = chartWindow.FindFirst("ChartTraderControlAccountSe lector") as AccountSelector;


        however, when loaded, I get this error

        Indicator 'AAATM01': Error on calling 'OnStateChange' method: Value cannot be null.
        Parameter name: element​

        apparently caused by this block

        accountSelector.SelectionChanged += (o, args) =>
        {
        accountChanged = true;
        Print ("AAATM01 Account CHANGED");
        };

        seems to me that the interface for the chartWindows AccountSelector is not the same as for the AddOn

        which is why I need your help...or someone else in the thread​

        thankx

        Comment


          #5
          Hello,

          My colleague made me aware of an indicator sample we have that does use AccountSelector.SelectionChanged the script. It is attached below.

          If you need any further assistance, please let us know.
          Attached Files
          Gaby V.NinjaTrader Customer Service

          Comment


            #6
            this will not compile

            accountSelector = chartWindow.FindFirst("ChartTraderControlAccountSe lector") as AccountSelector; // compiles OK
            accountSelector.SelectionChanged += accountSelectorChanged;​


            private void accountSelectorChanged (object sender, AccountSelector.SelectionChangedEvent e) // <<<<< not ok
            {
            }

            I get this compile error
            The type name 'SelectionChangedEvent' does not exist in the type 'NinjaTrader.Gui.Tools.AccountSelector'

            so, what I really need is the interface for the event....... ​​

            Comment


              #7
              Hello,

              This is demonstrated in the sample script I attached in my previous post, which I encourage you to take a look at for a complete picture of how to properly implement this within an indicator.

              For your convenience, here it is below:

              private void AccountSelector_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)

              If you need any further assistance please let me know.
              Gaby V.NinjaTrader Customer Service

              Comment


                #8
                Oh, I didn't that last post of yours...will check it..thx

                Comment


                  #9
                  works good, thank you

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Segwin, 05-07-2018, 02:15 PM
                  14 responses
                  1,789 views
                  0 likes
                  Last Post aligator  
                  Started by Jimmyk, 01-26-2018, 05:19 AM
                  6 responses
                  837 views
                  0 likes
                  Last Post emuns
                  by emuns
                   
                  Started by jxs_xrj, 01-12-2020, 09:49 AM
                  6 responses
                  3,293 views
                  1 like
                  Last Post jgualdronc  
                  Started by Touch-Ups, Today, 10:36 AM
                  0 responses
                  13 views
                  0 likes
                  Last Post Touch-Ups  
                  Started by geddyisodin, 04-25-2024, 05:20 AM
                  11 responses
                  63 views
                  0 likes
                  Last Post halgo_boulder  
                  Working...
                  X