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

BarsinProgress and Range Bars

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

    BarsinProgress and Range Bars

    Hello Community and Support friends,

    I have developed strategies using Minute and Tick data series that uses BarsinProgress to
    do actions within the bar successfully either with Historical and Real Time data...

    BUT, when I try this using RANGE bars, there is not trigger of BarsinProgress (stays always at 0) in HISTORICAL data.

    Is there a limitation to this using multiple data series that are Range Data?

    Thanks for the tips and hints to this issue... I want to know before I start working around this issue.

    G.

    THIS WORKS :

    else if (State == State.Configure)
    {
    //0 primary
    AddDataSeries(Data.BarsPeriodType.Minute, (2)); //1
    AddDataSeries(Data.BarsPeriodType.Minute, (4)); //2
    AddDataSeries(Data.BarsPeriodType.Minute, (6)); //3
    AddDataSeries(Data.BarsPeriodType.Tick, 1); //4

    }
    }

    protected override void OnBarUpdate()
    {
    // wait for at least 1 bar to load
    if (CurrentBars[0] > 1 )
    {
    if (BarsInProgress == 0) //find condition / trigger on primary bar.
    {


    Print("targetBlue ");

    } // end barsinprogress 0


    if (BarsInProgress == 4)
    {
    // this calculates on EVERY TICK
    Print(""+isLong+" "+isShort);

    } //end barsinprogress 4 Tick

    } //end currentbars load

    } // end onbarupdate



    THIS DOES NOT WORK WITH HISTORICAL DATA but DOES WITH REAL TIME:

    else if (State == State.Configure)
    {
    //0 primary
    AddDataSeries(Data.BarsPeriodType.Range, 2); //1
    AddDataSeries(Data.BarsPeriodType.Range, 4); //2
    AddDataSeries(Data.BarsPeriodType.Range, 6); //3
    AddDataSeries(Data.BarsPeriodType.Range, 1); //4

    }
    }

    protected override void OnBarUpdate()
    {
    // wait for at least 1 bar to load
    if (CurrentBars[0] > 1 )
    {
    if (BarsInProgress == 0) //find condition / trigger on primary bar.
    {


    Print("targetBlue ");

    } // end barsinprogress 0



    if (BarsInProgress == 4)
    {
    // this calculates on EVERY TICK
    Print(""+isLong+" "+isShort);

    } //end barsinprogress 4 Ticks

    } //end currentbars load

    } // end onbarupdate

    #2
    Hello gsmaster,

    Thank you for your reply.

    I'm not seeing the same on historical data - I'm seeing a print for each bar of the 1 range series starting after the first primary bar closed. Could you supply an export of the full script so I can better see how you have this set up? Any code unnecessary to reproduce what you are seeing should be removed. If you can also provide an example of what you're seeing in the NinjaScript output window on your end for comparison purposes that would be helpful as well.

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

    Comment


      #3
      Hello gsmaster,

      I wanted to follow up with you - can you confirm, did you resolve your issue? I have not received a reply.

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

      Comment


        #4
        Hi Kate,

        I am sorry for the late reply, I was trying to do the simplest of versions of this and restart my data on NT just in case it was a weird status.

        But the problem persists, I cannot get Tick (data) on Historical...

        please use the strategy script below ...

        Thanks
        Gustav
        Attached Files

        Comment


          #5
          Hello gsmaster,

          Thank you for your note.

          The provided strategy simply adds two data series and has no conditions or actions, so you wouldn't see anything in the output window at all when it's running other than that the strategy has been enabled or disabled.

          I've taken the code from your original post and modified it slightly so you can see that yes, we do get prints for BarsInProgress == 4. This indicator adds the same data series from your original example and will print to the Output window each time the 4th added series is processed in OnBarUpdate.

          Please let us know if we may be of further assistance to you.
          Attached Files
          Kate W.NinjaTrader Customer Service

          Comment


            #6
            Hi Kate ,

            my bad , it seems that when I exported , NT did not take the latest compiled version of it...

            it should have looked like this... and this does not work for some reason ...

            and what you sent me, its exactly what I have been trying ...

            I have other strategies developed using minute bars and tick bars and everything works perfectly fine... but when I use RANGE it does not.

            else if (State == State.Configure)
            {
            AddDataSeries(Data.BarsPeriodType.Range, 32);
            AddDataSeries(Data.BarsPeriodType.Range, 1);
            }
            }

            protected override void OnBarUpdate()
            {
            if (BarsInProgress == 0)
            Print("0");

            if (BarsInProgress == 2)
            Print("2");



            }

            Comment


              #7
              Hello gsmaster,

              Thank you for your reply.

              Were you able to test with the indicator I provided? Can you give an example of the prints you see from it in the NinjaScript Output? I'm seeing this print as expected once per 1 Range bar.

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

              Comment


                #8
                Hi Kate,

                I did the test with your code (modified for extra info) and the output is what I am seeing from my side...

                Here is the output text file...
                you will see that BIP 0 goes to almost 4k bars (historical) before BIP 4 starts chiming in between....

                for reproduction info

                New Chart -> NQ 12-20 -> Range Bars 16t -> 5000 bars
                Added only the Test indicator...

                Reloaded Ninjascript and Data a couple of times during testing...

                Hope this helps for further investigation.

                G
                Attached Files

                Comment


                  #9
                  Hello gsmaster,

                  Thank you for your reply.

                  With the example script, it doesn't matter what the primary series is, this prints based on the first and 4th added series, so we're just looking at those.

                  Here's an example of what I'm seeing:

                  Processing BIP 1 for bar 2
                  Processing BIP 4 for bar 125
                  Processing BIP 4 for bar 126
                  Processing BIP 4 for bar 127
                  Processing BIP 4 for bar 128
                  Processing BIP 4 for bar 129
                  Processing BIP 4 for bar 130
                  Processing BIP 4 for bar 131
                  Processing BIP 4 for bar 132
                  Processing BIP 4 for bar 133
                  Processing BIP 4 for bar 134
                  Processing BIP 4 for bar 135
                  Processing BIP 4 for bar 136
                  Processing BIP 4 for bar 137
                  Processing BIP 4 for bar 138
                  Processing BIP 4 for bar 139
                  Processing BIP 4 for bar 140
                  Processing BIP 4 for bar 141
                  Processing BIP 4 for bar 142
                  Processing BIP 4 for bar 143
                  Processing BIP 4 for bar 144
                  Processing BIP 4 for bar 145
                  Processing BIP 4 for bar 146
                  Processing BIP 4 for bar 147
                  Processing BIP 4 for bar 148
                  Processing BIP 4 for bar 149
                  Processing BIP 4 for bar 150
                  Processing BIP 4 for bar 151
                  Processing BIP 4 for bar 152
                  Processing BIP 4 for bar 153
                  Processing BIP 4 for bar 154
                  Processing BIP 4 for bar 155
                  Processing BIP 4 for bar 156
                  Processing BIP 4 for bar 157
                  Processing BIP 4 for bar 158
                  Processing BIP 1 for bar 3
                  Processing BIP 4 for bar 159
                  Processing BIP 4 for bar 160
                  Processing BIP 4 for bar 161
                  Processing BIP 4 for bar 162
                  Processing BIP 4 for bar 163
                  Processing BIP 4 for bar 164
                  Processing BIP 4 for bar 165
                  Processing BIP 1 for bar 4
                  We'd expect to see more prints for BIP 4 than BIP 1, obviously. This doesn't seem to be what you're seeing, so the first thing I would look at is your version of NinjaTrader. What version are you using? You can find this under Help > About. The current version is 8.0.22.2.

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

                  Comment


                    #10
                    Hi Kate,

                    thanks for the continued follow up... and you are correct,, that is what I would like to see...

                    If I have 5000 bars preloaded on a chart and I run the script... I see ONLY the EXPECTED function of the script once we have reached
                    the last bars and real time data is coming in... in other words.. it is ignoring historical data...

                    also for extra information, this issue is NOT present when I use minute data and tick data... this works as expected in HISTORICAL and REAL TIME data.

                    here is my version

                    8.0.22.2 64-bit

                    I wonder if this has something to do with the stored data from the symbol?

                    Thanks
                    Last edited by gsmaster; 09-28-2020, 02:20 AM.

                    Comment


                      #11
                      Hello gsmaster,

                      Thank you for your reply.

                      You're on the current version, so that shouldn't be an issue.

                      If you clear your cache, does the issue persist?

                      To delete the cache, follow the steps below.
                      • Shut down NinjaTrader.
                      • Open the Documents > NinjaTrader 8 > db folder.
                      • Delete the sub-folder named 'cache'.
                      • Restart NinjaTrader and test.

                      Please let us know if we may be of further assistance.
                      Kate W.NinjaTrader Customer Service

                      Comment


                        #12
                        Hi Kate,

                        I deleted cache and followed steps... unfortunately, result is the same...

                        this is so strange.., there must be a bug somewhere ...

                        As you can see once bar 4860 is reached (40 bars before reaching the last REAL TIME bars) then BIP 4 starts coming in...

                        Hope we can find a solution to this or if it is a bug that NT dev team can fix it for the next release..

                        Thanks
                        G
                        Attached Files

                        Comment


                          #13
                          Hello gsmaster,

                          Thank you for your reply.

                          I'm not seeing this occur when using the indicator on just historical data on a chart no matter how I've tested thus far.

                          Is this occurring in the Strategy Analyzer? Or on a live chart?

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

                          Comment


                            #14
                            This is happening on a live chart. I have really no idea how come this is happening. Again, i do not have this issue with 1 Min 1 Tick...
                            Maybe it helps to say that I have live strategies running but not on the same instrument?

                            Comment


                              #15
                              Hello gsmaster,

                              Thank you for your reply.

                              I've created a short video illustrating exactly how I'm testing:



                              I've modified the original test indicator, which I'll also attach so you can better tell what state the script is currently in. This will print when the primary series on the chart updates as well as when a 1 Range added series updates, and should match what I'm seeing in the above video. Can you confirm you're seeing something different when repeating the same test?

                              Strategies running on a different instrument would generally have no affect on an indicator running on a different instrument.

                              I look forward to your reply.
                              Attached Files
                              Kate W.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by wzgy0920, 04-20-2024, 06:09 PM
                              2 responses
                              26 views
                              0 likes
                              Last Post wzgy0920  
                              Started by wzgy0920, 02-22-2024, 01:11 AM
                              5 responses
                              32 views
                              0 likes
                              Last Post wzgy0920  
                              Started by wzgy0920, Yesterday, 09:53 PM
                              2 responses
                              49 views
                              0 likes
                              Last Post wzgy0920  
                              Started by Kensonprib, 04-28-2021, 10:11 AM
                              5 responses
                              192 views
                              0 likes
                              Last Post Hasadafa  
                              Started by GussJ, 03-04-2020, 03:11 PM
                              11 responses
                              3,234 views
                              0 likes
                              Last Post xiinteractive  
                              Working...
                              X