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 guillembm, Yesterday, 11:25 AM
        2 responses
        9 views
        0 likes
        Last Post guillembm  
        Started by junkone, 04-21-2024, 07:17 AM
        9 responses
        68 views
        0 likes
        Last Post jeronymite  
        Started by trilliantrader, 04-18-2024, 08:16 AM
        4 responses
        20 views
        0 likes
        Last Post trilliantrader  
        Started by mgco4you, Yesterday, 09:46 PM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by wzgy0920, Yesterday, 09:53 PM
        0 responses
        10 views
        0 likes
        Last Post wzgy0920  
        Working...
        X