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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        84 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        46 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        66 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        69 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        58 views
        0 likes
        Last Post CarlTrading  
        Working...
        X