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

Error using MiniInstrumentSelector on NT8

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

    Error using MiniInstrumentSelector on NT8

    There are several examples on this forum of using the 'MiniInstrumentSelector' class to change a chart's period:

    Code:
    MiniInstrumentSelector MIS = new MiniInstrumentSelector(ChartControl, "6RE");
    System.Windows.Forms.SendKeys.Send("{ENTER}");
    MIS.ShowDialog();
    In NT8 (8.0.15.1 64-bit), I'm getting an error in the editor: "The type or namespace name 'MiniInstrumentSelector' could not be found (are you missing a using directive or an assembly reference?).

    To follow up on the error message I've compared the items in my script's 'Using declarations' section to the same sections from 2 examples already posted in this forum:



    https://ninjatrader.com/support/foru...d.php?p=411233 (the attached ZigZagMod indicator in post 2 )

    As far as I can tell, no declarations are missing. How do I get this working for NT8?


    Many thanks!!

    #2
    Hello dave01,

    Thank you for your note.

    You could see the RolloverIndicator for NT8 at the link below,


    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Perfect, thank you very much Alan!!

      Comment


        #4
        adding a timer and a counter

        I've added a timer to trigger a symbol change every 'n' seconds. The timer/counter combination works as expected. Each time the timer triggers the event handler the counter is incremented.

        The problem comes when adding in code that communicates with the UI. Once this code is added into the timer's event handler the counter gets reset to 0 on each call to the event handler. In effect, the chart symbol is set to the first symbol in variable 'symList' over and over again.

        Putting the "Increment Counter" code above the "Change Symbol" code doesn't change anything.

        Why won't the counter hold its value anymore?


        Code:
        
        private void TimerEventProcessor(Object myObject, EventArgs myEventArgs)
        {
            TriggerCustomEvent(MyCustomHandler, myTimer.Interval);
        }
        
        private void MyCustomHandler(object state)
        {
            // CHANGE SYMBOL
        
            // explicity give the chart focus
            ChartControl.OwnerChart.Focus();
        
            // send a key event to trigger the instrument overlay selector to appear
            Keyboard.FocusedElement.RaiseEvent(new TextCompositionEventArgs(InputManager.Current.PrimaryKeyboardDevice,new TextComposition(InputManager.Current, ChartControl.OwnerChart, "open sesame")) { RoutedEvent = TextCompositionManager.PreviewTextInputEvent });
        
            // send the actual string you want in the instrument overlay selector
            Keyboard.FocusedElement.RaiseEvent(new TextCompositionEventArgs(InputManager.Current.PrimaryKeyboardDevice, new TextComposition(InputManager.Current, ChartControl.OwnerChart, symList[cntr])) { RoutedEvent = TextCompositionManager.TextInputEvent });
        
            // optionally send the enter key
            Keyboard.FocusedElement.RaiseEvent(new System.Windows.Input.KeyEventArgs( Keyboard.PrimaryDevice, PresentationSource.FromVisual(ChartControl.OwnerChart), 0,  Key.Enter)    { RoutedEvent = Keyboard.PreviewKeyDownEvent }  );
        
            // remove keyboard focus
            Keyboard.ClearFocus();
            
            // INCREMENT COUNTER
            
            Print( "Counter " + cntr.ToString() );
            Print( "Symbol " + symList[cntr] );        
        
            cntr++;
            if( cntr == symList.Length ) cntr = 0;
            
            Print( "Next Counter " + cntr.ToString() );
        }

        Comment


          #5
          Got it working without the counter. I'm guessing the counter is reset each time a new symbol is loaded. So, instead, before the code updates the chart symbol, it finds the current symbol in a symbol list, and then the next symbol in the list is set as the new symbol:

          Code:
          private void UpdateSymbol()
          {
              // find location of current chart symbol in symList
              // then assign the NEXT symbol to 'newSymbol'
              
              if (Instrument != null)
              {
                  string curSymbol = Instrument.FullName;
                  
                  //Print( "curSymbol " + curSymbol );
                  
                  for( int i = 0; i < symList.Length; i++ )
                  {
                      string tmpSymbol = symList[i];
                      
                      if( tmpSymbol == curSymbol )
                      {
                          //Print( "tmpSymbol " + tmpSymbol );
                          
                          if( i < symList.Length - 2 )
                          {
                              newSymbol = symList[i+1];
                          } 
                          else 
                          {
                              newSymbol = symList[0];
                          }
                          
                          //Print( "newSymbol " + newSymbol );
                          
                          break;
                      }
                  }    
              }
           }

          Comment


            #6
            Hello dave01,

            I would expect the counter to be getting reset each time a new symbol is being loaded.

            Good work around, thanks for sharing.

            Please let us know if you need further assistance.
            Alan P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by bortz, 11-06-2023, 08:04 AM
            47 responses
            1,610 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
             
            Started by Javierw.ok, Today, 04:12 PM
            0 responses
            22 views
            0 likes
            Last Post Javierw.ok  
            Working...
            X