Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

keep price on chart without changing scale

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

    keep price on chart without changing scale

    Hi,

    I'd like to view a chart build at high speeds in market replay without the current price moving off the screen & without the y-axis scale changing.

    Looking through the forums I've picked up bits and pieces, and downloaded various scripts, but can't get anything to work yet.

    Here's an outline of my current effort:

    Code:
            
            protected override void Initialize()
            {
                Overlay                = true;
                BarsRequired        = 0;
                CalculateOnBarClose = false;
            }
    
            protected override void OnBarUpdate() { // do nothing here }
            
            public override void GetMinMaxValues(Gui.Chart.ChartControl chartControl, ref double min, ref double max)
            {
                // print values of min & max to determine units (pixels or price)
                Print((int)min + " " + (int)max);    // each returns -2147483648...why??
                // set min and max to new price level
                min = 1950.00;
                max = 1960.00;
            }
            
            public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)
            {
                base.Plot(graphics, bounds, min, max);
            }
    This structure seems to have no effect on my chart at all. The lower and upper prices are not set to 1950 & 1960 respectively. Where am I going wrong?

    Many thanks!

    #2
    Hi dave01,

    What you are trying to attempt is not supported by NinjaTrader to do.

    However, this thread will remain open for any community members to comment in.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi ChelseaB,

      Thanks for the speedy reply...I'll keep my fingers crossed...

      Comment


        #4
        Originally posted by dave01 View Post
        Hi,

        I'd like to view a chart build at high speeds in market replay without the current price moving off the screen & without the y-axis scale changing.

        Looking through the forums I've picked up bits and pieces, and downloaded various scripts, but can't get anything to work yet.

        Here's an outline of my current effort:

        Code:
                
                protected override void Initialize()
                {
                    Overlay                = true;
                    BarsRequired        = 0;
                    CalculateOnBarClose = false;
                }
        
                protected override void OnBarUpdate() { // do nothing here }
                
                public override void GetMinMaxValues(Gui.Chart.ChartControl chartControl, ref double min, ref double max)
                {
                    // print values of min & max to determine units (pixels or price)
                    Print((int)min + " " + (int)max);    // each returns -2147483648...why??
                    // set min and max to new price level
                    min = 1950.00;
                    max = 1960.00;
                }
                
                public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)
                {
                    base.Plot(graphics, bounds, min, max);
                }
        This structure seems to have no effect on my chart at all. The lower and upper prices are not set to 1950 & 1960 respectively. Where am I going wrong?

        Many thanks!
        If you are doing nothing in OnBarUpdate(), what is driving your Plot?

        Comment


          #5
          Hi koganam,

          Thank you for the reply. I was trying to do this without adding a plot. Not having OnBarUpdate in the indicator generated an error when compiled.

          Ideally, there would be a few Chart properties that I could set directly with code "Yaxis.Max" and "Yaxis.Min," for example. After looking at a few indicators, I was under the impression that GetMinMaxValues was the way to do this indirectly.

          I did download and try a script from the forums that plotted a transparent line, though without success at the time. NinjaTrader staff having made that sample script available and now your question lead me to believe that I should give this approach another try.

          Will post back my results...thanks again.

          Comment


            #6
            The referenced script does indeed change the plotted max & min values for the y axis, without needing to override Plot(). It's easy to see it in action when comparing with an indicator free chart to one side.

            If the user changes the y axis scaling, this script 'loses' the ability to affect the max & min values until pressing the 'F' in the upper right hand corner and returning the y axis to Auto Scale mode.

            Here's a link to the post containing the script:

            http://www.ninjatrader.com/support/f...85&postcount=2
            Last edited by dave01; 11-13-2014, 03:30 AM. Reason: change link formatting

            Comment


              #7
              As a follow-up, when the max and min plotted prices are set by code and result in part of the data series being plotted off the chart, the coded prices are apparently ignored = cannot override AutoScale with this technique.

              From the script referenced above (chart does use coded prices to plot the y axis):

              Code:
                      public override void GetMinMaxValues(Gui.Chart.ChartControl chartControl, ref double min, ref double max)
                      {
                          base.GetMinMaxValues(chartControl, ref min, ref max); 
                          // lets give us 5 ticks of up / dn space for example
                          min = min - 5; 
                          max = max + 5; 
                      }
              In the following case, the chart does not use the new values for min & max. The plot replicates an indicator free chart...AutoScale wins!

              Code:
                      public override void GetMinMaxValues(Gui.Chart.ChartControl chartControl, ref double min, ref double max)
                      {
                          base.GetMinMaxValues(chartControl, ref min, ref max); 
                          // lets take out 5 ticks of up / dn space for example
                          min = min + 5;   // try to push low off the chart
                          max = max - 5;  // try to push high off the chart
                      }

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Papercut110, Today, 03:17 AM
              0 responses
              3 views
              0 likes
              Last Post Papercut110  
              Started by max333, Today, 02:22 AM
              2 responses
              6 views
              0 likes
              Last Post NinjaTrader_Jason  
              Started by mnbowursw, Today, 02:59 AM
              0 responses
              3 views
              0 likes
              Last Post mnbowursw  
              Started by ndimtyry, Today, 02:50 AM
              0 responses
              1 view
              0 likes
              Last Post ndimtyry  
              Started by cincai, Today, 12:55 AM
              3 responses
              11 views
              0 likes
              Last Post cincai
              by cincai
               
              Working...
              X