Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BarrsInProgress == 1 not being activated

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

    BarrsInProgress == 1 not being activated

    I converted this from NT7. I did AddDataSeries in the State.Change.

    I have put Print("Here") in the State.Change and it shows in the Output window. But I have the Print("here2") in the BarsInProgress == 1, and it does not show in the output window.

    In my code, I need BarsInProgress == 1 occurs before BarsInProgress == 0. I dont know if that makes a difference.

    I have checked the Help Guide, but I cannot figure out why the bars in progress one is not being activated.

    I appreciate your advice. Thanks.

    -Stearno
    Attached Files
    Last edited by stearno; 02-23-2016, 07:44 AM.

    #2
    Hello stearno,

    Thank you for your post.

    Are there any errors listed in the Log tab of the Control Center when adding the indicator or strategy?
    Last edited by NinjaTrader_PatrickH; 02-23-2016, 01:51 PM.

    Comment


      #3
      error log

      Nope, there are no errors related to indicators (screenshot attached).
      Attached Files

      Comment


        #4
        stearno,

        May I test the full code? If so, could you attach it to your response in it's .cs file format from Documents\NinjaTrader 8\bin\Custom\Indicator or Strategy?

        Comment


          #5
          You add a day bar series, but issue a return after seeing it?
          Last edited by sledge; 02-23-2016, 01:29 PM. Reason: swipe keyboard correction

          Comment


            #6
            Patrick,
            Here is the full code.
            Attached Files

            Comment


              #7
              sledge pointed out the item here. You are returning the OnBarUpdate() method in lines 93 to 96 in your code:
              Code:
              				else
              				{
              					if (Bars.BarsPeriod.BarsPeriodType == BarsPeriodType.Day) return;
              				}
              Nothing gets processed passed this point if it is a daily bar.

              Comment


                #8
                Originally posted by NinjaTrader_PatrickH View Post
                sledge pointed out the item here. You are returning the OnBarUpdate() method in lines 93 to 96 in your code:
                Code:
                				else
                				{
                					if (Bars.BarsPeriod.BarsPeriodType == BarsPeriodType.Day) return;
                				}
                Nothing gets processed passed this point if it is a daily bar.
                The idea behind that is the indicator will give errors from calcs if on a day chart. So this returns after doing nothing if the chart is a daily chart. Since the chart is a minute chart, this is fine.

                Plus, as I showed with print command, It makes it to right before the bars in progress =1, also it reaches to right after that section. Finally, it makes it just fine to inside the bars in progress =2 section. All of this even with this return.

                So it is not that.

                -Stearno

                Comment


                  #9
                  in your 1st post: "But I have the Print("here2") in the BarsInProgress == 1, and it does not show in the output window."


                  I do not see "here2" at all in my output window.
                  All I see is "here".

                  I am using Playback-Market Replay on ES 06-14.

                  I used 1 minute, 2 minutes, and daily chart.

                  The dailychart only prints the very first "here". Nothing else.

                  So, yes it is the problem.

                  Comment


                    #10
                    Originally posted by sledge View Post
                    in your 1st post: "But I have the Print("here2") in the BarsInProgress == 1, and it does not show in the output window."


                    I do not see "here2" at all in my output window.
                    All I see is "here".

                    I am using Playback-Market Replay on ES 06-14.

                    I used 1 minute, 2 minutes, and daily chart.

                    The dailychart only prints the very first "here". Nothing else.

                    So, yes it is the problem.
                    I don't mean to argue, but that does not even make sense.

                    The code says:
                    Code:
                     if (Bars.BarsPeriod.BarsPeriodType == BarsPeriodType.Minute)
                    				{		
                    					
                    				}
                    				else
                    				{
                    					//if (Bars.BarsPeriod.BarsPeriodType == BarsPeriodType.Day) return;
                    				}
                    then it has
                    Code:
                    BarsInProgress == 1 
                    { 
                    Print("here2")
                    }
                    then it has
                    Code:
                    BarsInProgress == 2 
                    {
                     Print("here")
                    }
                    The print "here" shows in the output window and the print here2 does not. How is it possible that a return above all of this is the cause of one section to work but the section to not work.

                    Anyway, I removed the line you are referring to and it still only shows "here" and not "here2". It still does not work even with that code removed. So if I am not understanding something, please explain as I am always looking to improve my coding.

                    I still think there is something else wrong with the code that BarsInProgress == 1 is not being activated. It works just fine as it is written in NT7 as it is wrttien. So most likely, I think, it has something to do with initiating a another data series. NT8 is doing something different, so and it is probably something small.

                    I appreciate anyone help and guidance.

                    -Stearno

                    Comment


                      #11
                      That code is different than what you posted. That line was not commented out at all.

                      I would expect here2 to print in this case.

                      Comment


                        #12
                        Yes it is different because as I said, I removed it and it still does same thing. This proves this is jot the problem because as you can see it was removed.

                        So since that is not it could you please look over the code again and see with fresh eyes what the problem is?

                        Or support, I would appreciate your perspective on this problem as well Sledge's.

                        Comment


                          #13
                          I'll look tonight and comment out the line and see where it goes.

                          Comment


                            #14
                            Hello stearno,

                            Thank you for your response.

                            Provide the full code as it should be tested so we may investigate on our end.

                            Comment


                              #15
                              How many days do you have to load for this? It looks like 24 days is necessary for a 60 minute chart and 1,440 days for a 1 minute chart.

                              You'll see by changing your code to this, and why you aren't getting to here2 anytime soon.


                              Code:
                              			if (Bars.BarsPeriod.BarsPeriodType == BarsPeriodType.Minute)
                              				{		
                              					BarsRequired 		= 	(1440/Bars.BarsPeriod.Value);	//for 60 min chart = 24
                              					barsinaperiod		=	(1440/Bars.BarsPeriod.Value)-1;	//for 60 min chart = 23
                              					LineBegininBars		=	(1440/Bars.BarsPeriod.Value)-1;	//for 2 min chart = 23
                              					barsPivotValidFor	=	((1440/Bars.BarsPeriod.Value)*(pivotValidFor-1));
                              					
                              					Print ( "CurrentBar=" + CurrentBar + " BarsRequired=" + BarsRequired );
                              				}
                              				else
                              				{
                              					Print ( "**** CurrentBar=" + CurrentBar + " BarsRequired=" + BarsRequired );//if (Bars.BarsPeriod.BarsPeriodType == BarsPeriodType.Day) return;
                              				}
                              							
                              		if (CurrentBar <= BarsRequired) return;
                              					 
                              		if (BarsInProgress == 1)
                              			{  Print("here2");

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              602 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              347 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              103 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              559 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              558 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X