Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 Spiderbird, Today, 12:15 PM
      2 responses
      10 views
      0 likes
      Last Post Spiderbird  
      Started by WHICKED, Today, 12:45 PM
      0 responses
      6 views
      0 likes
      Last Post WHICKED
      by WHICKED
       
      Started by FrazMann, Today, 11:21 AM
      2 responses
      6 views
      0 likes
      Last Post NinjaTrader_ChristopherJ  
      Started by rjbtrade1, 11-30-2023, 04:38 PM
      2 responses
      80 views
      0 likes
      Last Post DavidHP
      by DavidHP
       
      Started by lorem, Yesterday, 09:18 AM
      5 responses
      18 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Working...
      X