Taking this official example:
https://ninjatrader.com/support/help...barsperiod.htm
I am setting a timer in my indicator code, but this doesnt work.
No error on the compilation, and "MyCondition" are working
What I am doing bad?
Thank you
private System.Windows.Forms.Timer alertTimer = new System.Windows.Forms.Timer();
protected override void OnStateChange()
{
if (State == State.SetDefaults) {
}
else if (State == State.Configure) {
alertTimer.Tick += new EventHandler(alertTimerFunction);
alertTimer.Interval = 1000;
}
else if (State == State.Configure) { }
else if (State == State.Terminated) {
alertTimer.Stop();
alertTimer.Tick -= new EventHandler(alertTimerFunction);
}
}
private void alertTimerFunction(Object myObject, EventArgs myEventArgs){
if (CurrentBar > 0){
TriggerCustomEvent(alertTimerEject, Close[0]);
}
}
private void alertTimerEject(object nada){
Print("alertTimerFunction " + DateTime.Now);
}
protected override void OnBarUpdate(){
if(myCondition){
Print("My condition works");
alertTimer.Start();
}
}
Comment