Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
center the price on the scale
Collapse
X
-
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
-
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
-
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
-
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
-
-
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
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by herzogvladimir2, Yesterday, 08:10 PM
|
0 responses
15 views
0 likes
|
Last Post
![]() |
||
Started by giogio1, 04-13-2025, 01:42 AM
|
2 responses
39 views
0 likes
|
Last Post
![]()
by giogio1
Yesterday, 07:19 PM
|
||
Started by mmenigma, 01-23-2024, 09:37 AM
|
1 response
92 views
0 likes
|
Last Post
![]()
by Nin8aTrender
Yesterday, 03:47 PM
|
||
Started by wbayne333, 02-22-2021, 01:18 PM
|
6 responses
415 views
0 likes
|
Last Post
![]()
by Nin8aTrender
Yesterday, 03:44 PM
|
||
Started by gtheaded, 07-03-2020, 03:47 PM
|
3 responses
374 views
0 likes
|
Last Post
![]()
by Nin8aTrender
Yesterday, 03:21 PM
|
Comment