Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Market Analyzer Indicator Stuck In Loop?

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

    Market Analyzer Indicator Stuck In Loop?

    Hello,

    I want to optimize my indicator code, and I have an issue where the Market Analyzer runs the Indicator column multiple times per Instrument. I only need to run it once!

    Is there a way to scan the total bars then keep it from repeating the loop? I have the column Indicator set to 80 Days Back and I output to the console if it finds my pattern. It appears to be looping 8 times per Instrument. How can I be sure to only run the full 80 days then not loop again?

    Here's an example of my output (I only wish to check these once):

    2/20/2019 -- LWAY
    2/20/2019 -- LWAY
    2/20/2019 -- LWAY
    2/20/2019 -- LWAY
    2/20/2019 -- LWAY
    2/20/2019 -- LWAY
    2/20/2019 -- LWAY
    2/20/2019 -- LWAY
    3/4/2019 -- LUV
    3/4/2019 -- LUV
    3/4/2019 -- LUV
    3/4/2019 -- LUV
    3/4/2019 -- LUV
    3/4/2019 -- LUV
    3/4/2019 -- LUV
    3/4/2019 -- LUV
    3/12/2019 -- LONE
    3/12/2019 -- LONE
    3/12/2019 -- LONE
    3/12/2019 -- LONE
    3/12/2019 -- LONE
    3/12/2019 -- LONE
    3/12/2019 -- LONE
    3/12/2019 -- LONE
    2/13/2019 -- LOMA
    2/13/2019 -- LOMA
    2/13/2019 -- LOMA
    2/13/2019 -- LOMA
    2/13/2019 -- LOMA
    2/13/2019 -- LOMA
    2/13/2019 -- LOMA
    2/13/2019 -- LOMA
    3/12/2019 -- LKSD
    3/12/2019 -- LKSD
    3/12/2019 -- LKSD
    3/12/2019 -- LKSD
    3/12/2019 -- LKSD
    3/12/2019 -- LKSD
    3/12/2019 -- LKSD
    3/12/2019 -- LKSD
    3/8/2019 -- LIVE
    3/8/2019 -- LIVE
    3/8/2019 -- LIVE
    3/8/2019 -- LIVE
    3/8/2019 -- LIVE
    3/8/2019 -- LIVE
    3/8/2019 -- LIVE
    3/8/2019 -- LIVE
    2/6/2019 -- LIND
    2/6/2019 -- LIND
    2/6/2019 -- LIND
    2/6/2019 -- LIND
    2/6/2019 -- LIND
    2/6/2019 -- LIND
    2/6/2019 -- LIND
    2/6/2019 -- LIND
    3/11/2019 -- JMP
    3/11/2019 -- JMP
    3/11/2019 -- JMP
    3/11/2019 -- JMP
    3/11/2019 -- JMP
    3/11/2019 -- JMP
    3/11/2019 -- JMP
    3/11/2019 -- JMP
    3/6/2019 -- MDC
    3/6/2019 -- MDC
    3/6/2019 -- MDC
    3/6/2019 -- MDC
    3/6/2019 -- MDC
    3/6/2019 -- MDC
    3/6/2019 -- MDC
    3/6/2019 -- MDC
    Last edited by MrDevDevy; 03-18-2019, 11:17 AM.

    #2
    Hello MrDevDevy,
    Thanks for your post.

    Can you show us the code that generates these prints?
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_JoshG View Post
      Hello MrDevDevy,
      Thanks for your post.

      Can you show us the code that generates these prints?
      I wouldn't be able to reveal the indicator, but the section where the prints are called is uninteresting. The behavior I am expecting is for the Market Analyzer to check each bar then stop after 40 Days back is completed.Click image for larger version  Name:	indicator.png Views:	1 Size:	47.5 KB ID:	1051831

      I've now isolated the prints outside of my indicator's main logic to see what bars were being checked. My print code at OnBarUpdate() now looks like the following:
      Code:
      protected override void OnBarUpdate()
              {
                  Print(Instrument.FullName + ", " + CurrentBar + ", " + Time[0].ToString("M/d/yyyy"));
      Output (we've scanned the same bars twice):
      CEO, 0, 2/6/2019
      CEO, 1, 2/7/2019
      CEO, 2, 2/8/2019
      CEO, 3, 2/11/2019
      CEO, 4, 2/12/2019
      CEO, 5, 2/13/2019
      CEO, 6, 2/14/2019
      CEO, 7, 2/15/2019
      CEO, 8, 2/19/2019
      CEO, 9, 2/20/2019
      CEO, 10, 2/21/2019
      CEO, 11, 2/22/2019
      CEO, 12, 2/25/2019
      CEO, 13, 2/26/2019
      CEO, 14, 2/27/2019
      CEO, 15, 2/28/2019
      CEO, 16, 3/1/2019
      CEO, 17, 3/4/2019
      CEO, 18, 3/5/2019
      CEO, 19, 3/6/2019
      CEO, 20, 3/7/2019
      CEO, 21, 3/8/2019
      CEO, 22, 3/11/2019
      CEO, 23, 3/12/2019
      CEO, 24, 3/13/2019
      CEO, 25, 3/14/2019
      CEO, 26, 3/15/2019
      CEO, 0, 2/6/2019
      CEO, 1, 2/7/2019
      CEO, 2, 2/8/2019
      CEO, 3, 2/11/2019
      CEO, 4, 2/12/2019
      CEO, 5, 2/13/2019
      CEO, 6, 2/14/2019
      CEO, 7, 2/15/2019
      CEO, 8, 2/19/2019
      CEO, 9, 2/20/2019
      CEO, 10, 2/21/2019
      CEO, 11, 2/22/2019
      CEO, 12, 2/25/2019
      CEO, 13, 2/26/2019
      CEO, 14, 2/27/2019
      CEO, 15, 2/28/2019
      CEO, 16, 3/1/2019
      CEO, 17, 3/4/2019
      CEO, 18, 3/5/2019
      CEO, 19, 3/6/2019
      CEO, 20, 3/7/2019
      CEO, 21, 3/8/2019
      CEO, 22, 3/11/2019
      CEO, 23, 3/12/2019
      CEO, 24, 3/13/2019
      CEO, 25, 3/14/2019
      CEO, 26, 3/15/2019
      Last edited by MrDevDevy; 03-18-2019, 12:43 PM.

      Comment


        #4
        I haven't gotten a reply and I can't seem to solve this issue. Are there any resources to look into for this problem? Also my issue with OnBarClose is it does not include the current day; I need the current day's data. I am only calling to 3 function without any for loops. If I use OnEachTick it loops indefinitely on the current day:

        Code:
        AAPL, 2/7/2019 low: 170.34
        AAPL, 2/8/2019 low: 168.42
        AAPL, 2/11/2019 low: 169.25
        AAPL, 2/12/2019 low: 169.7
        AAPL, 2/13/2019 low: 169.92
        AAPL, 2/14/2019 low: 169.38
        AAPL, 2/15/2019 low: 169.75
        AAPL, 2/19/2019 low: 169.49
        AAPL, 2/20/2019 low: 170.99
        AAPL, 2/21/2019 low: 170.3
        AAPL, 2/22/2019 low: 171.38
        AAPL, 2/25/2019 low: 173.95
        AAPL, 2/26/2019 low: 173.17
        AAPL, 2/27/2019 low: 172.73
        AAPL, 2/28/2019 low: 172.92
        AAPL, 3/1/2019 low: 172.89
        AAPL, 3/4/2019 low: 173.97
        AAPL, 3/5/2019 low: 174.54
        AAPL, 3/6/2019 low: 173.94
        AAPL, 3/7/2019 low: 172.02
        AAPL, 3/8/2019 low: 169.5
        AAPL, 3/11/2019 low: 175.35
        AAPL, 3/12/2019 low: 179.37
        AAPL, 3/13/2019 low: 180.92
        AAPL, 3/14/2019 low: 182.56
        AAPL, 3/15/2019 low: 183.74
        AAPL, 3/18/2019 low: 185.79
        AAPL, 3/19/2019 low: 188
        AAPL, 3/19/2019 low: 188
        AAPL, 3/19/2019 low: 188
        AAPL, 3/19/2019 low: 188
        AAPL, 3/19/2019 low: 188
        AAPL, 3/19/2019 low: 188
        AAPL, 3/19/2019 low: 188
        AAPL, 3/19/2019 low: 188
        AAPL, 3/19/2019 low: 188
        AAPL, 3/19/2019 low: 188
        AAPL, 3/19/2019 low: 188
        If I leave it running we will keep seeing AAPL, 3/19/2019 low: 188
        Last edited by MrDevDevy; 03-19-2019, 08:13 AM.

        Comment


          #5
          MrDevDevy,

          I am looking into some things related to this. I'll post here when I have it figured out.

          In regards to your OnBarClose vs OnEachTick question, that is simply the way that those settings work. If you want to separate your logic you can use IsFirstTickOfBar: https://ninjatrader.com/support/help...ttickofbar.htm

          Here is a reference sample on how to separate your logic as well: https://ninjatrader.com/support/help...either_cal.htm
          Last edited by NinjaTrader_JoshG; 03-19-2019, 08:37 AM.
          Josh G.NinjaTrader Customer Service

          Comment


            #6
            I've simplified this down to as simple as I could to demonstrate this. Perhaps you can reproduce this behavior. In the OnBarUpdate I have this code:
            Code:
                  
            protected override void OnBarUpdate()
            {
               if (CurrentBar >= 19)
               {
                  Print(Instrument.FullName + ", " + Time[0].ToString("M/d/yyyy") + " low: " + Low[0]);
               }
            
            }
            The following loops over a handful of Instruments, but never continues on the other instruments in the Market Analyzer. As you can see it's never hitting TRV, UNH, UTX, ect.
            Click image for larger version  Name:	nj8.png Views:	1 Size:	170.4 KB ID:	1051937
            It's much worse for my actual use as I am using 5000+ instruments.
            Last edited by MrDevDevy; 03-19-2019, 08:43 AM.

            Comment


              #7
              MyDevDevy,

              In your screenshot it looks like those instruments did not load, so there were not OnBarUpdate() calls for them. Are you getting any errors on the Logs tab of your Control Center whenever this occurs?
              Josh G.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Jon17, Today, 04:33 PM
              0 responses
              1 view
              0 likes
              Last Post Jon17
              by Jon17
               
              Started by Javierw.ok, Today, 04:12 PM
              0 responses
              6 views
              0 likes
              Last Post Javierw.ok  
              Started by timmbbo, Today, 08:59 AM
              2 responses
              10 views
              0 likes
              Last Post bltdavid  
              Started by alifarahani, Today, 09:40 AM
              6 responses
              41 views
              0 likes
              Last Post alifarahani  
              Started by Waxavi, Today, 02:10 AM
              1 response
              21 views
              0 likes
              Last Post NinjaTrader_LuisH  
              Working...
              X