• 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

GetMinMaxValues​​

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

    GetMinMaxValues​​

    What is the purpose of GetMinMaxValues method​​?
    There are a lot of indicators that use this method but i do not understand what their role.
    As far i can see the parameters: (max, min) their values ​​are infinite, unlike the method "Plot" to get the visible price range on screen.

    On the other hand also gets the object "chartcontrol" But this object is accessible to anywhere using ChartControl directly.
    Can anyone explain what advantages you have or when to use GetMinMaxValues​​?
    Code:
    public override void GetMinMaxValues(ChartControl chartControl, ref double min, ref double max)
            {
                sMinGMMV=min.String;
                sMaxGMMV=max.String;
            }
    public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)
            {
               sMinPlot = min.String;
               sMaxPlot= max.Plot;
            }
    When you draw those strings..:

    thanks
    Attached Files

    #2
    Hi Ramon, you could use this method to override the per default set min max value range of the scale method NT uses - however using it would not be supported nor documented by us unfortunately but for illustration sakes I've attached a simple script you could experiment on your end with.
    Attached Files
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Indeed, it works.
      The maximum and minimum values ​​differ with respect to those obtained in "Plot" method , I guess it has to do with rounding and conversions of pixels at prices

      The difference between getting good and bad values lies in the fact of defining and using a "plot" . SMA.in your case.

      Must I use a Plot to get good (max/min) values ?.
      Attached Files

      Comment


        #4
        Using base.GetMinMaxValues

        I'm writing an indicator and need to get the values of the min and max prices painted.

        Essentially I have established a list of support and resistance levels and during OnBarUpdate() I want to check whether each S or R level is currently on screen at this instant and if so, to draw a horizontal line to display it.

        Just checking around on the net to find the best method to obtain min and max prices, I discovered base.GetMinMaxValues() but also discovered it's not supported.

        I'm trying to use it like this:

        Code:
                protected override void Initialize()
                {
                    Add(PeriodType.Minute, 60);
                    Overlay = true;
                }
        
                protected override void OnBarUpdate()
                {
                    // Checks to ensure Bars objects contain enough bars before beginning
                    if (CurrentBars[0] <= BarsRequired 
                        || CurrentBars[1] <= 3)
                        return;
                    if (BarsInProgress == 1) // 60mins
                    {
                        if (Low[2] < Low[0] && Low[2] < Low[1]
                            && Low[2] < Low[3] && Low[3] < Low[4])
                        {
                            support.Add(Time[2]);
                        }
                        return;
                    }
                    double min = 0.0;
                    double max = 0.0;
                    try
                    {
                        base.GetMinMaxValues(this.ChartControl, ref min, ref max);
                    }
                    catch (Exception exception) 
                    { 
                        if (!done) Alert("1", Priority.High, exception.Message,
                            "Alert1.wav", 10, Color.Black, Color.Yellow);
                        done = true;
                    }
                    foreach (DateTime when in support)
                    {
                        int bar60mX = BarsArray[1].GetBar(when);
                        int lowBarsAgo = CurrentBars[1] - bar60mX;
                        double swingLow = Lows[1][lowBarsAgo];
                        if (swingLow < max && swingLow > min)
                        {
                            int barPrimaryX = BarsArray[0].GetBar(when);
                            lowBarsAgo = CurrentBars[0] - barPrimaryX;
                            DrawLine("S" + bar60mX, lowBarsAgo, swingLow, 0, swingLow, Color.DarkBlue);
                        }
                    }
                }
        However this is crashing NT7. It just dies, no exception,nothing in the logs. Just gone.

        Can anyone see what I'm doing wrong?

        Thanks

        Comment


          #5
          Just override Plot().

          Store the min and max provided within Plot() in some variables and then reference the stored values from OnBarUpdate or where ever you want.

          Comment


            #6
            Originally posted by BigWaveDave View Post
            Just override Plot().

            Store the min and max provided within Plot() in some variables and then reference the stored values from OnBarUpdate or where ever you want.
            adamus :: "I'm writing an indicator and need to get the values of the min and max prices painted."



            Wouldn't high[0] and low[0] work? or am I missing something?

            Comment


              #7
              Now that is a solution and a half. Thanks.

              Just to verify this is all it takes:

              Code:
              double currentMin;
              double currentMax;
              
                  public override void Plot(Graphics graphics, Rectangle bounds, 
                          double min, double max)
                      {
                          base.Plot(graphics, bounds, min, max);
                          currentMin = min;
                          currentMax = max;
                      }
              Last edited by adamus; 02-14-2013, 04:32 AM.

              Comment


                #8
                Looks right.

                Just to clarify... you are looking for the upper and lower bounds of the chart in terms of price, correct? In other words, the extremes of the price scale (y-axis). In order to determine if you want to paint something or not, I assume.

                Not just the high and low price of the currently displayed bars on the chart....
                Last edited by BigWaveDave; 02-14-2013, 05:51 AM.

                Comment


                  #9
                  Originally posted by BigWaveDave View Post
                  Looks right.

                  Just to clarify... you are looking for the upper and lower bounds of the chart in terms of price, correct? In other words, the extremes of the price scale (y-axis). In order to determine if you want to paint something or not, I assume.

                  Not just the high and low price of the currently displayed bars on the chart....
                  You're probably right as to adamus's intentions.

                  Comment


                    #10
                    Hi Dave,
                    your assumption is correct - I just ignored Sledge's post because I couldn't make immediate sense of his question or better said, what he was thinking when he asked it.

                    I need the high and low of the bars currently on the chart.

                    It's tough that there's no documentation on the Plot() method and how to craft the overriding method you/I want - all the examples I have looked at want to do something else so I was confused by it and was slowly experimenting to see what happens when I do different things in Plot().

                    The first thing I wasn't sure about was how often it is called. Do you know?

                    I assume it is called every time there is a new tick when live, and also every time I change the axes manually - either scrolling backwards and forwards or shrinking / expanding the range displayed, on both x and y axes.

                    I also assume but I haven't got to the point where it would make any difference, I assume when using CalculateOnBarClose=false, that the OnBarUpdate() event would fire on a new tick before the Plot() event. Is that what you assumed?

                    Comment


                      #11
                      It still sounds like there is confusion.

                      The Min, Max provided in the Plot() override have nothing to do with any price data in the chart. They describe the 'physical' upper and lower bounds of the chart in price. In other words, they describe the extent of the y-axis in price.

                      Plot is updated when the y-axis is scaled or transformed. The min and max values can be used to determine the vertical pixel offset within the chartpanel of a specific price because we not only know the price extent of the y-axis but we also know the bounds (in pixels) of the chartpanel.

                      Min and Max are valid even if there isn't a dataseries in the chart.'


                      There may be an easy way to the high and low of the visible bars. I dunno. My first though would be to determine what the first and last bar visible on the chart are, then iterate through the dataseries tracking the highest high and lowest low as you go. It should be an easy routine to write. You would want to process the routine on each OnBarUpdate().
                      Last edited by BigWaveDave; 02-14-2013, 06:53 AM.

                      Comment


                        #12
                        Alright, I'm with you. I was thinking what you said but I wasn't differentiating it from what I said but of course it's the top and bottom of the y axis, not the max high and min low of the data series, especially considering that I might have a fixed scale on the chart as opposed to the auto-scale.

                        It was just a lazy assumption I had made based on auto-scaling that there was a direct relationship between the y-axis and the max high and min low.

                        Thanks for pointing it out. I wouldn't need to know what the actual price max and min were.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by vpzdcv, Today, 02:31 AM
                        0 responses
                        7 views
                        0 likes
                        Last Post vpzdcv
                        by vpzdcv
                         
                        Started by YevhenShynkarenko, Today, 01:22 AM
                        0 responses
                        14 views
                        0 likes
                        Last Post YevhenShynkarenko  
                        Started by ttodua, Today, 12:52 AM
                        0 responses
                        6 views
                        0 likes
                        Last Post ttodua
                        by ttodua
                         
                        Started by ttodua, Today, 12:50 AM
                        0 responses
                        5 views
                        0 likes
                        Last Post ttodua
                        by ttodua
                         
                        Started by mulshah, Yesterday, 11:12 PM
                        0 responses
                        7 views
                        0 likes
                        Last Post mulshah
                        by mulshah
                         
                        Working...
                        X