• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to get something to run on last bar on chart?

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

    How to get something to run on last bar on chart?

    Howdy.

    I have some various stats I have a script I have run on the end of each day, last bar of that particular session template.

    I.e. for a RTH session template of NQ, it will run on that last bar that occurs at the end of the session. My problem is that it works for every day except the very last session. So if I run the report over 15 days of data, it will collect the first 14 days, but it won't execute on the very last day, until a new day begins.

    Is there a way to get around this? Or is there a way to tell it to run on the very latest bar on the chart?

    The piece of code I am using to run at the end of the day is:
    Code:
    			if(Bars.LastBarOfSession )
    			{	
                                     Do somethign
    			}
    Last edited by forrestang; 12-14-2011, 04:47 PM.

    #2
    Hi forrestang,

    You can work with CurrentBar in relation to Count to identify the last bar on the chart.

    When CalculateOnBarClose = true:
    if (Count - 2 == CurrentBar)

    When CalculateOnbarClose = false:
    if (Count - 1 == CurrentBar)
    Ryan MNinjaTrader Customer Service

    Comment


      #3
      Thank you, that seems to be what I needed to trigger that last session run.

      Comment


        #4
        Hi,
        Will Count also work in case of MutiSymbol strategy?

        Regards

        Vivek

        Comment


          #5
          Hello Ankas,

          Thank you for your post.

          Count will work in multi-series indicators and strategies.
          Patrick H.NinjaTrader Customer Service

          Comment


            #6
            Hello,

            I tried to use marking the last bar with the information from NT-support and I do

            DrawDot("LastBar" + CurrentBar, false, 0, Low[0] - 2 * TickSize, Color.Chartreuse);

            But the dots remain below the bars, I just need a dot below the last bar.

            What do I have to change please?

            Thank you
            Tony

            Comment


              #7
              Originally posted by tonynt View Post
              Hello,

              I tried to use marking the last bar with the information from NT-support and I do

              DrawDot("LastBar" + CurrentBar, false, 0, Low[0] - 2 * TickSize, Color.Chartreuse);

              But the dots remain below the bars, I just need a dot below the last bar.

              What do I have to change please?

              Thank you
              Tony
              Try:
              Code:
              DrawDot("LastBar" , false, 0, Low[0] - 2 * TickSize, Color.Chartreuse);
              If you just want a dot below the last bar on the chart.

              Comment


                #8
                Hello,

                thanks for your help. Seems to work.

                Best regards
                Tony


                Originally posted by forrestang View Post
                Try:
                Code:
                DrawDot("LastBar" , false, 0, Low[0] - 2 * TickSize, Color.Chartreuse);
                If you just want a dot below the last bar on the chart.

                Comment


                  #9
                  Hi,
                  Try out
                  if ( CurrentBar >= ( Count -2 ))
                  DrawDot("LastBar", false, 0, Low[0] - 2 * TickSize, Color.Chartreuse);

                  Regards

                  Vivek

                  Comment


                    #10
                    Hello Tony,

                    Thank you for your post.

                    forrestang is correct here. Removing the CurrentBar from the tag string will mean there is only one tag listed so only one dot drawn. If you add a variable to the tag such as CurrentBar that updates every bar you will get a dot each time the condition to draw the dot occurs.
                    Patrick H.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Jschmelz, Yesterday, 04:45 PM
                    1 response
                    17 views
                    0 likes
                    Last Post NinjaTrader_Marco  
                    Started by sisenberg, Today, 07:29 AM
                    1 response
                    8 views
                    0 likes
                    Last Post sisenberg  
                    Started by Oceans, Today, 02:22 AM
                    2 responses
                    25 views
                    0 likes
                    Last Post Oceans
                    by Oceans
                     
                    Started by sisenberg, Yesterday, 08:06 PM
                    1 response
                    24 views
                    0 likes
                    Last Post sisenberg  
                    Started by PLeary, Today, 06:25 AM
                    1 response
                    18 views
                    0 likes
                    Last Post NinjaTrader_SergeyS  
                    Working...
                    X