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
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
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.BertrandNinjaTrader Customer Service
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Mongo, Today, 11:05 AM
|
0 responses
1 view
0 likes
|
Last Post
by Mongo
Today, 11:05 AM
|
||
Started by Tim-c, Today, 10:58 AM
|
0 responses
1 view
0 likes
|
Last Post
by Tim-c
Today, 10:58 AM
|
||
Started by traderqz, Yesterday, 09:06 AM
|
3 responses
22 views
0 likes
|
Last Post Today, 10:36 AM | ||
Started by f.saeidi, Today, 10:19 AM
|
1 response
5 views
0 likes
|
Last Post Today, 10:31 AM | ||
Started by kujista, Today, 06:23 AM
|
5 responses
18 views
0 likes
|
Last Post
by kujista
Today, 10:26 AM
|
Comment