Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Number of Bars and Size of the Current View Area

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

    Number of Bars and Size of the Current View Area

    Hi,

    I got two questions.


    1) Would appreciate very much if anyone could indicate a method to calculate the number of bars in the current Chart View Area.

    The reason is that I would like to Draw some Text or Plot some arrows on the charts, but depending on the scale of the chart, I need to know what is the Maximum / Low value of price in the current view area.


    To plot one arrow in a 3 min chart, where the Max-Min value of current view are is 20 pts I can use this line of code:
    DrawArrowDown("down", 0, High[0]+TickSize, Color.Blue);


    However in one scale of 30 min, I have to ajust the Vertical position so that the arrow would be well above the candle:
    DrawArrowDown("down", 0, High[0]+TickSize*5, Color.Blue);


    How can I know the Max and Min value of the Current View Area of one Chart?

    I think If I got the number of bars of current view area (not Bars.BarsSinceSession), but only the number of Bars that are currently displayed, in order to obtain the Max and Min.

    Attached is one image that shows what I mean.


    2) I've seen in a script a method to calculate the Size of current Chart View Area.
    Height = bounds.Size.Height; // would give the Height in pixels
    Width = bounds.Size.Width; // would give the With in pixels


    The problem is that to access those bounds.... it seams to be necessary to include it in a function like this:
    public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)


    That is declared outside the OnBarUpdate() procedure, and when the code goes to that procedure,
    doesn't come back to OnBarUpdate() procedure.


    The question is, how do we get these values without having to put them inside that procedure?

    If we don't do that, we receive a error code saying:
    the name 'bounds' doesn't exist in the current context


    -------------

    Help would be more then welcome.

    Kind regards,

    Candido
    Attached Files

    #2
    Unfortunately this is beyond the scope of what we can provide support for. You will probably need to override the Plot() method to achieve what you want. In the Plot() method you can store a variable that contains the spacing distance you want and then just use that variable in the OnBarUpdate() method.
    Josh P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by cre8able, Today, 03:20 PM
    1 response
    9 views
    0 likes
    Last Post cre8able  
    Started by fiddich, Today, 05:25 PM
    0 responses
    3 views
    0 likes
    Last Post fiddich
    by fiddich
     
    Started by gemify, 11-11-2022, 11:52 AM
    6 responses
    804 views
    2 likes
    Last Post ultls
    by ultls
     
    Started by ScottWalsh, Today, 04:52 PM
    0 responses
    4 views
    0 likes
    Last Post ScottWalsh  
    Started by ScottWalsh, Today, 04:29 PM
    0 responses
    9 views
    0 likes
    Last Post ScottWalsh  
    Working...
    X