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

Time Check BarsInProgress

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

    Time Check BarsInProgress

    Good Evening,

    I'm using addeddataseries in my script. when I check the time condition using if (BarsInProgress == 2), I get signals that happens after 2:00pm. When I check time condition using if (BarsInProgress == 0), the time check works like it's suppose to. What am I doing wrong?

    if (BarsInProgress == 2)
    {
    if ((Position.MarketPosition == MarketPosition.Flat)
    && (Times[0][0].TimeOfDay >= new TimeSpan(09, 00, 00) && Times[0][0].TimeOfDay < new TimeSpan(14, 00, 00)))
    }

    #2
    I think I just figured out. Its in the timeseries check: Since I'm using addedDataSeries and if (BarsInProgress == 2), I must check Times[2][0].TimeOfDay. Right?

    Comment


      #3
      Nope. That's not it. Its still calling time outside of my time check.

      Comment


        #4
        Hello AdeptistJune,

        Thank you for your note.

        Is the script in question running On Bar Close, On Each Tick or On Price Change?

        What is the added data series?

        Are you assigning a value or triggering an order with this condition?

        Thanks in advance; I look forward to assisting you further.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          Hello Kate,

          I'm using On Bar Close.

          I'm using a 30 minute added data series.

          Yes. I assigned a Bool value and it triggers an order with this condition.

          private Series<bool> oneTimeFramingUp;

          AddDataSeries(Data.BarsPeriodType.Minute, 1); // BarsArray 1
          AddDataSeries(Data.BarsPeriodType.Minute, 30); // BarsArray 2

          oneTimeFramingUp = new Series<bool>(this);

          oneTimeFramingUp[0] = ((Times[0][0].TimeOfDay >= new TimeSpan(09, 00, 00) && Times[0][0].TimeOfDay <= new TimeSpan(15, 00, 00))
          && (Highs[2][0] > Highs[2][1])) ? true : false;
          if (BarsInProgress == 2)
          {
          if ((Position.MarketPosition == MarketPosition.Flat)
          && (Times[0][0].TimeOfDay >= new TimeSpan(09, 00, 00) && Times[0][0].TimeOfDay < new TimeSpan(15, 00, 00))
          && (oneTimeFramingUp[0] == true))
          {

          EnterLong(1, @"Set6.Long.Entry.30minute");
          }
          }

          Comment


            #6
            Hello AdeptistJune,

            Thank you for your reply.

            From what I can see here I would not expect an entry after 3pm in the most recently provided code snippet - in the original snippet you had 2 pm (14:00) but in this code snippet I would expect orders up until 3 pm (15:00). Is that what you are seeing with this code as well?

            Thanks in advance; I look forward to assisting you further.
            Kate W.NinjaTrader Customer Service

            Comment


              #7
              Hello, Kata,

              It was 14:00. I changed it to 1500 this morning to check other signals. I forgot to change it back to 14:00 before I sent you the code snippet. This is the correct snippet:

              if ((Position.MarketPosition == MarketPosition.Flat)
              && (Times[0][0].TimeOfDay >= new TimeSpan(09, 00, 00) && Times[0][0].TimeOfDay < new TimeSpan(14, 00, 00))
              && (oneTimeFramingUp[0] == true))
              {

              EnterLong(1, @"Set6.Long.Entry.30minute");
              }
              }

              Comment


                #8
                Hello AdeptistJune,

                Thank you for your reply.

                Can you confirm if you're seeing actual entries after 2 pm, or is the strategy simply staying in an open position after that time?

                If you are seeing actual entries, we would want to take a look at a reduced, compilable version of the strategy to see what may be occurring. Any code unnecessary to reproduce should be removed.

                Thanks in advance; I look forward to assisting you further.
                Kate W.NinjaTrader Customer Service

                Comment


                  #9
                  Yes. I'm seeing I'm still seeing entries outside of the time check:
                  Attached Files

                  Comment


                    #10
                    Hello AdeptistJune,

                    Thank you for your reply.

                    What is the primary series instrument, bar type and interval you are testing this on so I may best reproduce the issue? If there is a specific date you see this occurring on that would be helpful as well.

                    Thanks in advance; I look forward to assisting you further.
                    Kate W.NinjaTrader Customer Service

                    Comment


                      #11
                      Hello, Kate,

                      The primary series instrument is the ES 03-22, bar type is minute, and interval is 30.Through the 1/25 - 1/27.

                      Comment


                        #12
                        Hello AdeptistJune,

                        Thank you for your reply.

                        I'm not seeing this take trades outside the times specified in the script on my end, either in the Playback Connection using Market Replay data or in the Strategy Analyzer, with the default script settings. Are you able to reproduce this behavior on Market Reply data in the Playback Connection?

                        Thanks in advance; I look forward to assisting you further.
                        Kate W.NinjaTrader Customer Service

                        Comment


                          #13
                          Hello, Kate,

                          Your right. I'm not seeing it either. The issue was the Bars In Process call.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by proptrade13, Today, 11:06 AM
                          0 responses
                          1 view
                          0 likes
                          Last Post proptrade13  
                          Started by kulwinder73, Today, 10:31 AM
                          1 response
                          10 views
                          0 likes
                          Last Post NinjaTrader_Erick  
                          Started by RookieTrader, Today, 09:37 AM
                          3 responses
                          15 views
                          0 likes
                          Last Post NinjaTrader_ChelseaB  
                          Started by terofs, Yesterday, 04:18 PM
                          1 response
                          24 views
                          0 likes
                          Last Post terofs
                          by terofs
                           
                          Started by CommonWhale, Today, 09:55 AM
                          1 response
                          6 views
                          0 likes
                          Last Post NinjaTrader_Erick  
                          Working...
                          X