Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
x-value of current bar
Collapse
X
-
x-value of current bar
Is it possible to get the x value of the current bar to us in order to plot text just to the right of the current bar? I have programming set up so the text is floating with price for the y-value but can't get it to scroll left and right as I scroll the chart left and right. The text is staying on the right side of the screen. Any ideas? -
Hello jhowinvest,
Yes, this would be possible by overriding the plot method inside of NinjaTrader. This is not something that we can support but you can view the following references to help you get started with this.
1. You may go to Tools -> Edit NinjaScript -> Indicators -> CustomPlotSample.
2. Our File Sharing Section does have a few indicators that do this as well, one of which is at the following link.
Let us know if we can be of further assistance.JCNinjaTrader Customer Service
-
Thanks but I am still having trouble. This is a variation of the tick counter 3 in the file sharing section. The float with price is great for the y-value but I would like it to slide left and right as I manually scroll the chart. I did set up a private int called "marginValue" that will allow a person to change how far from the right margin the text prints but it is not dynamic like the y-value is.
Here is the section of code if anyone wants to tackle this.
// calculate x,y location for text display
float x;
float y;
switch (DispLocation)
{
case DisplayLocation3.Float_with_price: //the x = line did say x = bounds.X + bounds.Width - ChartControl.BarMarginRight + 5;
x = bounds.X + bounds.Width - ChartControl.BarMarginRight + marginValue;
y = (int)(((bounds.Y + bounds.Height) - ((Close[0] - min) / ChartControl.MaxMinusMin(max, min)) * bounds.Height) - textHeight*0.4);
if(ChartControl.BarMarginRight < textWidth-12)
graphics.DrawString("Increase chart Properties - Right side margin", TextFont, textBrush, bounds.X + bounds.Width - noTickTextWidth, bounds.Y + bounds.Height - noTickTextHeight, stringFormat);
break;
Comment
-
Hello jhowinvest,
Thank you for your response.
The ChartControl.BarMarginValue is based on the right side margin as you know, this means if you set the x value to this it will stay static in correlation to the bounds on the right side of the chart. If you would like the x value to stay at a point such as a bar on the chart does you will need to use something such as the bar it's self as the reference point and not the right side margin.
Comment
-
Thanks Patrick. I changed things around because I was making it too complicated. I used your advice and have it working now. I used draw text to keep the tick counter right near the current price bar. Thanks again. Basic code is below:
int ticksRemaining = Bars.Period.Value - Bars.TickCount;
Font textFont = new Font("Arial", textSize, FontStyle.Bold);
if (Bars.Period.Id == PeriodType.Tick && printSymbol == true)
{
DrawText("tag1", false, "<" + ticksRemaining, 0 - counterOffset, Close[0], 0, textColor, textFont, StringAlignment.Near, Color.Transparent, Color.Transparent, 0);
}
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by rocketman7, Today, 02:12 AM
|
3 responses
20 views
0 likes
|
Last Post Today, 08:05 AM | ||
Started by trilliantrader, 04-18-2024, 08:16 AM
|
7 responses
27 views
0 likes
|
Last Post Today, 07:56 AM | ||
Started by samish18, 04-17-2024, 08:57 AM
|
17 responses
65 views
0 likes
|
Last Post Today, 07:51 AM | ||
Started by briansaul, Today, 05:31 AM
|
1 response
13 views
0 likes
|
Last Post Today, 07:36 AM | ||
Started by PaulMohn, Today, 03:49 AM
|
1 response
12 views
0 likes
|
Last Post Today, 07:36 AM |
Comment