"emaSeries[0]-ema2Series[0]" it will just print that rather than the value.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
DrawText for a calculated value?
Collapse
X
-
DrawText for a calculated value?
Hi, i would like to print a number on the chart just like i do with drawtext() but this number should be calculated, for example the current diffrence between two moving averages. but somehow i cant make it work since drawtext() requires a string so when i use something like
"emaSeries[0]-ema2Series[0]" it will just print that rather than the value.Last edited by BigRo; 10-07-2015, 09:54 AM.Tags: None
-
Hello BigRo,
Thank you for your inquiry.
The reason why it is printing "emaSeries[0]-ema2Series[0]" is because you have wrapped this statement with quotation marks. As DrawText() accepts a string for this parameter, it is just going to output that exact string you have specified.
If you wish to output a value, you will want to create a variable that will hold the value of emaSeries[0] - ema2Series[0] and use that variable with ToString() appended to it.
Example:
Please, let us know if we may be of further assistance.Code:double subtractedEMAs = emaSeries[0] - ema2Series[0]; DrawText("tag", subtractedEMAs.ToString(), .....);Zachary G.NinjaTrader Customer Service
-
Round2TickSize()?Originally posted by BigRo View Postok, worked and is there a way to round this number because it has 10-15 decimals for example
0.0008000000000005 or something.
ref: http://ninjatrader.com/support/helpG...round2ticksize
Comment
-
Originally posted by NinjaTrader_ZacharyG View PostHello BigRo,
Thank you for your inquiry.
The reason why it is printing "emaSeries[0]-ema2Series[0]" is because you have wrapped this statement with quotation marks. As DrawText() accepts a string for this parameter, it is just going to output that exact string you have specified.
If you wish to output a value, you will want to create a variable that will hold the value of emaSeries[0] - ema2Series[0] and use that variable with ToString() appended to it.
Example:
Please, let us know if we may be of further assistance.Code:double subtractedEMAs = emaSeries[0] - ema2Series[0]; DrawText("tag", subtractedEMAs.ToString(), .....);
Dear ZacharyG,
I tried to implement your idea into my Drawtext, but I get an error. Any idea what I am coding wrong?
Comment
-
Hello kadan,
As a heads up, Zachary is no longer with NinjaTrader.
Please expand the Error column so that we may read the full error message.
What is the full line of code causing the error?
From the screenshot it looks like there are too many parameters used in this overload of DrawText(). There are not any overloads that have string, string, bool.
DrawText(string tag, bool autoScale, string text, int barsAgo, double y, int yPixelOffset, Color textColor, Font font, StringAlignment alignment, Color outlineColor, Color areaColor, int areaOpacity)
Perhaps you are wanting the first string to be concatenated?
"EMA 288 max avg. " + countad.ToString()
Chelsea B.NinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_ChelseaB View PostHello kadan,
As a heads up, Zachary is no longer with NinjaTrader.
Please expand the Error column so that we may read the full error message.
What is the full line of code causing the error?
From the screenshot it looks like there are too many parameters used in this overload of DrawText(). There are not any overloads that have string, string, bool.
DrawText(string tag, bool autoScale, string text, int barsAgo, double y, int yPixelOffset, Color textColor, Font font, StringAlignment alignment, Color outlineColor, Color areaColor, int areaOpacity)
Perhaps you are wanting the first string to be concatenated?
"EMA 288 max avg. " + countad.ToString()
Dear ChelseaB,
Concatenate has helped. Thank you very much for your help :-)
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Hwop38, 05-04-2026, 07:02 PM
|
0 responses
152 views
0 likes
|
Last Post
by Hwop38
05-04-2026, 07:02 PM
|
||
|
Started by CaptainJack, 04-24-2026, 11:07 PM
|
0 responses
305 views
0 likes
|
Last Post
by CaptainJack
04-24-2026, 11:07 PM
|
||
|
Started by Mindset, 04-21-2026, 06:46 AM
|
0 responses
244 views
0 likes
|
Last Post
by Mindset
04-21-2026, 06:46 AM
|
||
|
Started by M4ndoo, 04-20-2026, 05:21 PM
|
0 responses
345 views
0 likes
|
Last Post
by M4ndoo
04-20-2026, 05:21 PM
|
||
|
Started by M4ndoo, 04-19-2026, 05:54 PM
|
0 responses
176 views
0 likes
|
Last Post
by M4ndoo
04-19-2026, 05:54 PM
|

Comment