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

Test for missing data (afterhours)

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

    Test for missing data (afterhours)

    Hello,

    I'm building an indicator that seems to run into problems during afterhours when an instrument doesn't always have trades every minute. Is there any way to test if there were no trades during that minute?

    I tried if (Close[0] == null) and (Close[0] == 0) but these are both returning true, even though there are clearly gaps in the data (see attached jpg, blue circle)
    Attached Files

    #2
    What is the desired effect for this indicator?
    LanceNinjaTrader Customer Service

    Comment


      #3
      Thanks Lance.

      Goal is to compare the price of one ETF with the price of another ETF, using 1min bars. Of course it is important to do this calculation by comparing data from the exact same minute.

      During RTH there doesn't seem to be any problem, but in afterhours there are times when one ETF has data and another does not.

      The chart appears to have the data lined up correctly according to time, yet when I try to test if the series has data or not (using Close[0] for example) I'm not getting the result I thought I would.

      Is there a way to access the data (Close[0]) according to the way it is lined up on the chart, rather than how it is stored in the Closes[0] dataseries?

      2) 2nd question... how does NT treat the plot values[0] dateseries when there is no data to be added? Is there a 0, or some type of "empty" or "null"? I've seen "N/A" appear in the chart data window but I'm having trouble testing for this.

      Comment


        #4
        Originally posted by ntfred View Post
        Thanks Lance.

        Goal is to compare the price of one ETF with the price of another ETF, using 1min bars. Of course it is important to do this calculation by comparing data from the exact same minute.

        During RTH there doesn't seem to be any problem, but in afterhours there are times when one ETF has data and another does not.

        The chart appears to have the data lined up correctly according to time, yet when I try to test if the series has data or not (using Close[0] for example) I'm not getting the result I thought I would.

        Is there a way to access the data (Close[0]) according to the way it is lined up on the chart, rather than how it is stored in the Closes[0] dataseries?
        Ok thanks. When using the multi-instrument indicator Close[0] will never be null or 0 after the start.

        Instead of checking that you could check the bar's current time.

        pseudo code
        Code:
        if(BIP == 0)
          if(Times[0][0] != Times[1][0])
            return;


        This may also be of use for future reference:http://www.ninjatrader.com/support/f...ead.php?t=3572

        if you haven't done so already you will want to thoroughly understand this section: http://www.ninjatrader.com/support/h...nstruments.htm

        2) 2nd question... how does NT treat the plot values[0] dateseries when there is no data to be added? Is there a 0, or some type of "empty" or "null"? I've seen "N/A" appear in the chart data window but I'm having trouble testing for this.
        By default it will store the closing price. This will prevent null reference errors

        you can test like this
        Code:
        if (myBool)
        {
        	myBool= false;
        	Value.Set(CurrentBar);
        }
        else 
        	myBool= true;
        				
        Print(Value[0]);
        Last edited by NinjaTrader_Lance; 03-03-2013, 12:07 PM.
        LanceNinjaTrader Customer Service

        Comment


          #5
          Thank you, very helpful info here. I read all the links and sample code.

          One thing I still don't understand.... what is going on internally when "gaps" appear on the chart? If there is always a value in Closes[0], how are there blank spaces on the chart...

          I understand that Close[0] and Close[1] might have time stamps that are more than 1min apart... this is where the gap comes from initially.

          a) is the chart displaying a different internally synched dataseries that inserts "blank" values for the missing 1min intervals?

          b) or does the chart display the exact same dataseries that I can access using BarsArray, but just plot it aligned with an internally generate "map" of each minute of the day, even if the Bars didn't have all the minutes on that map?

          2) If the chart is displaying a "gap" (no data) at 6:20am... can I use code to say "show me the "value" that is held/being displayed for 6:20am?

          Comment


            #6
            Also... is the visual chart plot always synched with the Primary dataseries, or is there a way to synch the chart with the secondary series instead?

            Comment


              #7
              Could you post the screenshot of using a candle chart instead of line. I want to see if the gaps are in the bar spacing.

              A multi-series indicator will hold the same number of data points for plots as the primary series. Setting values to plots should be done in the primary series in OnBarUpdate(). If you are using calculations based off of a larger secondary series, it may plot like a step ladder because there are more data points available than there are actual meaningful data values. There is not a supported way to change the chart to another series other than the primary.
              LanceNinjaTrader Customer Service

              Comment


                #8
                Here are the screen shots...

                1) line on close. (no gaps are plotted. the chart appears to have an "interpolated" line crossing the gaps. Can the value of this interpolated line be accessed?

                2) candle chart. Gaps are visible.
                Attached Files

                Comment


                  #9
                  Right click on your chart -> Properties -> set equidistant bar spacing to true

                  There won't be a way to pull this data with the line on close but you could create a function to calculate the value if you needed. That said I don't think you'll need to when you set equidistant spacing.

                  Let me know if this doesn't resolve the issue.
                  LanceNinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by ntfred View Post
                    Here are the screen shots...

                    1) line on close. (no gaps are plotted. the chart appears to have an "interpolated" line crossing the gaps. Can the value of this interpolated line be accessed?

                    2) candle chart. Gaps are visible.
                    Use the Print() method to output the value of Close[0] to the OutputWindow. The results should tell you what happens when there is no update on a bar. I am confident that that will give you the information you need to filter the event out, or otherwise handle the issue.

                    Comment


                      #11
                      Thank You. Equidistant explains what I'm seeing.

                      Found good info on this here:

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by geddyisodin, Yesterday, 05:20 AM
                      7 responses
                      45 views
                      0 likes
                      Last Post NinjaTrader_Gaby  
                      Started by gbourque, Today, 06:39 AM
                      2 responses
                      5 views
                      0 likes
                      Last Post gbourque  
                      Started by cre8able, Yesterday, 07:24 PM
                      1 response
                      13 views
                      0 likes
                      Last Post NinjaTrader_ChelseaB  
                      Started by cocoescala, 10-12-2018, 11:02 PM
                      6 responses
                      939 views
                      0 likes
                      Last Post Jquiroz1975  
                      Started by cmtjoancolmenero, Yesterday, 03:58 PM
                      1 response
                      17 views
                      0 likes
                      Last Post NinjaTrader_Gaby  
                      Working...
                      X