Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

More than 100 subsequent user events?

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

    More than 100 subsequent user events?

    I am trying to use a timer but iam getting this when i go live sim. The timer start is within onbarupdate. why do i get this? and why do i get this even though conditions have not been met within onbarupdate to even call the timer to start?

    Code:
    		
                    private void timer()
    		{
    			myTimer.Tick += new EventHandler(TimerEventProcessor);
    			myTimer.Interval = 5000;
    			myTimer.Start();
    		}
    		
    		private void TimerEventProcessor(Object myObject, EventArgs myEventArgs)
    		{
    			// Important to use the TriggerCustomEvent() to ensure that NinjaScript indexes and pointers are correctly set.
    			// Do not process your code here. Process your code in the MyCustomHandler method.
    			TriggerCustomEvent(MyCustomHandler, 0, myTimer.Interval);
    		}
    		
    		private void MyCustomHandler(object state)
    		{//cancels working orders after 5 seconds
    				if (priceFeed == ConnectionStatus.Connected && orderFeed == ConnectionStatus.Connected)
    				{
    					if (buy != null && OrderState.Working == buy.OrderState)
    						{
    							CancelOrder(buy);
    						}
    					if ( sell != null && OrderState.Working == sell.OrderState )
    						{
    							CancelOrder(sell);
    						}
    					if ( sellshort != null &&  OrderState.Working == sellshort.OrderState )
    						{
    							CancelOrder(sellshort);
    						}
    					if (  buytocover != null &&  OrderState.Working == buytocover.OrderState )
    						{
    							CancelOrder(buytocover);
    						}
    						
    				}
    		}

    #2
    ericson, you would need to debug further - the timer must be getting started otherwise it would not throw that user events message, which is a safeguard for NS strategies to limit the # of potential user events per bar, so before control from the event queue is given back to NT's core processing, that # could be increased, but our suggested approach would be first understanding why this high a # of custom events would be thrown for your code.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    566 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    330 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    547 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    548 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X