![]() |
|
|||||||
| Automated Trading Support for automated trading systems using NinjaScript. Support for our ATI (Automated Trading Interface) used to link an external application such as TradeStation and eSignal to NinjaTrader. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Aug 2008
Posts: 7
Thanks: 0
Thanked 0 times in 0 posts
|
Is there an OnTimer event in NT? If not is there a work around? Thanks.
|
|
|
|
|
|
#2 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
You can use the following method TriggerCustomEvent() and then you can use standard .NET System Timer class.
http://www.ninjatrader-support.com/H...stomEvent.html
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Aug 2008
Posts: 7
Thanks: 0
Thanked 0 times in 0 posts
|
Got it. Thanks a lot!
|
|
|
|
|
|
#4 | |
|
Senior Member
Join Date: Mar 2007
Location: , Florida, USA
Posts: 663
Thanks: 36
Thanked 7 times in 6 posts
|
Quote:
|
|
|
|
|
|
|
#5 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
|
Thanks for the feedback KBJ, please also review this reference sample using the TriggerCustomEvent() - http://www.ninjatrader-support2.com/...ead.php?t=5965
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#6 |
|
Senior Member
Join Date: Mar 2007
Location: , Florida, USA
Posts: 663
Thanks: 36
Thanked 7 times in 6 posts
|
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? |
|
|
|
|
|
#7 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
Not sure I follow KBJ. Are you saying the reference sample crashed NT?
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#8 |
|
Senior Member
Join Date: Mar 2007
Location: , Florida, USA
Posts: 663
Thanks: 36
Thanked 7 times in 6 posts
|
No, what I'm saying is that I had trouble with code that I wrote which looked like this....
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? |
|
|
|
|
|
#9 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
KBJ,
Not sure why you think they conflict. They are inline with each other and will work as advertised. new CustomEvent(MyCustomHandler, 0, "myText")
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#10 | |
|
Senior Member
Join Date: Mar 2007
Location: , Florida, USA
Posts: 663
Thanks: 36
Thanked 7 times in 6 posts
|
Quote:
Code:
Examples ... TriggerCustomEvent(new CustomEvent(MyCustomHandler, 0, "myText")); Code:
new CustomEvent(MyCustomHandler, 0, "myText") Code:
Syntax TriggerCustomEvent(CustomEvent customEvent, object state) TriggerCustomEvent(CustomEvent customEvent, int barsIndex, object state) Code:
TriggerCustomEvent(MyCustomHandler, myTimer.Interval);
Last edited by KBJ; 12-18-2008 at 09:14 AM.
|
|
|
|
|
|
|
#11 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
I see. Disregard the Syntax portion and just go with what you see in either the Help Guide example or the reference sample.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#12 |
|
Senior Member
Join Date: Mar 2007
Location: , Florida, USA
Posts: 663
Thanks: 36
Thanked 7 times in 6 posts
|
I'm still confused, as the Help Guide example (1 argument, undocumented syntax) disagrees with the reference sample (2 arguments).
|
|
|
|
|
|
#13 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
KBJ,
Disregard trying to correlate the two into one overload. Just call your CustomEvent and pass the object afterwards. Easiest to just follow the reference sample.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#14 |
|
Junior Member
Join Date: Jan 2010
Posts: 3
Thanks: 0
Thanked 0 times in 0 posts
|
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. |
|
|
|
|
|
#15 |
|
Junior Member
Join Date: Jan 2010
Posts: 3
Thanks: 0
Thanked 0 times in 0 posts
|
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. |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| MouseMove event | cls71 | General Programming | 34 | 11-24-2010 06:44 AM |
| Mouse Event | shortorlong | Charting | 3 | 07-26-2008 11:59 AM |
| event-driven methods? | mktrend | General Programming | 8 | 04-29-2008 06:17 AM |
| Order Event Warning | Moda1 | Miscellaneous Support | 4 | 02-14-2008 09:44 AM |
| Chaining strategy and event | afifio | ATM Strategies (Discretionary Trading) | 6 | 06-26-2005 01:52 PM |