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 Aviram Y, Today, 05:29 AM
|
4 responses
11 views
0 likes
|
Last Post
by Aviram Y
Today, 07:57 AM
|
||
Started by algospoke, 04-17-2024, 06:40 PM
|
3 responses
26 views
0 likes
|
Last Post Today, 07:41 AM | ||
Started by bmartz, 03-12-2024, 06:12 AM
|
3 responses
30 views
0 likes
|
Last Post Today, 07:38 AM | ||
Is it possible to have a drawing, such as a line, cycle through different colors?
by gentlebenthebear
Started by gentlebenthebear, Today, 01:30 AM
|
1 response
8 views
0 likes
|
Last Post Today, 07:30 AM | ||
Started by cls71, Today, 04:45 AM
|
1 response
7 views
0 likes
|
Last Post Today, 07:25 AM |
Comment