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

NT8 - Where to define MouseEvents

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

    NT8 - Where to define MouseEvents

    Hello,

    I would like to use MouseEvents like these:

    ChartPanel.MouseLeftButtonUp += new MouseButtonEventHandler(myMouseEvents);

    ChartPanel.MouseLeftButtonUp -= midasMouseEvents;

    Where do i have to define them?

    Currently they are located in State.Configure and State.Terminated but i get some errors in the Ouput:

    Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.

    Thank you,
    Mike

    #2
    Hello,

    Thank you for the question.

    In general the error Object reference not set to an instance of an object indicates that in one of these states, the object you are trying to use is null.

    This could potentially be caused by the nature of the states in combination with not checking if the object is null.

    To start you can try adding a null check, this should resovle the error you are getting.


    Code:
    if(ChartPanel != null)
    {
       // execute code
    }
    Also you may want to move this logic to State.Historical, ChartControl and its sub objects should only be accessed from State.Historical and after, this likely would include the charts panel as well.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by traderqz, Today, 09:44 AM
    2 responses
    4 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by stafe, 04-15-2024, 08:34 PM
    8 responses
    40 views
    0 likes
    Last Post stafe
    by stafe
     
    Started by rocketman7, Today, 09:41 AM
    2 responses
    6 views
    0 likes
    Last Post rocketman7  
    Started by rocketman7, Today, 02:12 AM
    7 responses
    31 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by guillembm, Yesterday, 11:25 AM
    3 responses
    16 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Working...
    X