Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using Prior Day OHLC for Indicator in Market Analyzer is unpredictable

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

    Using Prior Day OHLC for Indicator in Market Analyzer is unpredictable

    Hi All,

    I created a new indicator that I am using in Market Analyzer but for some reason the Prior Day OHLC values are unpredictable. In the indicator I am simply printing out the values for the current day OHL and prior day OHLC and 200 bar SMA and 200 bar EMA using 1 minute chart. If I look at the values that get printed out via my indicator versus opening a chart and adding the Prior Day OHLC indicator to the chart, the values are different.

    Here is a snippet of code that prints out the lines when OnBarUpdate gets called:

    if (PriorDayOHLC().PriorClose.ContainsValue(0))
    Print("Prior Close: "+ PriorDayOHLC().PriorClose[0].ToString("C"));

    if (PriorDayOHLC().PriorHigh.ContainsValue(0))
    Print("Prior High: "+ PriorDayOHLC().PriorHigh[0].ToString("C"));

    if (PriorDayOHLC().PriorLow.ContainsValue(0))
    Print("Prior Low: "+ PriorDayOHLC().PriorLow[0].ToString("C"));

    if (PriorDayOHLC().PriorOpen.ContainsValue(0))
    Print("Prior Open: "+ PriorDayOHLC().PriorOpen[0].ToString("C"));

    Print("Current High: "+ CurrentDayOHL().CurrentHigh[0].ToString("C"));
    Print("Current Low: "+ CurrentDayOHL().CurrentLow[0].ToString("C"));
    Print("Current Open: "+ CurrentDayOHL().CurrentOpen[0].ToString("C"));

    Print("SMA 200: "+ SMA(200)[0].ToString("C"));
    Print("EMA 200: "+ EMA(200)[0].ToString("C"));


    Any ideas on why we would have some sort of discrepancy?

    Thanks for any help!
    - Eric
    Attached Files

    #2
    Hello ericmacd,

    Thank you for writing in. I have tested the code you provided and it is providing the correct results on my end. I have attached a screenshot of my results (highlighted with color for clarity).

    Is this not what you are seeing? If not, can you please provide a screenshot of what you are seeing?

    Thank you in advance.
    Attached Files
    Michael M.NinjaTrader Quality Assurance

    Comment


      #3
      More Info

      Hi Michael,

      Thank you for your quick response. If you have the data, can you try TSLA with 1 minute bars and COBC set to true? Also I'm assuming you added the indicator to the Market Analyzer and not a chart but could you confirm? I added it to a chart and it worked fine. It only outputs incorrect data when added to the Market Analyzer which we need for scanning the market.

      I included a picture of what I'm seeing.

      Thank you for your help!

      Best regards,
      Eric
      Attached Files

      Comment


        #4
        Hi Eric,

        I've added your script to a TSLA 1 minute chart with Calculate on bar close set to True.

        Attached is a screenshot of how this looks on my end.

        In your screenshot I am not able to see that the TestOHLC indicator was added to your chart.

        Is there a different script you are using on the chart in your screenshot?
        Attached Files
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi Chelsea,

          Thanks for taking a look. The issue only happens when we add the TestOHLC indicator to the "Market Analyzer". On my chart I added PriorDayOHLC and CurrentDayOHL indicators to illustrate that we are getting incorrect data. Here are the steps I used on how to reproduce the issue:

          Open a Market Analyzer window (Control Center -> File -> New -> Market Analyzer)
          In the Market Analyzer window, right click, go to Add Instrument and add TSLA
          Right click in the Market Analyzer again, go to Columns, select Indicator, click New
          On the right side in the Indicator Properties Window, change the indicator to TestOHLC
          Change the Calculate on bar close to True
          Make sure Data series is set for 1 minute bars
          Click on OK

          Open a new chart (Control Center -> File -> New -> Chart..)
          Right click and select Data Series
          Make sure we are using 1 minute bars and then click OK

          Right click and add indicators for PriorDayOHLC and CurrentDayOHL
          Open a Data Box window

          Open an Output Window

          Move the cursor over some time period in the chart and compare the Current Day OHL and Prior Day OHLC to the values that are in the Output Window

          The Prior Day data is different from the Output Window to what I see in the Data Box.

          Thanks for your help!

          Best regards,
          Eric

          Comment


            #6
            Hello Eric,

            Thank you for confirming that when the script is added to a chart that this works correctly without issue.

            In the Market Analyzer, how many # of bars to look back do you have set?
            You must include enough bars that the PriorDayOHLC indicator can calculate correctly.

            I have set my # of bars to look back to 2800. (There are 1400 minutes in a day and I quickly wanted to make sure there are enough 1 minute bars for two days of data)

            Attached is a screenshot showing this indicator in the Market Analyzer with Calculate on bar close set to true with 2800 bars loading.
            Attached Files
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hi Chelsea,

              I set the bars back to 5000 and am still getting the same issue on my development computer. However, I tried running the exact same code on a different computer with a different data feed and it is working perfectly on the other computer... The computer that is not working I have NT 7.0.30 and NT 8 Beta installed. The other computer only has NT 7.0.30 installed. Could that cause any issues? Maybe I need to reload ninja or data or ?? Would instrument lists/setup cause any types of issues? Any ideas..?

              Thanks for your help.

              Best regards,
              Eric

              Comment


                #8
                Hi Eric,

                I wouldn't think that would cause an issue...

                When added to a chart the indicator prints the right values, so I wouldn't think its an issue with the historical data..

                Can you send a screenshot of the settings for the indicator column in the Market Analyzer?
                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by bortz, 11-06-2023, 08:04 AM
                47 responses
                1,607 views
                0 likes
                Last Post aligator  
                Started by jaybedreamin, Today, 05:56 PM
                0 responses
                9 views
                0 likes
                Last Post jaybedreamin  
                Started by DJ888, 04-16-2024, 06:09 PM
                6 responses
                19 views
                0 likes
                Last Post DJ888
                by DJ888
                 
                Started by Jon17, Today, 04:33 PM
                0 responses
                6 views
                0 likes
                Last Post Jon17
                by Jon17
                 
                Started by Javierw.ok, Today, 04:12 PM
                0 responses
                15 views
                0 likes
                Last Post Javierw.ok  
                Working...
                X