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 Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        663 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        376 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        110 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        575 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        580 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X