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

total number of bars onrender and period

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

    total number of bars onrender and period

    Hello,

    I am confuse does substract 631 bars from

    for(int barIndex = (ChartBars.ToIndex) - 631; barIndex <= (ChartBars.ToIndex); barIndex++)

    means barIndex start at bar 631 to currentBar or the opposite ?

    I am trying to get all the bars in the chart from exemple barIndex 631 ------> CurrentBar right side of the chart.

    Now i want to replace 631 by period and set a period in indicators proprieties so i can change the number in the indicator without having to compile every time, is it possible?

    #2
    Hello frankduc,

    The ChartBars.ToIndex is the last visible bar on the chart.
    The ChartBars.FromIndex is the first visible on the chart.



    This allows you to only render within the viewable space on the chart with the range of visible bars..

    With ChartBars.ToIndex - 631 this would be a hard coded 631 bars to the left of the last visible bar on the chart. If this was more bars than on the chart, the coordinates may be outside of the chart.

    The 631st bar that is hard coded before the last bar on the chart could be an input public input if you would like.

    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Sorry i dont get it.

      Like i said i want
      to get all the bars in the chart from barIndex 631 of 2100 to last bar right side of the chart.

      I want my barindex to represent 1471 bars included between 631 and 2100.

      I dont need the viewable thing.


      Last edited by frankduc; 07-10-2019, 11:42 AM.

      Comment


        #4
        Hello frankduc,

        I'm not certain what you are wanting, but if you would like to render over bars of the chart, the bar indexes would likely need to be the visible bar indexes for rendering..

        But if you are just wanting to trigger actions for certain bar numbers, likely the ChartBars ToIndex or FromIndex wouldn't be needed.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          I want the barIndex to include the bars from 631 to 2100 which is the last bar of the chart (right side of the chart currentbar)

          For exemple this include all the bars between : cursorPointX and
          ChartBars.ToIndex

          for(int barIndex = ChartBars.GetBarIdxByX(chartControl, cursorPointX); barIndex <= ChartBars.ToIndex; barIndex++)

          bars 631 begin 300 bars before cursorPointX

          Its simple its the barIndex in the data box 631 of 2100 i want the barIndex to includes bars from 631 to 2100

          Comment


            #6
            Hello frankduc,

            What if bar 631 isn't in view?

            Are you wanting to do things with bars that are not in view?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              That's something that never came to my mind. Are you saying that in
              for(int barIndex = ChartBars.GetBarIdxByX(chartControl, cursorPointX); barIndex <= ChartBars.ToIndex; barIndex++) if the part from cursorPointX is not in view it will not include the bars out of the chart in the for loop?

              You know its ok because i always keep enough bars in the chart to make sure the for loop includes all the bars. If i cant see the bars in the chart how will i be able to make my calculation works. I am building a new cumulative moving average.

              So as long as i got barIndex 631 to 2100 its ok.

              Comment


                #8
                Hello frankduc,

                If you aren't doing rendering stuff, then you probably don't need to worry about the visible bars on the chart.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  I think you are the one who introduce me to the file
                  MouseXYtoTimePriceExample.
                  .

                  Would it be possible to transfer a part of the script and use it to draw a blue dot at a specific position using the same methods?

                  The way i see it i need:

                  private System.Windows.Media.Brush ellipseBrush;
                  private SharpDX.Direct2D1.Brush ellipseBrushDX;

                  ellipseBrush = Brushes.Blue.Clone();

                  and

                  SharpDX.Vector2 ellipseVector = clickPoint.ToVector2();
                  newEllipses.Add(new SharpDX.Direct2D1.Ellipse(ellipseVector, 10f, 10f));


                  I suppose the (=) part lead to the positioning of the object but i wonder if its possible to use the x and y to position the dot?

                  https://ninjatrader.com/support/help...etybyvalue.htm

                  Comment


                    #10
                    Hello frankduc,

                    The MouseXYtoBarTimePriceExample script is generally meant to demonstrate how to translate a mouse click into a time and price. ClickDraw is meant to convert mouse coordinates to drawing coordinates.



                    Are you trying to draw a dot on bar 631? You need to check first that bar 631 is a visible bar on the chart.

                    The RolloverIndications saves a few bar numbers for drawing a lines on them. This may be similar.
                    Shows a button on the chart to roll the expiry to the next available contract month. Option to hide button until a number of days before or on roll date. Another option to confirm by opening the instrument overlay selector or automatically rollover without confirmation. (Update June 27th, 2019 &#8211; Added an option to show [&#8230;]



                    The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Well my variable returns a bar number so it can be 631 or any visible bar on the chart.

                      I am not very competent with c# nor with SharpDX which seems to be a c# thing more than a Ninjatrader component.

                      If i could find something similar that i could copy or easily adapt that would save me learning time. It doesn't have to be a dot it could be an arrow, etc.

                      Its like clickPoint.X = ChartingExtensions.ConvertToHorizontalPixels(e.Get Position(ChartControl as IInputElement).X, ChartControl.PresentationSource);
                      need to be adapt or change for the bar position?

                      I suppose by the
                      GetYByValue.

                      Comment


                        #12
                        Hello frankduc,

                        I don't understand what you are wanting to do.

                        Are you trying to get the mouse position and draw a dot where the mouse is clicked?
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13

                          Point clickPoint = chartControl.MouseDownPoint;
                          clickPoint.X = ChartingExtensions.ConvertToHorizontalPixels(click Point.X, chartControl.PresentationSource);

                          for(int barIndex = ChartBars.GetBarIdxByX(chartControl, (int)clickPoint.X); barIndex <= ChartBars.ToIndex; barIndex--)
                          {
                          sumOfVolumes4 += Bars.GetVolume(barIndex);
                          if (sumOfVolumes4 >= sumvolfibo)
                          {
                          foundIndex = barIndex;
                          Print(foundIndex);
                          break;

                          }
                          }


                          I want to draw a dot at the position returned by foundIndex

                          foundIndex returns a bar (631 ex). I want my dot on that bar.

                          Comment


                            #14
                            Hello frankduc,

                            May I confirm that the line rendered on specific bars in the Rollover indications indicator is not demonstrating exactly what you are wanting only with a line instead of a dot?

                            Can you clarify why the code in the Rollover indicator is not a sufficient example?

                            The code you are suggesting at the top is for mouse clicks. If you aren't interested in capturing mouse clicks, then that suggested code is not going to be helpful.
                            Any conditions for choosing which bars have objects rendered on them should be done in OnBarUpdate (just like in the Rollover indications indicator).
                            Then for the chosen bars you can render objects using the bars information if the bar is visible on the chart (which is demonstrated in the Rollover indications indicator)
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #15
                              Its not clear to me what does the
                              Rollover indications indicator.

                              I will need to study that indicator to understand how it can help me, cause right now i dont see how.

                              At first i wanted to draw a vertical line at the spot of the bar. I thought clickdraw would of been easier but looks like i am wrong.

                              My indicator is built onRender. I try to move it to OBU but it ask to much conversion. I wish it was possible to send foundIndex result to OBU to use drawverticalline. But its not possible without rewriting the script in OBU.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by sidlercom80, 10-28-2023, 08:49 AM
                              172 responses
                              2,278 views
                              0 likes
                              Last Post sidlercom80  
                              Started by Irukandji, Yesterday, 02:53 AM
                              2 responses
                              17 views
                              0 likes
                              Last Post Irukandji  
                              Started by adeelshahzad, Today, 03:54 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post adeelshahzad  
                              Started by CortexZenUSA, Today, 12:53 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post CortexZenUSA  
                              Started by CortexZenUSA, Today, 12:46 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post CortexZenUSA  
                              Working...
                              X