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
    DierkNinjaTrader Customer Service

    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 zacharydw00, Today, 05:14 PM
      0 responses
      7 views
      0 likes
      Last Post zacharydw00  
      Started by shahabjet1, Today, 04:47 PM
      0 responses
      14 views
      0 likes
      Last Post shahabjet1  
      Started by aligator, Today, 04:32 PM
      0 responses
      13 views
      0 likes
      Last Post aligator  
      Started by timko, Today, 04:02 PM
      0 responses
      10 views
      0 likes
      Last Post timko
      by timko
       
      Started by asmmbillah, Today, 03:37 PM
      2 responses
      18 views
      0 likes
      Last Post asmmbillah  
      Working...
      X