NinjaScript > Language Reference > Data >


Print this Topic Previous pageReturn to chapter overviewNext page


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.



TriggerCustomEvent(CustomEvent customEvent, int barsIndex, object state)




Index of the bar series you want to synchronize to


Delegate of your custom event method


Any object you want passed into your custom event method




// 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());