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 Hwop38, 05-04-2026, 07:02 PM
    0 responses
    168 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    322 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    246 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    350 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    179 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Working...
    X