Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
OnTimer event
Collapse
X
-
I find this help entry to be confusing, since the Syntax section for TriggerCustomEvent shows that the TriggerCustomEvent method can have either 2 or 3 arguments, whereas the Examples section gives an example with only 1 argument.Originally posted by NinjaTrader_Ray View PostYou can use the following method TriggerCustomEvent() and then you can use standard .NET System Timer class.
http://www.ninjatrader-support.com/H...stomEvent.html
Comment
-
Thanks for the feedback KBJ, please also review this reference sample using the TriggerCustomEvent() - http://www.ninjatrader-support2.com/...ead.php?t=5965
Comment
-
Sorry, I forgot to mention that I had already done that.
What I noticed was that the reference sample does not match the example given in the help.
When I implemented code in a fashion matching the reference sample (instead of matching the help example), I found that the code consistently aborted giving me a repeating message stating that NinjaTrader had to be restarted.
That was the point that I backed out the use of TriggerCustomEvent and made my earlier posting, hoping that the help would be fixed and elaborated on.
By the way, when the help is fixed, can this be posted somewhere that we can access it online, without having to wait for the next NinjaTrader update?
Comment
-
No, what I'm saying is that I had trouble with code that I wrote which looked like this....
I realize that this is not what's in the help, and it's not what's in the reference sample either. I'm confused because the help and the reference sample conflict with each other.Code:private void OnTimer(object sender, EventArgs e) { TriggerCustomEvent( new CustomEvent( TimerSynchronized ), 0 ); timer.Enabled = false; // Done with the timer. } private void TimerSynchronized(object obj) { Special_Timer_Flag = true; }
I notice that the reference sample doesn't mention "CustomEvent" at all, so does this mean it's obsolete?
Could someone who's familiar with Ninja internals please document what the parameters are supposed to be for "new CustomEvent()" and how these parameters are supposed to be used?
Comment
-
The help for TriggerCustomEvent says:Originally posted by NinjaTrader_Josh View PostNot sure why you think they conflict. They are inline with each other and will work as advertised.
new CustomEvent(MyCustomHandler, 0, "myText")Thus, there is one argument to TriggerCustomEvent in that example, which is:Code:[B][COLOR=Sienna]Examples [/COLOR][/B]... TriggerCustomEvent(new CustomEvent(MyCustomHandler, 0, "myText"));
The syntax shown for TriggerCustomEvent in the help description shows 2 or 3 arguments:Code:new CustomEvent(MyCustomHandler, 0, "myText")
and the reference sample uses 2 arguments:Code:[B][COLOR=Sienna]Syntax [/COLOR][/B] TriggerCustomEvent(CustomEvent customEvent, object state) TriggerCustomEvent(CustomEvent customEvent, int barsIndex, object state)
See what I mean?Code:TriggerCustomEvent(MyCustomHandler, myTimer.Interval);
Last edited by KBJ; 12-18-2008, 10:14 AM.
Comment
-
TriggerCustomEvent
When I call:
TriggerCustomEvent(MyCustomHandler, myTimer.Interval);
as listed in the SampleCustomEvents.cs example, I get a compiler error:
Strategy\drawtest1.cs No overload for method 'TriggerCustomEvent' takes '2' arguments CS1501 - click for info 57 4
Also, using:
TriggerCustomEvent(new CustomEvent(MyCustomHandler), e);
gives the same error.
TriggerCustomEvent(MyCustomHandler, 1, "message");
compiles, but MyCustomHandler is never called. I know from debugging that TriggerCustomEvent *is* called.
Can you tell me which invocation I should be trying to use? I expect I'm making an error somewhere, but am confused by the differences/conflicts in the examples and in the documentation.
Thanks.
Comment
-
My apologies, but of course not long after I posted my message, I tried something that finally worked. I called:
TriggerCustomEvent(new CustomEvent(MyCustomHandler), BarsInProgress, 1);
Apparently, it is important to pass in the correct 'BarsInProgress' value.
Also, note that you can also call:
TriggerCustomEvent(MyCustomHandler, BarsInProgress, 1);
If I could find documentation on CustomEvent, I might be able to figure out why that is.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
93 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
48 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
31 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
34 views
0 likes
|
Last Post
|
||
|
Started by Mindset, 02-28-2026, 06:16 AM
|
0 responses
69 views
0 likes
|
Last Post
by Mindset
02-28-2026, 06:16 AM
|

Comment