Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ChartPanel.MaxValue

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

    ChartPanel.MaxValue

    Hi,

    It appears that ChartPanel.MaxValue and ChartPanel.MinValue do not update with the chart. I have also tried this with IsAutoScale = true. Is this expected behaviour?

    Is there any way to obtain the current values for ChartPanel.MaxValue and ChartPanel.MinValue? Thanks for any suggestions you may be able to provide.

    #2
    Hello,

    Thank you for the post.

    I wanted to check, what specific min/max value are you trying to use and for what purpose? Is this the minimum/maximum price or the bottom/top of the panel that you want to get the value for?

    The ChartPanel.MaxValue would get the calculated scale value of the Price scale for said ChartPanel, you can see this change if you adjust the scale in the indicators panel. The Charts sizing would not make this value change and the scale of the chart should only affect this value if the indicator is set to overlay.

    If you are trying to access the Min/Max scaled price values, you can use MinValue and MaxValue, these are inherited properties of an indicator and relate to its OnCalculateMinMax, if you are not using an indicator this may not apply.

    Otherwise, for the panel dimensions in X and Y coordinates/pixels you could use:

    ChartPanel.X and ChartPanel.Y for the Left and Top
    ChartPanel.W and ChartPanel.H for the Bottom and Right

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Jesse,
      I'm trying to get the Min/Max scaled price values for the chart. Do I need to use OnRender or OnCalculateMinMax()? What would be the easiest/quickest way to get these in real time?

      EDIT: ChartPanel.MaxValue inside OnRender() works in real time but I also need to know this for historical bars and we do not seem to have full access to the canvas.
      Last edited by Zeos6; 10-25-2017, 02:35 PM.

      Comment


        #4
        Hello,

        Thank you for confirming that for me.

        Yes in this case, if you are using an indicator or a type that can override the OnCalculateMinMax I would suggest using that.

        You could use the help guide sample as a template and make a slight modification so it just returns the values on the chart instead of adding to that. Here is an example:

        Code:
        public override void OnCalculateMinMax()
        		{
        		  // make sure to always start fresh values to calculate new min/max values
        		  double tmpMin = double.MaxValue;
        		  double tmpMax = double.MinValue;
        		 
        		  // For performance optimization, only loop through what is viewable on the chart
        		  for (int index = ChartBars.FromIndex; index <= ChartBars.ToIndex; index++)
        		  {
        		    // since using Close[0] is not guaranteed to be in sync
        		    // retrieve "Close" value at the current viewable range index
        		    double plotValue = Close.GetValueAt(index);
        		 
        		    // return min/max of close value
        		    tmpMin = Math.Min(tmpMin, plotValue);
        		    tmpMax = Math.Max(tmpMax, plotValue);
        		  }
        		 
        		  // Finally, set the minimum and maximum Y-Axis values to +/- 50 ticks from the primary close value
        		  MinValue = tmpMin ;
        		  MaxValue = tmpMax ;
        		  Print(MaxValue);
        		}

        You could use this override to save the values it finds to a private variable which could then be used from the remainder of your script.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Thanks for your response Jesse but this misses the point. I want to know the Max or Min value on the chart panel. Getting a bar value is useless for this. Clearly a canvas exists but we can't access all of its values. Essentially I'd like to draw something at the top of the canvass and keep it at the top on an ongoing basis. Any suggestions as to how this might be accomplished? I was hoping ChartControl would provide access to the canvass top but it doesn't.

          Comment


            #6
            Hello,

            Thank you for clarifying.

            Yes, this was what I had questioned in post #2, I had asked you originally:
            Is this the minimum/maximum price or the bottom/top of the panel that you want to get the value for?
            You noted previously that you wanted the Min/Max prices but if you instead are asking: Essentially I'd like to draw something at the top of the canvass and keep it at the top

            If you want to place something statically, you would use the following items:

            ChartPanel.X and ChartPanel.Y for the Left and Top
            ChartPanel.W and ChartPanel.H for the Bottom and Right
            This also still requires the question "for what purpose", if you are trying to use OnRender, these values transition directly. If you are trying to place something like a DrawingObject at a specific point, you would very likely need to convert the X and Y into price and bar coordinates.

            The Chart objects like the Panels are now documented and all properties are also documented, we have this shown in the help guide here: https://ninjatrader.com/support/help...chartpanel.htm

            Also, there is a sample indicator that demonstrates this called SampleCustomRender that comes with the platform.

            If you are still unclear on any of these concepts, can you provide some detail on what outcome you are trying to achieve? With more detail on the expected result, I can likely provide more accurate help information.


            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Hi Jesse,

              Thank you for the reply. I think I have not been communicating clearly enough what it is that I actually want. So let me try to explain better.

              I have an indicator that performs some calculations on each bar. If certain conditions are calculated for a bar, I would like to print a mark at the top of the price panel on the bar on which the conditions were calculated as true. I would like the marks to be printed on historical as well as real time bars.

              Using Min/Max value works on real time bars but not historical bars. Using ChartPanel.Y will provide a static output but this is not what I want. I basically need to draw a mark at the top of the canvas (directly above the bar), on any bar (historical as well as real time) for which my condition is true. There may be many bars for which the mark may need to be drawn, so I'd like to show the marks for all the bars that meet my condition. Suggestions would be greatly appreciated. Thank you.

              Comment


                #8
                Hello,

                Thank you for clearing that up.

                Based on the criteria, I would likely suggest to store into a Series when the condition has become true and then later render that data from OnRender. You could use Drawing Objects for this as well, but they would be placed at a Price instead of a static value meaning if the chart was ever scaled, they would no longer be at the top of the panel. Alternatively you would need to use something like OnCalculateMinMax to know when sizing changes, and then go back and update all the existing drawing objects with a new price. This is likely more difficult to implement and I would only suggest this if you absolutely need the user to interact with the drawings.

                I have attached a simple test that checks the Close is Greater than the Open, and if so, it draws an ellipse at the top of the chart 10 pixels from the top on each bar. This works historically as it stores the values to a series, as you scroll the chart it would visually update based on that series and how it was stored.


                The best examples for this concept would be in the help guide here:





                I look forward to being of further assistance.
                Attached Files
                JesseNinjaTrader Customer Service

                Comment


                  #9
                  Hi Jesse,

                  Thank you. This is very helpful. Please note that adding additional series when I am already dealing with a multi-timeframe situation is not great, but I guess I need to, don't I?

                  As an side, can something like this be also done with DrawText and use the Wingdings font for symbols?

                  Comment


                    #10
                    Hello,

                    Thank you for the reply.

                    You can certainly use wingdings with the text objects, but positioning them at the top of the panel would be more difficult and less accurate. You can convert the Y value into a price using the ChartScale object which can then be relayed to a Drawing Tool, but this would require that any time the scale changes or a bar updates that you go back and update the Price for all objects. This also can create strange sizing for the objects as they are tied to the charts compression.

                    This approach would also be difficult to use historically opposed to using a calculated series value. The historical bars would need to set dummy values for the drawing objects as the ChartScale object is only populated once OnRender runs after historical processing. Once the ChartScale object is populated, you can then call GetValueByY(10) which would return a Price based on the current scale at the X value of 10. This price would need to be used to update the existing objects by calling Draw. again for each. You would also need to ensure the correct BarsAgo was used for the new call to update the object.

                    Because of these difficulties, using specifically OnRender with a series would give the script access to this data historically and would not require additional loops or other reset logic.


                    I look forward to being of further assistance.
                    JesseNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by chbruno, Today, 04:10 PM
                    0 responses
                    1 view
                    0 likes
                    Last Post chbruno
                    by chbruno
                     
                    Started by josh18955, 03-25-2023, 11:16 AM
                    6 responses
                    436 views
                    0 likes
                    Last Post Delerium  
                    Started by FAQtrader, Today, 03:35 PM
                    0 responses
                    5 views
                    0 likes
                    Last Post FAQtrader  
                    Started by rocketman7, Today, 09:41 AM
                    5 responses
                    19 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by frslvr, 04-11-2024, 07:26 AM
                    9 responses
                    127 views
                    1 like
                    Last Post caryc123  
                    Working...
                    X