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 Waxavi, Today, 02:10 AM
      1 response
      17 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Started by Kaledus, Today, 01:29 PM
      5 responses
      13 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by Waxavi, Today, 02:00 AM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Started by alifarahani, Today, 09:40 AM
      5 responses
      23 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by gentlebenthebear, Today, 01:30 AM
      3 responses
      17 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X