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

Filter Bad/Negative Ticks from within Strategy

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

    Filter Bad/Negative Ticks from within Strategy

    Hi

    I am having a unique problem of data vendor sending out Negative Incoming Ticks for only one particular symbol of BankNifty. Back-fills work perfectly and OHLC values have no issues either.
    The filter within NT7 doesn't work because there are more than 4 consecutive negative ticks too.
    The ticks are either positive or negative. When positive, they are all correct. If its wrong, it's negative.
    So, i need to create a condition for incoming tick that filters out negative ones.
    How should i do that within the strategy please?

    Some images attached for reference.

    Thank You
    Attached Files

    #2
    Hello piyushc,

    Thank you for your post.

    There would be no other means to filter the incoming ticks, unfortunately. NinjaScript does not offer any options to filter the data.

    However, you could perform checks in your code to verify the current value is not less than zero. This would allow you to wait until a specific bar value is produced or you could reload the historical data on the chart through code to force the data to reload correctly (assuming it is always correct on backfill).

    To reload the historical data it requires unsupported code but is possible through SendKeys. For example:
    Code:
                if (Close[0] < 0)
    			{
    				System.Windows.Forms.SendKeys.Send("{F5}");
    			}
    Please let me know if you have any questions.

    Comment


      #3
      Thanks Patrick.

      That sounds Good.

      Taking a leaf from that, suppose i want to refresh the data after every close of the bar, Can the following work

      protected override void OnBarUpdate()
      {
      if (Instrument.MasterInstrument.Name == "BANKNIFTY_I"
      && Low[0] < 0)
      {
      System.Windows.Forms.SendKeys.Send("{F5}");
      }
      }

      Now, the challenge in this is how can we ensure that the strategy does this calculation as the fist thing after OnBarUpdate before getting into any other conditions?

      Comment


        #4
        Hello piyushc,

        Thank you for your response.

        As long as those lines are at the beginning of OnBarUpdate() it will be the first items called.

        Please let me know if you have any questions.

        Comment


          #5
          F5 will reload the Ninja Script but i would also want to refresh the historical data.
          The chart command is CTRL+SHIFT+R

          Objective: To refresh the historical data too.

          So, can this work:

          protected override void OnBarUpdate()
          {
          if (Instrument.MasterInstrument.Name == "BANKNIFTY_I"
          && Low[0] < 0)
          {
          System.Windows.Forms.SendKeys.Send("{CTRL+SHIFT+R} ");

          System.Windows.Forms.SendKeys.Send("{F5}");

          }
          }
          Last edited by piyushc; 07-03-2017, 07:14 AM.

          Comment


            #6
            Hello piyushc,

            Thank you for your response.

            The call would be the following:
            Code:
            System.Windows.Forms.SendKeys.Send("{^}"+"{+}"+"{R}");
            Please let me know if you have any questions.

            Comment


              #7
              Thanks a lot Patrick.
              There's no way i could have reached this as a solution.

              Comment


                #8
                I'm now using the following code. Tried to make it as foolproof as possible and testing it real-time:

                if (Instrument.MasterInstrument.Name == "BANKNIFTY_I"
                && (MIN(Low, 250)[0] < 0
                || Close[0] < 0
                || Low[0] < 0 ))
                {
                System.Windows.Forms.SendKeys.Send("{^}"+"{+}"+"{R }");
                System.Windows.Forms.SendKeys.Send("{F5}");
                }
                Print(" "+Instrument.FullName+" "+Open[0]+" "+High[0]+" "+Low[0]+" "+Close[0]);

                ---

                The output i got last is:

                BANKNIFTY_I 23320.65 23327.4 -19657.07 -19636.72

                --

                Clearly, not working.

                Comment


                  #9
                  Hello piyushc,

                  Thank you for your update.

                  If you manually reload the historical data does it correct the data?

                  Comment


                    #10
                    Yes, if i manually reload the data it gets corrected.

                    Comment


                      #11
                      Awaiting your reply/inputs

                      Comment


                        #12
                        Hello piyushc,

                        Thank you for your response.

                        You will need to figure the condition that will be triggered when your data is extremely incorrect from your data source. If "Close or Low is less than 0" is not taking the actions as needed then you need to look to another condition.

                        Please let me know if you have any questions.
                        Last edited by NinjaTrader_PatrickH; 07-05-2017, 09:34 AM.

                        Comment


                          #13
                          In my opinion, this command is not refreshing the historical data at all..I have checked this on chart too:

                          System.Windows.Forms.SendKeys.Send("{^}"+"{+}"+"{R }");

                          --

                          Manually, if i refresh the data it gets corrected.

                          I am really looking for a command which is an exact equivalent of manually refreshing the chart data.

                          Presuming ^ stands for SHIFT and then + and then R, what's the symbol for CTRL?
                          Last edited by piyushc; 07-05-2017, 07:11 AM.

                          Comment


                            #14
                            Hello piyushc,

                            Thank you for your response.

                            Use the following instead:
                            Code:
                            System.Windows.Forms.SendKeys.Send("^(+R)");
                            I recommend reviewing the MSDN documentation at the following link: https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx

                            Please let me know if you have any questions.

                            Comment


                              #15
                              Thanks Patrick.

                              i went through the link and ("^(+R)") looks logical.

                              Let me test it real-time and will come back.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by RideMe, 04-07-2024, 04:54 PM
                              6 responses
                              31 views
                              0 likes
                              Last Post RideMe
                              by RideMe
                               
                              Started by tkaboris, Today, 05:13 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post tkaboris  
                              Started by GussJ, 03-04-2020, 03:11 PM
                              16 responses
                              3,281 views
                              0 likes
                              Last Post Leafcutter  
                              Started by WHICKED, Today, 12:45 PM
                              2 responses
                              19 views
                              0 likes
                              Last Post WHICKED
                              by WHICKED
                               
                              Started by Tim-c, Today, 02:10 PM
                              1 response
                              10 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Working...
                              X