Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem capturing events

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

    Problem capturing events

    I have been working on a strategy/indicator combo to do on-chart trading without all the clunkiness of the built in ChartTrader.

    I've been working on it mostly on a separate computer, and after copying the .cs file to the right directory on my main computer, I can't get the strategy to show up on the strategy list for a chart unless I comment out the lines that are commented out in these functions:

    Code:
            protected override void OnBarUpdate()
            {
                if( !_init )
                {
                    //ChartControl.ChartPanel.KeyDown += new KeyEventHandler( myKeyDown );
                    //ChartControl.ChartPanel.MouseUp += new MouseEventHandler( myMouseUp );
                    //ChartControl.ChartPanel.MouseMove += new MouseEventHandler( myMouseMove );
                    _init = true;
                }
            }
            public override void Dispose()
            {
                //ChartControl.ChartPanel.KeyDown -= myKeyDown;
                //ChartControl.ChartPanel.MouseUp -= myMouseUp;
                //ChartControl.ChartPanel.MouseMove -= myMouseMove;
                base.Dispose();
            }
    Anybody have any idea why this would be going wrong, and why it would have started just now?

    #2
    Hello TNixon,

    I would check the log tab of control center for any messages related to handling of the code. These are not supported properties / events. Hopefully other community members can lend a hand on what's going on here.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      This message shows up in the log when bringing up the strategy window:

      1/21/2011 9:55:11 AM Default Error on calling 'Dispose' method for 'AdvChartTrader': Object reference not set to an instance of an object.

      And this one when I close it:
      1/21/2011 9:55:22 AM Default Error on calling 'Dispose' method for NinjaScript 'AdvChartTrader': Object reference not set to an instance of an object.


      Why is Dispose even being called there? I'm guessing I can fix the problem by checking my _init variable before cleaning up the events.


      Edit: yeah, that seems to have done the trick. It's sort of annoying that you have to do initialization in OnBarUpdate, which obviously doesn't get called every time Dispose does...

      Comment


        #4
        I've not tested this (So I may try it in the morning)
        But I'd have thought you only want to setup your event handlers once. Thus a better method to use would be in the OnStartUp()
        ie:
        protected override void OnStartUp() {

        }

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        52 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        142 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        160 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        96 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        276 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Working...
        X