Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SampleCustomEvents question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    SampleCustomEvents question

    Greetings,

    I have a question regarding the "Timer" code setup provided in the "CustomEvents" Sampler. The setup for a timer is provided as something similar to this:

    //in "Variables"
    private System.Windows.Forms.Timer myTimer = new System.Windows.Forms.Timer();
    //in "OnBarUpdate"
    if (CurrentBar == 0)
    {
    // Initiate our Timer object with an interval of 120000ms (2 minutes)
    myTimer.Tick += new EventHandler(TimerEventProcessor);
    myTimer.Interval = 120000;
    myTimer.Start();
    }


    I'm using this code and it seems to work fine. My one issue is, however, that a new instance of the event is added each time (every 2 minutes). Thus the first time the Timer runs everything is fine, 2 minutes later the event is called twice, 2 minutes later the event is called 3 times, 2 minutes later the event is called 4 times...etc

    How do I prevent additional instances from being called each run? Is a variable needed or is it something with that code above?

    #2
    Sorry, this is native C# programming support which is beyond teh scope what we can provide. As last report you could contact a certified NinjaScript consultant: http://www.ninjatrader.com/webnew/pa...injaScript.htm

    Comment


      #3
      OK, well I posted the question because it is taken directly from a "Sample" provided by NT staff, thus I would have thought it would be supported.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CaptainJack, 05-29-2026, 05:09 AM
      0 responses
      619 views
      0 likes
      Last Post CaptainJack  
      Started by CaptainJack, 05-29-2026, 12:02 AM
      0 responses
      420 views
      0 likes
      Last Post CaptainJack  
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      293 views
      1 like
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      414 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      367 views
      0 likes
      Last Post CarlTrading  
      Working...
      X