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

trying to avoid indi looking at every OnBarUpdate event

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

    trying to avoid indi looking at every OnBarUpdate event

    is there any way to skip bar update events so that a divergence indicator doesn't look at every single tick but maybe every 20th or 30th ?

    i've got to change the way a divergence indicator looks at the data from looking back at FirstTickOfBar to something more frequent but i was concerned that running it CalculateOnBarClose/false might cause real processor drag.

    the indicator won't usually display accurately until sometime after first tick of bar
    and having it set to one bar late is, well, too late...

    thanks
    /w

    #2
    Originally posted by stafe View Post
    is there any way to skip bar update events so that a divergence indicator doesn't look at every single tick but maybe every 20th or 30th ?

    i've got to change the way a divergence indicator looks at the data from looking back at FirstTickOfBar to something more frequent but i was concerned that running it CalculateOnBarClose/false might cause real processor drag.

    the indicator won't usually display accurately until sometime after first tick of bar
    and having it set to one bar late is, well, too late...

    thanks
    /w
    From the way that you pose the question, I have to presume that you are going to be using COBC = false. In that case all you need to do is store the current time, use DateTime.Now.AddSeconds(double delayLength) to determine the time limit for no processing, and check that on the next bar update, the time elapsed exceeds the delayLength and if not return out of the event loop, thus allowing a fall through to the processing code, only after the delayLength has occurred.

    Comment


      #3
      thanks Koganam for that delay method - i was a bit surprised to find a response today and especially one that can push me along...
      my biggest problem is my lack of programming skills so i'll have to ruminate on this for a while and see if i can find an example - but now i definitely now what to look for...

      ? would there be a way to use Volume in a similar delay fashion ? my main use of this indicator is on volume charts

      my original attempt was going to be just an empty counter

      counter above the divergence checking section... (yes main indicator runs COBC=F; )
      private int pause = 25;
      private int x = 0;
      while (x < pause)
      { x = x + 1 }

      but not knowing how each indicator runs within the main NT "shell"
      i was concerned that multiple iterations of the indicator would be "stuck" in these delay loops and chew up processor cycles needlessly ?

      thanks again !

      Comment


        #4
        Originally posted by stafe View Post
        thanks Koganam for that delay method - i was a bit surprised to find a response today and especially one that can push me along...
        my biggest problem is my lack of programming skills so i'll have to ruminate on this for a while and see if i can find an example - but now i definitely now what to look for...

        ? would there be a way to use Volume in a similar delay fashion ? my main use of this indicator is on volume charts

        my original attempt was going to be just an empty counter

        counter above the divergence checking section... (yes main indicator runs COBC=F; )
        private int pause = 25;
        private int x = 0;
        while (x < pause)
        { x = x + 1 }

        but not knowing how each indicator runs within the main NT "shell"
        i was concerned that multiple iterations of the indicator would be "stuck" in these delay loops and chew up processor cycles needlessly ?

        thanks again !
        That should work fine to filter based on a tick count: what I outlined filters based on time.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Brevo, Today, 01:45 AM
        0 responses
        3 views
        0 likes
        Last Post Brevo
        by Brevo
         
        Started by aussugardefender, Today, 01:07 AM
        0 responses
        3 views
        0 likes
        Last Post aussugardefender  
        Started by pvincent, 06-23-2022, 12:53 PM
        14 responses
        239 views
        0 likes
        Last Post Nyman
        by Nyman
         
        Started by TraderG23, 12-08-2023, 07:56 AM
        9 responses
        384 views
        1 like
        Last Post Gavini
        by Gavini
         
        Started by oviejo, Today, 12:28 AM
        0 responses
        6 views
        0 likes
        Last Post oviejo
        by oviejo
         
        Working...
        X