Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

center the price on the scale

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

    center the price on the scale

    is it possible to access center the price on the scale

    #2
    Hello franatas,

    I have moved this thread from the General Development section of the forums to the Platform Technical Support section of the forums as this does not appear to relate to NinjaScript Development (programming).

    Is this a SuperDOM window or a chart?

    On the SuperDOM, there is an Auto center option in the Properties window.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Yes, it is related to creating an indicator that automatically centers the chart at the candle close. And if there is the possibility of accessing this function, I am also interested in knowing what the last visible candle on the chart is called, so that if the last visible candle is 0, it will be executed and if not, it will not be executed.

      Comment


        #4
        Hello franatas,

        A chart does not have an auto center as the scaling is controlled by the AutoScaling and OnCalculateMinMax() for all scripts using the same price scale.

        If you were to only have one indicator on the price scale included with AutoScaling, that one indicator could center the price by making the MaxValue and MinValue an equal distance from the market price in OnCalculateMinMax().


        The last visible bar will be Chart.ToIndex.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          I was looking at the OnCalculateMinMax() example. but putting at the end of the candle AutoScaling = true does not react and I have no idea how to make 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 - 50 * TickSize;
          MaxValue = tmpMax + 50 * TickSize;
          } be executed.
          Could you give me a hand with this?​

          Comment


            #6
            Hello franatas,

            May I confirm the indicator is the only object with Auto Scaling enabled?
            (The data series and other indicators have Auto Scaling disabled in the DataSeries and Indicators window, correct?)

            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              This is solved, now I have to take the graph to the last candle, that is, when you press the F on the graph, it not only centers vertically but drags the graph just like when you press the arrow and it takes you to the last bar.
              Last edited by franatas; 02-08-2024, 05:34 AM.

              Comment


                #8
                Hello franatas,

                Unfortunately, there are no supported methods to scroll the chart on the time (X) axis.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  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;

                  // Get the index of the last bar
                  int lastIndex = ChartBars.ToIndex;

                  // Retrieve "Close" value at the last bar
                  double plotValue = Close.GetValueAt(lastIndex);

                  // Return min/max of close value for the last bar
                  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 - 50 * TickSize;
                  MaxValue = tmpMax + 50 * TickSize;
                  }​

                  Here the graph centers the last price of the last bar whenever, centering the price on the scale is true, and I cannot access this option of the data series to set it to true at the end of each bar?

                  Comment


                    #10
                    Hello franatas,

                    OnCalculateMinMax() runs anytime the chart updates and not just when a bar closes..

                    Are you trying to prevent the autoscaling from running until the bar closes?

                    What option are you trying to access from the data series window?
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Click image for larger version

Name:	2024-02-20_08h03_06.png
Views:	39
Size:	35.8 KB
ID:	1292149
                      centrar el precio en la escala, This is where I want to go.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by lightsun47, Today, 03:51 PM
                      0 responses
                      2 views
                      0 likes
                      Last Post lightsun47  
                      Started by 00nevest, Today, 02:27 PM
                      1 response
                      8 views
                      0 likes
                      Last Post 00nevest  
                      Started by futtrader, 04-21-2024, 01:50 AM
                      4 responses
                      41 views
                      0 likes
                      Last Post futtrader  
                      Started by Option Whisperer, Today, 09:55 AM
                      1 response
                      13 views
                      0 likes
                      Last Post bltdavid  
                      Started by port119, Today, 02:43 PM
                      0 responses
                      8 views
                      0 likes
                      Last Post port119
                      by port119
                       
                      Working...
                      X