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);
}
}
}
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
More than 100 subsequent user events?
Collapse
X
-
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:Tags: None
-
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.
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by CarlTrading, 03-31-2026, 09:41 PM
|
1 response
157 views
1 like
|
Last Post
|
||
|
Started by CarlTrading, 04-01-2026, 02:41 AM
|
0 responses
91 views
1 like
|
Last Post
by CarlTrading
04-01-2026, 02:41 AM
|
||
|
Started by CaptainJack, 03-31-2026, 11:44 PM
|
0 responses
143 views
2 likes
|
Last Post
by CaptainJack
03-31-2026, 11:44 PM
|
||
|
Started by CarlTrading, 03-30-2026, 11:51 AM
|
0 responses
131 views
1 like
|
Last Post
by CarlTrading
03-30-2026, 11:51 AM
|
||
|
Started by CarlTrading, 03-30-2026, 11:48 AM
|
0 responses
107 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:48 AM
|

Comment