NinjaScript > Language Reference > Data >

TriggerCustomEvent()

Print this Topic Previous pageReturn to chapter overviewNext page

Definition

This method provides a way to use your own custom events (such as a Timer object) so that internal NinjaScript indexes and pointers are correctly set prior to processing user code triggered by your custom event. When calling this event, NinjaTrader will synchronize all internal pointers and then call your custom event handler where your user code is located.
 

Method Return Value

This method does not have a return value.

 

Syntax

TriggerCustomEvent(CustomEvent customEvent, int barsIndex, object state)

 

Parameters

barsIndex

Index of the bar series you want to synchronize to

CustomEvent

Delegate of your custom event method

state

Any object you want passed into your custom event method

 

 

Examples

// Your timer object's tick event handler
private void TimerEventProcessor(Object myObject, EventArgs myEventArgs)
{
    // Do not process your code here but instead call the TriggerCustomEvent()
    // method and process your code in the MyCustomHandler method
    TriggerCustomEvent(MyCustomHandler, 0, "myText");
}
 
private void MyCustomHandler(object state)
{
    Print((string) state + " " + CurrentBar.ToString());
}